details: http://www.bx.psu.edu/hg/galaxy/rev/2a361ee9ce3e changeset: 1496:2a361ee9ce3e user: Dan Blankenberg dan@bx.psu.edu date: Mon Sep 08 11:15:58 2008 -0400 description: The interval to BED converter will now use the name field specified via metadata, if available.
2 file(s) affected in this change:
lib/galaxy/datatypes/converters/interval_to_bed_converter.py lib/galaxy/datatypes/converters/interval_to_bed_converter.xml
diffs (48 lines):
diff -r 49fe600b9499 -r 2a361ee9ce3e lib/galaxy/datatypes/converters/interval_to_bed_converter.py --- a/lib/galaxy/datatypes/converters/interval_to_bed_converter.py Mon Sep 08 09:47:37 2008 -0400 +++ b/lib/galaxy/datatypes/converters/interval_to_bed_converter.py Mon Sep 08 11:15:58 2008 -0400 @@ -31,18 +31,28 @@ strandCol = int( sys.argv[6] ) - 1 except: strandCol = -1 + try: + nameCol = int( sys.argv[7] ) - 1 + except: + nameCol = -1 skipped_lines = 0 first_skipped_line = 0 - count = 0 out = open( output_name,'w' ) - for region in bx.intervals.io.NiceReaderWrapper( open( input_name, 'r' ), chrom_col=chromCol, start_col=startCol, end_col=endCol, strand_col=strandCol, fix_strand=True, return_header=False, return_comments=False ): + for count, region in enumerate( bx.intervals.io.NiceReaderWrapper( open( input_name, 'r' ), chrom_col=chromCol, start_col=startCol, end_col=endCol, strand_col=strandCol, fix_strand=True, return_header=False, return_comments=False ) ): try: - out.write( region.chrom + "\t" + str( region.start ) + "\t" + str( region.end ) + "\tregion_" + str( count ) + "\t" + "0\t" + region.strand + "\n" ) + if nameCol >= 0: + name = region.fields[nameCol] + else: + raise IndexError + except: + name = "region_%i" % count + try: + + out.write( "%s\t%i\t%i\t%s\t%i\t%s\n" % ( region.chrom, region.start, region.end, name, 0, region.strand ) ) except: skipped_lines += 1 if not first_skipped_line: first_skipped_line = count + 1 - count += 1 out.close() info_msg = "%i regions converted to BED." % ( count - skipped_lines ) if skipped_lines > 0: diff -r 49fe600b9499 -r 2a361ee9ce3e lib/galaxy/datatypes/converters/interval_to_bed_converter.xml --- a/lib/galaxy/datatypes/converters/interval_to_bed_converter.xml Mon Sep 08 09:47:37 2008 -0400 +++ b/lib/galaxy/datatypes/converters/interval_to_bed_converter.xml Mon Sep 08 11:15:58 2008 -0400 @@ -1,7 +1,7 @@ <tool id="CONVERTER_interval_to_bed_0" name="Convert Genomic Intervals To BED"> <!-- <description>__NOT_USED_CURRENTLY_FOR_CONVERTERS__</description> --> <!-- Used on the metadata edit page. --> - <command interpreter="python">interval_to_bed_converter.py $output1 $input1 ${input1.metadata.chromCol} ${input1.metadata.startCol} ${input1.metadata.endCol} ${input1.metadata.strandCol}</command> + <command interpreter="python">interval_to_bed_converter.py $output1 $input1 ${input1.metadata.chromCol} ${input1.metadata.startCol} ${input1.metadata.endCol} ${input1.metadata.strandCol} ${input1.metadata.nameCol}</command> <inputs> <page> <param format="interval" name="input1" type="data" label="Choose intervals"/>
galaxy-dev@lists.galaxyproject.org