commit/galaxy-central: dan: Add Picard Interval List to BED6 converter.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/c6764f7a359c/ changeset: c6764f7a359c user: dan date: 2011-12-16 20:39:40 summary: Add Picard Interval List to BED6 converter. affected #: 3 files diff -r 11710de1b1fbf52ae3a9c860a7d36e76acf5e060 -r c6764f7a359cf26c81cfc14ff0e9e94e93b6c82a datatypes_conf.xml.sample --- a/datatypes_conf.xml.sample +++ b/datatypes_conf.xml.sample @@ -101,7 +101,9 @@ <display file="ensembl/ensembl_interval_as_bed.xml" inherit="True"/><display file="gbrowse/gbrowse_interval_as_bed.xml" inherit="True"/></datatype> - <datatype extension="picard_interval_list" type="galaxy.datatypes.data:Text" subclass="True" display_in_upload="True"/> + <datatype extension="picard_interval_list" type="galaxy.datatypes.tabular:Tabular" subclass="True" display_in_upload="True"> + <converter file="picard_interval_list_to_bed6_converter.xml" target_datatype="bed6"/> + </datatype><datatype extension="gatk_interval" type="galaxy.datatypes.data:Text" subclass="True" display_in_upload="True"/><datatype extension="gatk_dbsnp" type="galaxy.datatypes.tabular:Tabular" subclass="True" display_in_upload="True"/><datatype extension="gatk_tranche" type="galaxy.datatypes.tabular:Tabular" subclass="True" display_in_upload="True"/> diff -r 11710de1b1fbf52ae3a9c860a7d36e76acf5e060 -r c6764f7a359cf26c81cfc14ff0e9e94e93b6c82a lib/galaxy/datatypes/converters/picard_interval_list_to_bed6_converter.py --- /dev/null +++ b/lib/galaxy/datatypes/converters/picard_interval_list_to_bed6_converter.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python +#Dan Blankenberg + +import sys + +assert sys.version_info[:2] >= ( 2, 5 ) +HEADER_STARTS_WITH = ( '@' ) + +def __main__(): + input_name = sys.argv[1] + output_name = sys.argv[2] + skipped_lines = 0 + first_skipped_line = 0 + header_lines = 0 + out = open( output_name, 'w' ) + i = 0 + for i, line in enumerate( open( input_name ) ): + complete_interval = False + line = line.rstrip( '\r\n' ) + if line: + if line.startswith( HEADER_STARTS_WITH ): + header_lines += 1 + else: + try: + elems = line.split( '\t' ) + if len( elems ) >= 5: + complete_interval = True + out.write( '%s\t%s\t%s\t%s\t0\t%s\n' % ( elems[0], int(elems[1])-1, elems[2], elems[4], elems[3] ) ) + except Exception, e: + print e + skipped_lines += 1 + if not first_skipped_line: + first_skipped_line = i + 1 + else: + skipped_lines += 1 + if not first_skipped_line: + first_skipped_line = i + 1 + out.close() + info_msg = "%i lines converted to BED. " % ( i + 1 - skipped_lines ) + if skipped_lines > 0: + info_msg += "Skipped %d blank/comment/invalid lines starting with line #%d." % ( skipped_lines, first_skipped_line ) + print info_msg + +if __name__ == "__main__": __main__() diff -r 11710de1b1fbf52ae3a9c860a7d36e76acf5e060 -r c6764f7a359cf26c81cfc14ff0e9e94e93b6c82a lib/galaxy/datatypes/converters/picard_interval_list_to_bed6_converter.xml --- /dev/null +++ b/lib/galaxy/datatypes/converters/picard_interval_list_to_bed6_converter.xml @@ -0,0 +1,12 @@ +<tool id="CONVERTER_picard_interval_list_to_bed6" name="Convert Picard Interval List to BED6" version="1.0.0"> + <description>converter</description> + <command interpreter="python">picard_interval_list_to_bed6_converter.py "$input" "$output"</command> + <inputs> + <param name="input" type="data" format="picard_interval_list" label="Picard Interval List file"/> + </inputs> + <outputs> + <data name="output" format="bed6"/> + </outputs> + <help> + </help> +</tool> 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