1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/c2f41b36be5f/ changeset: c2f41b36be5f user: carlfeberhard date: 2012-08-20 19:50:12 summary: fix to gff_to_fli.py to avoid breaking unittests affected #: 1 file diff -r 0b58ac6510c5df73ffb1634f874c5283e3d2d068 -r c2f41b36be5f3df122abc57162e0d7e134e1cfbf lib/galaxy/datatypes/converters/gff_to_fli.py --- a/lib/galaxy/datatypes/converters/gff_to_fli.py +++ b/lib/galaxy/datatypes/converters/gff_to_fli.py @@ -6,48 +6,52 @@ from galaxy import eggs from galaxy.datatypes.util.gff_util import read_unordered_gtf, convert_gff_coords_to_bed -# Process arguments. -in_fname = sys.argv[1] -out_fname = sys.argv[2] +def main(): + # Process arguments. + in_fname = sys.argv[1] + out_fname = sys.argv[2] + + # Create dict of name-location pairings. + name_loc_dict = {} + for feature in read_unordered_gtf( open( in_fname, 'r' ) ): + for name in feature.attributes: + val = feature.attributes[ name ] + try: + float( val ) + continue + except: + convert_gff_coords_to_bed( feature ) + # Value is not a number, so it can be indexed. + if val not in name_loc_dict: + # Value is not in dictionary. + name_loc_dict[ val ] = { + 'contig': feature.chrom, + 'start': feature.start, + 'end': feature.end + } + else: + # Value already in dictionary, so update dictionary. + loc = name_loc_dict[ val ] + if feature.start < loc[ 'start' ]: + loc[ 'start' ] = feature.start + if feature.end > loc[ 'end' ]: + loc[ 'end' ] = feature.end + + # Print name, loc in sorted order. + out = open( out_fname, 'w' ) + max_len = 0 + entries = [] + for name in sorted( name_loc_dict.iterkeys() ): + loc = name_loc_dict[ name ] + entry = '%s\t%s' % ( name, '%s:%i-%i' % ( loc[ 'contig' ], loc[ 'start' ], loc[ 'end' ] ) ) + if len( entry ) > max_len: + max_len = len( entry ) + entries.append( entry ) + + out.write( str( max_len + 1 ).ljust( max_len ) + '\n' ) + for entry in entries: + out.write( entry.ljust( max_len ) + '\n' ) + out.close() -# Create dict of name-location pairings. -name_loc_dict = {} -for feature in read_unordered_gtf( open( in_fname, 'r' ) ): - for name in feature.attributes: - val = feature.attributes[ name ] - try: - float( val ) - continue - except: - convert_gff_coords_to_bed( feature ) - # Value is not a number, so it can be indexed. - if val not in name_loc_dict: - # Value is not in dictionary. - name_loc_dict[ val ] = { - 'contig': feature.chrom, - 'start': feature.start, - 'end': feature.end - } - else: - # Value already in dictionary, so update dictionary. - loc = name_loc_dict[ val ] - if feature.start < loc[ 'start' ]: - loc[ 'start' ] = feature.start - if feature.end > loc[ 'end' ]: - loc[ 'end' ] = feature.end - -# Print name, loc in sorted order. -out = open( out_fname, 'w' ) -max_len = 0 -entries = [] -for name in sorted( name_loc_dict.iterkeys() ): - loc = name_loc_dict[ name ] - entry = '%s\t%s' % ( name, '%s:%i-%i' % ( loc[ 'contig' ], loc[ 'start' ], loc[ 'end' ] ) ) - if len( entry ) > max_len: - max_len = len( entry ) - entries.append( entry ) - -out.write( str( max_len + 1 ).ljust( max_len ) + '\n' ) -for entry in entries: - out.write( entry.ljust( max_len ) + '\n' ) -out.close() \ No newline at end of file +if __name__ == '__main__': + main() \ No newline at end of file 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.