1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/bc309f6d4ce5/ changeset: bc309f6d4ce5 user: jgoecks date: 2013-02-07 18:57:30 summary: Add function to query tool data tables by attribute-value pairs and expose this functionality to tool wrappers. This is needed for tool wrappers that use data tables but do not use dynamic options. affected #: 2 files diff -r 57bd06b6e9fa4cb1b6591216b6f4d3010b21f060 -r bc309f6d4ce5e18c9d2c8eac6a50eeac06664554 lib/galaxy/tools/__init__.py --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -2267,10 +2267,14 @@ `to_param_dict_string` method of the associated input. """ param_dict = dict() + # All parameters go into the param_dict param_dict.update( incoming ) - # Wrap parameters as neccesary + def wrap_values( inputs, input_values ): + """ + Wraps parameters as neccesary. + """ for input in inputs.itervalues(): if isinstance( input, Repeat ): for d in input_values[ input.name ]: @@ -2333,11 +2337,13 @@ else: input_values[ input.name ] = InputValueWrapper( input, input_values[ input.name ], param_dict ) + # HACK: only wrap if check_values is not false, this deals with external # tools where the inputs don't even get passed through. These # tools (e.g. UCSC) should really be handled in a special way. if self.check_values: wrap_values( self.inputs, param_dict ) + ## FIXME: when self.check_values==True, input datasets are being wrapped ## twice (above and below, creating 2 separate ## DatasetFilenameWrapper objects - first is overwritten by @@ -2390,6 +2396,20 @@ # failed to pass; for tool writing convienence, provide a # NoneDataset param_dict[ out_name ] = NoneDataset( datatypes_registry = self.app.datatypes_registry, ext = output.format ) + + # -- Add useful attributes/functions for use in creating command line. + + # Function for querying a data table. + def get_data_table_entry(table_name, query_attr, query_val, return_attr): + """ + Queries and returns an entry in a data table. + """ + + if table_name in self.app.tool_data_tables: + return self.app.tool_data_tables[ table_name ].get_entry( query_attr, query_val, return_attr ) + + param_dict['__get_data_table_entry__'] = get_data_table_entry + # We add access to app here, this allows access to app.config, etc param_dict['__app__'] = RawObjectWrapper( self.app ) # More convienent access to app.config.new_file_path; we don't need to diff -r 57bd06b6e9fa4cb1b6591216b6f4d3010b21f060 -r bc309f6d4ce5e18c9d2c8eac6a50eeac06664554 lib/galaxy/tools/data/__init__.py --- a/lib/galaxy/tools/data/__init__.py +++ b/lib/galaxy/tools/data/__init__.py @@ -240,7 +240,26 @@ fields = line.split( self.separator ) if self.largest_index < len( fields ): rval.append( fields ) - return rval + return rval + + def get_entry( self, query_attr, query_val, return_attr ): + """ + Returns table entry associated with a col/val pair. + """ + query_col = self.columns.get( query_attr, None ) + if not query_col: + return None + return_col = self.columns.get( return_attr, None ) + if not return_col: + return None + + # Look for table entry. + for fields in self.data: + if fields[ query_col ] == query_val: + rval = fields[ return_col ] + break + + return rval # Registry of tool data types by type_key tool_data_table_types = dict( [ ( cls.type_key, cls ) for cls in [ TabularToolDataTable ] ] ) 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.