diff --git a/datatypes_conf.xml.sample b/datatypes_conf.xml.sample index 099addfa73a..7d27266dc53 100644 --- a/datatypes_conf.xml.sample +++ b/datatypes_conf.xml.sample @@ -169,7 +169,6 @@ - @@ -246,7 +245,6 @@ - diff --git a/lib/galaxy/datatypes/converters/bedgraph_to_bigwig_converter.xml b/lib/galaxy/datatypes/converters/bedgraph_to_bigwig_converter.xml new file mode 100644 index 00000000000..77d2c2a42e6 --- /dev/null +++ b/lib/galaxy/datatypes/converters/bedgraph_to_bigwig_converter.xml @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/lib/galaxy/datatypes/converters/gff_to_fli.py b/lib/galaxy/datatypes/converters/gff_to_fli.py index cfa056e573f..ef38576a5a3 100644 --- a/lib/galaxy/datatypes/converters/gff_to_fli.py +++ b/lib/galaxy/datatypes/converters/gff_to_fli.py @@ -6,48 +6,52 @@ import sys 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 diff --git a/lib/galaxy/datatypes/converters/interval_to_interval_index_converter.py.orig b/lib/galaxy/datatypes/converters/interval_to_interval_index_converter.py.orig deleted file mode 100644 index 15d84bd4141..00000000000 --- a/lib/galaxy/datatypes/converters/interval_to_interval_index_converter.py.orig +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env python - -""" -Convert from interval file to interval index file. Default input file format is BED (0-based, half-open intervals). - -usage: %prog in_file out_file - -G, --gff: input is GFF format, meaning start and end coordinates are 1-based, closed interval -""" - -from __future__ import division - -import sys, fileinput -from galaxy import eggs -import pkg_resources; pkg_resources.require( "bx-python" ) -from galaxy.visualization.tracks.summary import * -from bx.cookbook import doc_optparse -from galaxy.tools.util.gff_util import convert_gff_coords_to_bed -from bx.interval_index_file import Indexes -from galaxy.tools.util.gff_util import parse_gff_attributes - -def main(): - - # Read options, args. - options, args = doc_optparse.parse( __doc__ ) - try: - gff_format = bool( options.gff ) - input_fname, out_fname = args - except: - doc_optparse.exception() - - # Do conversion. - # TODO: take column numbers from command line. - if gff_format: - chr_col, start_col, end_col = ( 0, 3, 4 ) - else: - chr_col, start_col, end_col = ( 0, 1, 2 ) - index = Indexes() - offset = 0 - # Need to keep track of last gene, transcript id for indexing GTF files. - last_gene_id = None - last_transcript_id = None - for line in open(input_fname, "r"): - feature = line.strip().split('\t') - if not feature or feature[0].startswith("track") or feature[0].startswith("#"): - offset += len(line) - continue - chrom = feature[ chr_col ] - chrom_start = int( feature[ start_col ] ) - chrom_end = int( feature[ end_col ] ) - if gff_format: - chrom_start, chrom_end = convert_gff_coords_to_bed( [chrom_start, chrom_end ] ) - - # Only add feature if gene_id, transcript_id are different from last - # values. - if len( feature ) == 9: - attributes = parse_gff_attributes( feature[8] ) - gene_id = attributes.get( 'gene_id', None ) - transcript_id = attributes.get( 'transcript_id', None ) - if gene_id and transcript_id and gene_id == last_gene_id and \ - transcript_id == last_transcript_id: - # Feature has same gene_id, transcript as last feature, so - # do not add. - offset += len(line) - continue - else: - # gene_id, transcript_id set and are different from last - # values. - last_gene_id = gene_id - last_transcript_id = transcript_id - - #print "%s %s %s %s %i %i %i" % (feature[2], last_gene_id, last_transcript_id, chrom, chrom_start, chrom_end, offset) - index.add( chrom, chrom_start, chrom_end, offset ) - offset += len(line) - - index.write( open(out_fname, "w") ) - -if __name__ == "__main__": - main() - \ No newline at end of file diff --git a/lib/galaxy/datatypes/converters/wig_to_bigwig_converter.xml b/lib/galaxy/datatypes/converters/wig_to_bigwig_converter.xml index e85c3a7b138..d90702efe78 100644 --- a/lib/galaxy/datatypes/converters/wig_to_bigwig_converter.xml +++ b/lib/galaxy/datatypes/converters/wig_to_bigwig_converter.xml @@ -1,6 +1,6 @@