[hg] galaxy 1489: Add a metadata parameter to Alignment datatype...
details: http://www.bx.psu.edu/hg/galaxy/rev/21534250600b changeset: 1489:21534250600b user: Dan Blankenberg <dan@bx.psu.edu> date: Thu Aug 28 15:12:53 2008 -0400 description: Add a metadata parameter to Alignment datatypes which stores chromosome information found in the alignment for each species. GMAJ tool no longer needs to have the chromosome specified for annotations. 4 file(s) affected in this change: lib/galaxy/datatypes/metadata.py lib/galaxy/datatypes/sequence.py templates/dataset/edit_attributes.mako tools/visualization/GMAJ.xml diffs (192 lines): diff -r dcaed9f80caf -r 21534250600b lib/galaxy/datatypes/metadata.py --- a/lib/galaxy/datatypes/metadata.py Thu Aug 28 13:57:23 2008 -0400 +++ b/lib/galaxy/datatypes/metadata.py Thu Aug 28 15:12:53 2008 -0400 @@ -66,6 +66,7 @@ value = str( value ) self.value = value self.context = context + self.display = True def __str__(self): if self.value is None: @@ -264,4 +265,24 @@ def __str__(self): return ",".join( map( str, self.value ) ) +class PythonObjectParameter( MetadataParameter ): + def __init__( self, spec, value, context ): + MetadataParameter.__init__( self, spec, value, context ) + self.value = value + self.display = False + + def __str__(self): + if not self.value: + return self.spec.to_string( self.spec.no_value ) + return self.spec.to_string( self.value ) + + def get_html_field( self, value=None, other_values={} ): + return form_builder.TextField( self.spec.name, value=str( self ) ) + def get_html( self ): + return str( self ) + + @classmethod + def marshal( cls, value ): + return value + diff -r dcaed9f80caf -r 21534250600b lib/galaxy/datatypes/sequence.py --- a/lib/galaxy/datatypes/sequence.py Thu Aug 28 13:57:23 2008 -0400 +++ b/lib/galaxy/datatypes/sequence.py Thu Aug 28 15:12:53 2008 -0400 @@ -24,6 +24,7 @@ """Add metadata elements""" MetadataElement( name="species", desc="Species", default=[], param=metadata.SelectParameter, multiple=True, readonly=True, no_value=None ) + MetadataElement( name="species_chromosomes", desc="Species Chromosomes", value={}, param=metadata.PythonObjectParameter, readonly=True, no_value={}, to_string=str ) class Fasta( Sequence ): """Class representing a FASTA sequence""" @@ -165,9 +166,10 @@ def set_meta( self, dataset, first_line_is_header=False, **kwd ): """ - Parses and returns species from MAF files. + Parses and sets species and chromosomes from MAF files. """ species = [] + species_chromosomes = {} try: for i, m in enumerate( bx.align.maf.Reader( open(dataset.file_name) ) ): for c in m.components: @@ -176,15 +178,20 @@ # "src_split" finds the rightmost dot, which is probably # wrong in general, and certainly here. spec = c.src + chrom = None if "." in spec: - spec = spec.split( "." )[0] + spec, chrom = spec.split( ".", 1 ) if spec not in species: species.append(spec) + species_chromosomes[spec] = [] + if chrom and chrom not in species_chromosomes[spec]: + species_chromosomes[spec].append( chrom ) # only check first 100,000 blocks for species if i > 100000: break except: pass dataset.metadata.species = species + dataset.metadata.species_chromosomes = species_chromosomes def missing_meta( self, dataset ): """Checks to see if species is set""" diff -r dcaed9f80caf -r 21534250600b templates/dataset/edit_attributes.mako --- a/templates/dataset/edit_attributes.mako Thu Aug 28 13:57:23 2008 -0400 +++ b/templates/dataset/edit_attributes.mako Thu Aug 28 15:12:53 2008 -0400 @@ -39,15 +39,17 @@ <div style="clear: both"></div> </div> %for element in metadata: - <div class="form-row"> - <label> - ${element.spec.desc}: - </label> - <div style="float: left; width: 250px; margin-right: 10px;"> - ${element.get_html()} + %if element.display: + <div class="form-row"> + <label> + ${element.spec.desc}: + </label> + <div style="float: left; width: 250px; margin-right: 10px;"> + ${element.get_html()} + </div> + <div style="clear: both"></div> </div> - <div style="clear: both"></div> - </div> + %endif %endfor <div class="form-row"> <input type="submit" name="save" value="Save"> diff -r dcaed9f80caf -r 21534250600b tools/visualization/GMAJ.xml --- a/tools/visualization/GMAJ.xml Thu Aug 28 13:57:23 2008 -0400 +++ b/tools/visualization/GMAJ.xml Thu Aug 28 15:12:53 2008 -0400 @@ -10,7 +10,6 @@ <filter type="data_meta" ref="maf_input" key="species" /> </options> </param> - <param name="chromosome" label="Chromosome" value="" type="text"/> <param name="exons_file" type="data" format="bed,gff" label="Exons File" optional="True"/> <param name="highlights_file" type="data" format="bed,gff" label="Highlights File" optional="True"/> <param name="underlays_file" type="data" format="bed,gff" label="Underlays File" optional="True"/> @@ -81,48 +80,53 @@ nowarn = $nowarn #end if -#for $seq_count, $annotation in $enumerate( $annotations ): +#set $seq_count = 0 +#for $spec_count, $annotation in $enumerate( $annotations ): +#if $annotation['species'].value in $maf_input.metadata.species_chromosomes and $maf_input.metadata.species_chromosomes[$annotation['species'].value]: +#set $seq_names = [ "%s.%s" % ( $annotation['species'].value, $chrom ) for $chrom in $maf_input.metadata.species_chromosomes[$annotation['species'].value]] +#else +#set $seq_names = [$annotation['species'].value] +#end if +#for $seq_name in $seq_names: seq ${seq_count}: -#if $annotation['chromosome'].value: -seqname = $annotation['species'].$annotation['chromosome'] -#else: -seqname = $annotation['species'] -#end if +seqname = $seq_name #if $annotation['exons_file'].dataset: -exons = ${seq_count}.exons.${annotation['exons_file'].extension} +exons = ${spec_count}.exons.${annotation['exons_file'].extension} #end if #if $annotation['repeats_file'].dataset: -repeats = ${seq_count}.repeats.${annotation['repeats_file'].extension} +repeats = ${spec_count}.repeats.${annotation['repeats_file'].extension} #end if #if $annotation['links_file'].dataset: -links = ${seq_count}.links.${annotation['links_file'].extension} +links = ${spec_count}.links.${annotation['links_file'].extension} #end if #if $annotation['underlays_file'].dataset: -underlays = ${seq_count}.underlays.${annotation['underlays_file'].extension} +underlays = ${spec_count}.underlays.${annotation['underlays_file'].extension} #end if #if $annotation['highlights_file'].dataset: -highlights = ${seq_count}.highlights.${annotation['highlights_file'].extension} +highlights = ${spec_count}.highlights.${annotation['highlights_file'].extension} #end if offset = $annotation['offset'] +#set $seq_count = $seq_count + 1 +#end for #end for </configfile> <configfile name="filenames_file"> -#for $seq_count, $annotation in $enumerate( $annotations ): +#for $spec_count, $annotation in $enumerate( $annotations ): #if $annotation['exons_file'].dataset: -$annotation['exons_file'] = ${seq_count}.exons.${annotation['exons_file'].extension} +$annotation['exons_file'] = ${spec_count}.exons.${annotation['exons_file'].extension} #end if #if $annotation['repeats_file'].dataset: -$annotation['repeats_file'] = ${seq_count}.repeats.${annotation['repeats_file'].extension} +$annotation['repeats_file'] = ${spec_count}.repeats.${annotation['repeats_file'].extension} #end if #if $annotation['links_file'].dataset: -$annotation['links_file'] = ${seq_count}.links.${annotation['links_file'].extension} +$annotation['links_file'] = ${spec_count}.links.${annotation['links_file'].extension} #end if #if $annotation['underlays_file'].dataset: -$annotation['underlays_file'] = ${seq_count}.underlays.${annotation['underlays_file'].extension} +$annotation['underlays_file'] = ${spec_count}.underlays.${annotation['underlays_file'].extension} #end if #if $annotation['highlights_file'].dataset: -$annotation['highlights_file'] = ${seq_count}.highlights.${annotation['highlights_file'].extension} +$annotation['highlights_file'] = ${spec_count}.highlights.${annotation['highlights_file'].extension} #end if #end for </configfile>
participants (1)
-
gregļ¼ scofield.bx.psu.edu