galaxy-dist commit a8ef6a46d622: Added AttributeValueSplitterFilter to tool select parameter filters so that GFF attributes can be read and used as tool inputs. Updated gff_filtering tool to use this filter.
# HG changeset patch -- Bitbucket.org # Project galaxy-dist # URL http://bitbucket.org/galaxy/galaxy-dist/overview # User jeremy goecks <jeremy.goecks@emory.edu> # Date 1280439706 14400 # Node ID a8ef6a46d6221d8eb3a7bc919fc3e2b13c1bc2aa # Parent 66e03194e2dae00723d446509e077a869f274922 Added AttributeValueSplitterFilter to tool select parameter filters so that GFF attributes can be read and used as tool inputs. Updated gff_filtering tool to use this filter. --- a/lib/galaxy/tools/parameters/dynamic_options.py +++ b/lib/galaxy/tools/parameters/dynamic_options.py @@ -206,6 +206,40 @@ class MultipleSplitterFilter( Filter ): for field in fields[column].split( self.separator ): rval.append( fields[0:column] + [field] + fields[column:] ) return rval + +class AttributeValueSplitterFilter( Filter ): + """ + Filters a list of attribute-value pairs to be unique attribute names. + + Type: attribute_value_splitter + + Required Attributes: + column: column in options to compare with + Optional Attributes: + pair_separator: Split column by this (,) + name_val_separator: Split name-value pair by this ( whitespace ) + """ + def __init__( self, d_option, elem ): + Filter.__init__( self, d_option, elem ) + self.pair_separator = elem.get( "pair_separator", "," ) + self.name_val_separator = elem.get( "name_val_separator", None ) + self.columns = elem.get( "column", None ) + assert self.columns is not None, "Required 'columns' attribute missing from filter" + self.columns = [ int ( column ) for column in self.columns.split( "," ) ] + def filter_options( self, options, trans, other_values ): + attr_names = [] + rval = [] + for fields in options: + for column in self.columns: + for pair in fields[column].split( self.pair_separator ): + ary = pair.split( self.name_val_separator ) + if len( ary ) == 2: + name, value = ary + if name not in attr_names: + rval.append( fields[0:column] + [name] + fields[column:] ) + attr_names.append( name ) + return rval + class AdditionalValueFilter( Filter ): """ @@ -322,6 +356,7 @@ filter_types = dict( data_meta = DataMet static_value = StaticValueFilter, unique_value = UniqueValueFilter, multiple_splitter = MultipleSplitterFilter, + attribute_value_splitter = AttributeValueSplitterFilter, add_value = AdditionalValueFilter, remove_value = RemoveValueFilter, sort_by = SortByColumnFilter ) --- a/tools/ngs_rna/gff_filtering.xml +++ b/tools/ngs_rna/gff_filtering.xml @@ -5,8 +5,12 @@ </command><inputs><param format="gff" name="input" type="data" label="Filter" help="Query missing? See TIP below."/> - <param name="attribute_name" size="40" type="text" label="Attribute name" help=""> - <validator type="empty_field" message="Enter a valid attribute name."/> + <param name="attribute_name" type="select" label="Attribute name" help=""> + <options from_dataset="input"> + <column name="name" index="8"/> + <column name="value" index="8"/> + <filter type="attribute_value_splitter" pair_separator=";" column="8"/> + </options></param><param name="attribute_type" type="select" label="Attribute type"><option value="float">Float</option>
participants (1)
-
commits-noreply@bitbucket.org