1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/95bcb99ad2b4/ Changeset: 95bcb99ad2b4 User: jmchilton Date: 2014-09-26 14:49:43+00:00 Summary: Fix data column parameters pointed at multiple data parameters. Before it would just die with an unhelpful server side exception - now it attempts to build, validate, and use a useful set of columns. Affected #: 4 files diff -r d27e8692adadf069e30d454cdb7a634526a6ba45 -r 95bcb99ad2b467ca0176a1e5e747bb18cd3cc61f lib/galaxy/tools/parameters/basic.py --- a/lib/galaxy/tools/parameters/basic.py +++ b/lib/galaxy/tools/parameters/basic.py @@ -1170,34 +1170,47 @@ Generate a select list containing the columns of the associated dataset (if found). """ - column_list = [] # No value indicates a configuration error, the named DataToolParameter # must preceed this parameter in the config assert self.data_ref in other_values, "Value for associated DataToolParameter not found" # Get the value of the associated DataToolParameter (a dataset) dataset = other_values[ self.data_ref ] # Check if a dataset is selected - if dataset is None or dataset == '': + if dataset is None or dataset == '' or dataset == []: # NOTE: Both of these values indicate that no dataset is selected. # However, 'None' indicates that the dataset is optional # while '' indicates that it is not. Currently column # parameters do not work well with optional datasets - return column_list - # Generate options - if not dataset.metadata.columns: - if self.accept_default: - column_list.append( self.default_value or '1' ) - return column_list - if not self.force_select: + return [] + column_list = None + for dataset in util.listify( dataset ): + # Handle columns not available. + if not dataset.metadata.columns: + default_column_list = [] + if self.accept_default: + default_column_list.append( self.default_value or '1' ) + return default_column_list + + # Build up possible columns for this dataset + this_column_list = [] + if self.numerical: + # If numerical was requested, filter columns based on metadata + for i, col in enumerate( dataset.metadata.column_types ): + if col == 'int' or col == 'float': + this_column_list.append( str( i + 1 ) ) + else: + for i in range(0, dataset.metadata.columns): + this_column_list.append( str( i + 1 ) ) + + # Take the intersection of these columns with the other columns. + if column_list is None: + column_list = this_column_list + else: + column_list = filter(lambda c: c in this_column_list, column_list) + + if not self.force_select and 'None' not in column_list: column_list.append( 'None' ) - if self.numerical: - # If numerical was requested, filter columns based on metadata - for i, col in enumerate( dataset.metadata.column_types ): - if col == 'int' or col == 'float': - column_list.append( str( i + 1 ) ) - else: - for i in range(0, dataset.metadata.columns): - column_list.append( str( i + 1 ) ) + return column_list def get_options( self, trans, other_values ): @@ -1249,14 +1262,15 @@ if self.data_ref not in context: return False # Get the selected dataset if selected - dataset = context[ self.data_ref ] - if dataset: - # Check if the dataset does not have the expected metadata for columns - if not dataset.metadata.columns: - # Only allow late validation if the dataset is not yet ready - # (since we have reason to expect the metadata to be ready eventually) - if dataset.is_pending or not dataset.datatype.matches_any( self.ref_input.formats ): - return True + datasets = util.listify( context[ self.data_ref ] ) + for dataset in datasets: + if dataset: + # Check if the dataset does not have the expected metadata for columns + if not dataset.metadata.columns: + # Only allow late validation if the dataset is not yet ready + # (since we have reason to expect the metadata to be ready eventually) + if dataset.is_pending or not dataset.datatype.matches_any( self.ref_input.formats ): + return True # No late validation return False diff -r d27e8692adadf069e30d454cdb7a634526a6ba45 -r 95bcb99ad2b467ca0176a1e5e747bb18cd3cc61f test/functional/tools/column_multi_param.xml --- /dev/null +++ b/test/functional/tools/column_multi_param.xml @@ -0,0 +1,25 @@ +<tool id="column_multi_param" name="Column Param Multi"> + <command> + #for $input in $input1# + cut -f '$col' '$input' >> 'col_output'; + #end for# + </command> + <inputs> + <param type="data" format="tabular" name="input1" label="Input 1" multiple="true" /> + <param name="col" type="data_column" data_ref="input1" label="Column to Use" /> + </inputs> + <outputs> + <data name="output1" type="tabular" from_work_dir="col_output" /> + </outputs> + <tests> + <test> + <param name="input1" value="2.tabular,2.tabular" /> + <param name="col" value="2" /> + <output name="outpu1"> + <assert_contents> + <has_line line="68" /> + </assert_contents> + </output> + </test> + </tests> +</tool> diff -r d27e8692adadf069e30d454cdb7a634526a6ba45 -r 95bcb99ad2b467ca0176a1e5e747bb18cd3cc61f test/functional/tools/column_param.xml --- /dev/null +++ b/test/functional/tools/column_param.xml @@ -0,0 +1,23 @@ +<tool id="column_param" name="Column Param"> + <command> + cut -f '$col' '$input1' > 'col_output' + </command> + <inputs> + <param type="data" format="tabular" name="input1" label="Input 1" /> + <param name="col" type="data_column" data_ref="input1" label="Column to Use" /> + </inputs> + <outputs> + <data name="output1" type="tabular" from_work_dir="col_output" /> + </outputs> + <tests> + <test> + <param name="input1" value="2.tabular" /> + <param name="col" value="2" /> + <output name="output1"> + <assert_contents> + <has_line line="68" /> + </assert_contents> + </output> + </test> + </tests> +</tool> diff -r d27e8692adadf069e30d454cdb7a634526a6ba45 -r 95bcb99ad2b467ca0176a1e5e747bb18cd3cc61f test/functional/tools/samples_tool_conf.xml --- a/test/functional/tools/samples_tool_conf.xml +++ b/test/functional/tools/samples_tool_conf.xml @@ -20,6 +20,8 @@ <tool file="parallelism_optional.xml" /><tool file="implicit_default_conds.xml" /><tool file="multi_data_param.xml" /> + <tool file="column_param.xml" /> + <tool file="column_multi_param.xml" /><tool file="special_params.xml" /><tool file="validation_default.xml" /><tool file="validation_sanitizer.xml" /> Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.