commit/galaxy-central: jgoecks: GFF/GTF reading and visualization enhancements: (a) enable GFF to FLI conversion and (b) better feature aggregation.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/fa045aad74e9/ changeset: fa045aad74e9 user: jgoecks date: 2012-10-29 15:44:32 summary: GFF/GTF reading and visualization enhancements: (a) enable GFF to FLI conversion and (b) better feature aggregation. affected #: 4 files diff -r ecd131b136d00d5753992061d12b12156be8b277 -r fa045aad74e90f16995e0cbb670a59e6b9becbed lib/galaxy/datatypes/converters/bed_to_fli_converter.xml --- a/lib/galaxy/datatypes/converters/bed_to_fli_converter.xml +++ b/lib/galaxy/datatypes/converters/bed_to_fli_converter.xml @@ -1,7 +1,7 @@ <tool id="CONVERTER_bed_to_fli_0" name="Convert BED to Feature Location Index"><!-- <description>__NOT_USED_CURRENTLY_FOR_CONVERTERS__</description> --><!-- Used on the metadata edit page. --> - <command interpreter="python">interval_to_fli.py -B $input1 $output1</command> + <command interpreter="python">interval_to_fli.py -F bed $input1 $output1</command><inputs><param format="bed" name="input1" type="data" label="Choose BED file"/></inputs> diff -r ecd131b136d00d5753992061d12b12156be8b277 -r fa045aad74e90f16995e0cbb670a59e6b9becbed lib/galaxy/datatypes/converters/gff_to_fli_converter.xml --- a/lib/galaxy/datatypes/converters/gff_to_fli_converter.xml +++ b/lib/galaxy/datatypes/converters/gff_to_fli_converter.xml @@ -1,7 +1,7 @@ <tool id="CONVERTER_gff_to_fli_0" name="Convert GFF to Feature Location Index"><!-- <description>__NOT_USED_CURRENTLY_FOR_CONVERTERS__</description> --><!-- Used on the metadata edit page. --> - <command interpreter="python">interval_to_fli.py -G $input1 $output1</command> + <command interpreter="python">interval_to_fli.py -F $input1.extension $input1 $output1</command><inputs><param format="gff" name="input1" type="data" label="Choose GFF file"/></inputs> diff -r ecd131b136d00d5753992061d12b12156be8b277 -r fa045aad74e90f16995e0cbb670a59e6b9becbed lib/galaxy/datatypes/converters/interval_to_fli.py --- a/lib/galaxy/datatypes/converters/interval_to_fli.py +++ b/lib/galaxy/datatypes/converters/interval_to_fli.py @@ -12,22 +12,28 @@ import sys, optparse from galaxy import eggs -from galaxy.datatypes.util.gff_util import read_unordered_gtf, convert_gff_coords_to_bed +from galaxy.datatypes.util.gff_util import GFFReaderWrapper, read_unordered_gtf, convert_gff_coords_to_bed def main(): # Process arguments. parser = optparse.OptionParser() - parser.add_option( '-B', '--bed', action="store_true", dest="bed_input" ) - parser.add_option( '-G', '--gff', action="store_true", dest="gff_input" ) + parser.add_option( '-F', '--format', dest="input_format" ) (options, args) = parser.parse_args() in_fname, out_fname = args - + input_format = options.input_format.lower() # Create dict of name-location pairings. name_loc_dict = {} - if options.gff_input: - # GFF format - for feature in read_unordered_gtf( open( in_fname, 'r' ) ): + if input_format in [ 'gff', 'gtf' ]: + # GTF/GFF format + + # Create reader. + if input_format == 'gff': + in_reader = GFFReaderWrapper( open( in_fname, 'r' ) ) + else: #input_format == 'gtf' + in_reader = read_unordered_gtf( open( in_fname, 'r' ) ) + + for feature in in_reader: for name in feature.attributes: val = feature.attributes[ name ] try: @@ -50,7 +56,7 @@ loc[ 'start' ] = feature.start if feature.end > loc[ 'end' ]: loc[ 'end' ] = feature.end - else: + elif input_format == 'bed': # BED format. for line in open( in_fname, 'r' ): # Ignore track lines. diff -r ecd131b136d00d5753992061d12b12156be8b277 -r fa045aad74e90f16995e0cbb670a59e6b9becbed lib/galaxy/datatypes/util/gff_util.py --- a/lib/galaxy/datatypes/util/gff_util.py +++ b/lib/galaxy/datatypes/util/gff_util.py @@ -227,22 +227,20 @@ continue # Determine if interval is part of feature. - part_of = True + part_of = False group = interval.attributes.get( 'group', None ) # GFF test: - if group and feature_group != group: - part_of = False + if group and feature_group == group: + part_of = True # GFF3 test: parent_id = interval.attributes.get( 'Parent', None ) cur_id = interval.attributes.get( 'ID', None ) - if ( cur_id and cur_id != feature_id ) or ( parent_id and parent_id != feature_id ): - part_of = False + if ( cur_id and cur_id == feature_id ) or ( parent_id and parent_id == feature_id ): + part_of = True # GTF test: - gene_id = interval.attributes.get( 'gene_id', None ) transcript_id = interval.attributes.get( 'transcript_id', None ) - if ( transcript_id and transcript_id != feature_transcript_id ) or \ - ( gene_id and gene_id != feature_gene_id ): - part_of = False + if transcript_id and transcript_id == feature_transcript_id: + part_of = True # If interval is not part of feature, clean up and break. if not part_of: 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.
participants (1)
-
Bitbucket