comparison w4mcorcov_input.R @ 5:50f60f94c034 draft

planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
author eschen42
date Fri, 30 Mar 2018 14:59:19 -0400
parents 23f9fad4edfc
children 066b1f409e9f
comparison
equal deleted inserted replaced
4:8bba31f628da 5:50f60f94c034
34 || ! ( xcms_data_type %in% c("sampleMetadata", "variableMetadata", "dataMatrix") ) 34 || ! ( xcms_data_type %in% c("sampleMetadata", "variableMetadata", "dataMatrix") )
35 ) { 35 ) {
36 my_failure_action( sprintf("bad parameter xcms_data_type '%s'", xcms_data_type) ) 36 my_failure_action( sprintf("bad parameter xcms_data_type '%s'", xcms_data_type) )
37 return ( FALSE ) 37 return ( FALSE )
38 } 38 }
39 if ( is.character(xcms_data_in) ){ 39 if ( is.character(xcms_data_in) ) {
40 # case: xcms_data_in is a path to a file 40 # case: xcms_data_in is a path to a file
41 xcms_data_input_env <- read_data_frame( xcms_data_in, sprintf("%s input", xcms_data_type) ) 41 xcms_data_input_env <- read_data_frame( xcms_data_in, sprintf("%s input", xcms_data_type) )
42 if (!xcms_data_input_env$success) { 42 if (!xcms_data_input_env$success) {
43 my_failure_action(xcms_data_input_env$msg) 43 my_failure_action(xcms_data_input_env$msg)
44 return ( FALSE ) 44 return ( FALSE )
45 } 45 }
46 return ( xcms_data_input_env$data ) 46 return ( xcms_data_input_env$data )
47 # commenting out pasted code that is not tested here
48 # } else if ( is.data.frame(xcms_data_in) || is.matrix(xcms_data_in) ) {
49 # # case: xcms_data_in is a data.frame or matrix
50 # return(xcms_data_in)
51 # } else if ( is.list(xcms_data_in) || is.environment(xcms_data_in) ) {
52 # # NOTE WELL: is.list succeeds for data.frame, so the is.data.frame test must appear before the is.list test
53 # # case: xcms_data_in is a list
54 # if ( ! exists(xcms_data_type, where = xcms_data_in) ) {
55 # my_failure_action(sprintf("%s xcms_data_in is missing member '%s'"), ifelse(is.environment(xcms_data_in),"environment","list"), xcms_data_type)
56 # return ( FALSE )
57 # }
58 # prospect <- getElement(name = xcms_data_type, object = xcms_data_in)
59 # if ( ! is.data.frame(prospect) && ! is.matrix(prospect) ) {
60 # utils::str("list - str(prospect)")
61 # utils::str(prospect)
62 # if ( is.list(xcms_data_in) ) {
63 # my_failure_action(sprintf("the first member of xcms_data_in['%s'] is neither a data.frame nor a matrix but is a %s", xcms_data_type, typeof(prospect)))
64 # } else {
65 # my_failure_action(sprintf("the first member of xcms_data_in$%s is neither a data.frame nor a matrix but is a %s", xcms_data_type, typeof(prospect)))
66 # }
67 # return ( prospect )
68 # }
69 # # stop("stopping here for a snapshot")
70 # return ( prospect )
71 } else { 47 } else {
72 # case: xcms_data_in is invalid 48 # case: xcms_data_in is invalid
73 my_failure_action( sprintf("xcms_data_in has unexpected type %s", typeof(xcms_data_in)) ) 49 my_failure_action( sprintf("xcms_data_in has unexpected type %s", typeof(xcms_data_in)) )
74 return ( FALSE ) 50 return ( FALSE )
75 } 51 }