mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
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.
This commit is contained in:
@@ -66,6 +66,7 @@ class MetadataParameter( object ):
|
||||
value = str( value )
|
||||
self.value = value
|
||||
self.context = context
|
||||
self.display = True
|
||||
|
||||
def __str__(self):
|
||||
if self.value is None:
|
||||
@@ -264,4 +265,24 @@ class ColumnTypesParameter( MetadataParameter ):
|
||||
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
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ class Alignment( Sequence ):
|
||||
|
||||
"""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 @@ class Maf( Alignment ):
|
||||
|
||||
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 @@ class Maf( Alignment ):
|
||||
# "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"""
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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 @@ tabext = .bed .gff .gtf
|
||||
nowarn = $nowarn
|
||||
#end if
|
||||
|
||||
#for $seq_count, $annotation in $enumerate( $annotations ):
|
||||
seq ${seq_count}:
|
||||
#if $annotation['chromosome'].value:
|
||||
seqname = $annotation['species'].$annotation['chromosome']
|
||||
#else:
|
||||
seqname = $annotation['species']
|
||||
#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}:
|
||||
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>
|
||||
|
||||
Reference in New Issue
Block a user