1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/ac77414506d4/ changeset: ac77414506d4 user: jgoecks date: 2012-02-22 21:23:44 summary: Enable interval files to be converted to tabix. affected #: 13 files diff -r 20e573ed9f8248f659e3e40b862f475bd548ba47 -r ac77414506d4fb46197cb6db6f86707cfa78d21e datatypes_conf.xml.sample --- a/datatypes_conf.xml.sample +++ b/datatypes_conf.xml.sample @@ -89,7 +89,8 @@ <converter file="interval_to_bedstrict_converter.xml" target_datatype="bedstrict"/><converter file="interval_to_bed6_converter.xml" target_datatype="bed6"/><converter file="interval_to_bed12_converter.xml" target_datatype="bed12"/> - <converter file="interval_to_interval_index_converter.xml" target_datatype="interval_index"/> + <converter file="interval_to_bgzip_converter.xml" target_datatype="bgzip"/> + <converter file="interval_to_tabix_converter.xml" target_datatype="tabix" depends_on="bgzip"/><converter file="interval_to_summary_tree_converter.xml" target_datatype="summary_tree"/><!-- <display file="ucsc/interval_as_bed.xml" inherit="True" /> --><display file="genetrack.xml" inherit="True"/> diff -r 20e573ed9f8248f659e3e40b862f475bd548ba47 -r ac77414506d4fb46197cb6db6f86707cfa78d21e lib/galaxy/datatypes/converters/bed_to_bgzip_converter.xml --- a/lib/galaxy/datatypes/converters/bed_to_bgzip_converter.xml +++ b/lib/galaxy/datatypes/converters/bed_to_bgzip_converter.xml @@ -1,6 +1,6 @@ <tool id="CONVERTER_bed_to_bgzip_0" name="Convert BED to BGZIP" version="1.0.0" hidden="true"><!-- <description>__NOT_USED_CURRENTLY_FOR_CONVERTERS__</description> --> - <command interpreter="python">bgzip.py bed $input1 $output1</command> + <command interpreter="python">bgzip.py -P bed $input1 $output1</command><inputs><page><param format="bed" name="input1" type="data" label="Choose BED file"/> diff -r 20e573ed9f8248f659e3e40b862f475bd548ba47 -r ac77414506d4fb46197cb6db6f86707cfa78d21e lib/galaxy/datatypes/converters/bed_to_tabix_converter.xml --- a/lib/galaxy/datatypes/converters/bed_to_tabix_converter.xml +++ b/lib/galaxy/datatypes/converters/bed_to_tabix_converter.xml @@ -1,6 +1,6 @@ <tool id="CONVERTER_bed_to_tabix_0" name="Convert BED to tabix" version="1.0.0" hidden="true"><!-- <description>__NOT_USED_CURRENTLY_FOR_CONVERTERS__</description> --> - <command interpreter="python">interval_to_tabix_converter.py bed $input1 $bgzip $output1</command> + <command interpreter="python">interval_to_tabix_converter.py -P bed $input1 $bgzip $output1</command><inputs><page><param format="bed" name="input1" type="data" label="Choose BED file"/> diff -r 20e573ed9f8248f659e3e40b862f475bd548ba47 -r ac77414506d4fb46197cb6db6f86707cfa78d21e lib/galaxy/datatypes/converters/bgzip.py --- a/lib/galaxy/datatypes/converters/bgzip.py +++ b/lib/galaxy/datatypes/converters/bgzip.py @@ -8,19 +8,32 @@ from galaxy import eggs import pkg_resources; pkg_resources.require( "pysam" ) -import ctabix, subprocess, tempfile, sys +import ctabix, subprocess, tempfile, sys, optparse def main(): - filetype, input_fname, out_fname = sys.argv[1:] + # Read options, args. + parser = optparse.OptionParser() + parser.add_option( '-c', '--chr-col', type='int', dest='chrom_col' ) + parser.add_option( '-s', '--start-col', type='int', dest='start_col' ) + parser.add_option( '-e', '--end-col', type='int', dest='end_col' ) + parser.add_option( '-P', '--preset', dest='preset' ) + (options, args) = parser.parse_args() + input_fname, output_fname = args tmpfile = tempfile.NamedTemporaryFile() sort_params = None - if filetype == "bed": + if options.chrom_col and options.start_col and options.end_col: + sort_params = ["sort", + "-k%(i)s,%(i)s" % { 'i': options.chrom_col }, + "-k%(i)i,%(i)sn" % { 'i': options.start_col }, + "-k%(i)i,%(i)sn" % { 'i': options.end_col } + ] + elif options.preset == "bed": sort_params = ["sort", "-k1,1", "-k2,2n", "-k3,3n"] - elif filetype == "vcf": + elif options.preset == "vcf": sort_params = ["sort", "-k1,1", "-k2,2n"] - elif filetype == "gff": + elif options.preset == "gff": sort_params = ["sort", "-s", "-k1,1", "-k4,4n"] # stable sort on start column # Skip any lines starting with "#" and "track" grepped = subprocess.Popen(["grep", "-e", "^\"#\"", "-e", "^track", "-v", input_fname], stderr=subprocess.PIPE, stdout=subprocess.PIPE ) @@ -28,7 +41,7 @@ grepped.stdout.close() output, err = after_sort.communicate() - ctabix.tabix_compress(tmpfile.name, out_fname, force=True) + ctabix.tabix_compress(tmpfile.name, output_fname, force=True) if __name__ == "__main__": main() diff -r 20e573ed9f8248f659e3e40b862f475bd548ba47 -r ac77414506d4fb46197cb6db6f86707cfa78d21e lib/galaxy/datatypes/converters/gff_to_bgzip_converter.xml --- a/lib/galaxy/datatypes/converters/gff_to_bgzip_converter.xml +++ b/lib/galaxy/datatypes/converters/gff_to_bgzip_converter.xml @@ -1,6 +1,6 @@ <tool id="CONVERTER_gff_to_bgzip_0" name="Convert GFF to BGZIP" version="1.0.0" hidden="true"><!-- <description>__NOT_USED_CURRENTLY_FOR_CONVERTERS__</description> --> - <command interpreter="python">bgzip.py gff $input1 $output1</command> + <command interpreter="python">bgzip.py -P gff $input1 $output1</command><inputs><page><param format="gff" name="input1" type="data" label="Choose GFF file"/> diff -r 20e573ed9f8248f659e3e40b862f475bd548ba47 -r ac77414506d4fb46197cb6db6f86707cfa78d21e lib/galaxy/datatypes/converters/gff_to_tabix_converter.xml --- a/lib/galaxy/datatypes/converters/gff_to_tabix_converter.xml +++ b/lib/galaxy/datatypes/converters/gff_to_tabix_converter.xml @@ -1,6 +1,6 @@ <tool id="CONVERTER_gff_to_tabix_0" name="Convert GFF to tabix" version="1.0.0" hidden="true"><!-- <description>__NOT_USED_CURRENTLY_FOR_CONVERTERS__</description> --> - <command interpreter="python">interval_to_tabix_converter.py gff $input1 $bgzip $output1</command> + <command interpreter="python">interval_to_tabix_converter.py -P gff $input1 $bgzip $output1</command><inputs><page><param format="gff" name="input1" type="data" label="Choose GFF file"/> diff -r 20e573ed9f8248f659e3e40b862f475bd548ba47 -r ac77414506d4fb46197cb6db6f86707cfa78d21e lib/galaxy/datatypes/converters/interval_to_bgzip_converter.xml --- /dev/null +++ b/lib/galaxy/datatypes/converters/interval_to_bgzip_converter.xml @@ -0,0 +1,19 @@ +<tool id="CONVERTER_interval_to_bgzip_0" name="Convert Interval to BGZIP" version="1.0.0" hidden="true"> +<!-- <description>__NOT_USED_CURRENTLY_FOR_CONVERTERS__</description> --> + <command interpreter="python">bgzip.py + -c ${input1.metadata.chromCol} + -s ${input1.metadata.startCol} + -e ${input1.metadata.endCol} + $input1 $output1 + </command> + <inputs> + <page> + <param format="interval" name="input1" type="data" label="Choose Interval file"/> + </page> + </inputs> + <outputs> + <data format="bgzip" name="output1"/> + </outputs> + <help> + </help> +</tool> diff -r 20e573ed9f8248f659e3e40b862f475bd548ba47 -r ac77414506d4fb46197cb6db6f86707cfa78d21e lib/galaxy/datatypes/converters/interval_to_tabix_converter.py --- a/lib/galaxy/datatypes/converters/interval_to_tabix_converter.py +++ b/lib/galaxy/datatypes/converters/interval_to_tabix_converter.py @@ -9,13 +9,28 @@ from galaxy import eggs import pkg_resources; pkg_resources.require( "pysam" ) -import ctabix, subprocess, tempfile, sys, os +import ctabix, subprocess, tempfile, sys, os, optparse def main(): # Read options, args. - filetype, input_fname, index_fname, out_fname = sys.argv[1:] + parser = optparse.OptionParser() + parser.add_option( '-c', '--chr-col', type='int', dest='chrom_col' ) + parser.add_option( '-s', '--start-col', type='int', dest='start_col' ) + parser.add_option( '-e', '--end-col', type='int', dest='end_col' ) + parser.add_option( '-P', '--preset', dest='preset' ) + (options, args) = parser.parse_args() + input_fname, index_fname, out_fname = args - ctabix.tabix_index(filename=index_fname, preset=filetype, keep_original=True, already_compressed=True, index_filename=out_fname) + # Create index. + if options.preset: + # Preset type. + ctabix.tabix_index(filename=index_fname, preset=options.preset, keep_original=True, + already_compressed=True, index_filename=out_fname) + else: + # For interval files. + ctabix.tabix_index(filename=index_fname, seq_col=options.chrom_col, + start_col=options.start_col, end_col=options.end_col, + keep_original=True, already_compressed=True, index_filename=out_fname) if os.path.getsize(index_fname) == 0: sys.stderr.write("The converted tabix index file is empty, meaning the input data is invalid.") diff -r 20e573ed9f8248f659e3e40b862f475bd548ba47 -r ac77414506d4fb46197cb6db6f86707cfa78d21e lib/galaxy/datatypes/converters/interval_to_tabix_converter.xml --- /dev/null +++ b/lib/galaxy/datatypes/converters/interval_to_tabix_converter.xml @@ -0,0 +1,20 @@ +<tool id="CONVERTER_interval_to_tabix_0" name="Convert Interval to tabix" version="1.0.0" hidden="true"> +<!-- <description>__NOT_USED_CURRENTLY_FOR_CONVERTERS__</description> --> + <command interpreter="python">interval_to_tabix_converter.py + -c ${input1.metadata.chromCol} + -s ${input1.metadata.startCol} + -e ${input1.metadata.endCol} + $input1 $bgzip $output1 + </command> + <inputs> + <page> + <param format="interval" name="input1" type="data" label="Choose Interval file"/> + <param format="bgzip" name="bgzip" type="data" label="BGZIP file"/> + </page> + </inputs> + <outputs> + <data format="tabix" name="output1"/> + </outputs> + <help> + </help> +</tool> diff -r 20e573ed9f8248f659e3e40b862f475bd548ba47 -r ac77414506d4fb46197cb6db6f86707cfa78d21e lib/galaxy/datatypes/converters/vcf_bgzip_to_tabix_converter.xml --- a/lib/galaxy/datatypes/converters/vcf_bgzip_to_tabix_converter.xml +++ b/lib/galaxy/datatypes/converters/vcf_bgzip_to_tabix_converter.xml @@ -1,6 +1,6 @@ <tool id="CONVERTER_vcf_bgzip_to_tabix_0" name="Convert BGZ VCF to tabix" version="1.0.0" hidden="true"><!-- <description>__NOT_USED_CURRENTLY_FOR_CONVERTERS__</description> --> - <command interpreter="python">interval_to_tabix_converter.py 'vcf' '' '$input1' '$output1'</command> + <command interpreter="python">interval_to_tabix_converter.py -P 'vcf' '$input1' '$output1'</command><inputs><page><param format="vcf_bgzip" name="input1" type="data" label="Choose BGZIP'd VCF file"/> diff -r 20e573ed9f8248f659e3e40b862f475bd548ba47 -r ac77414506d4fb46197cb6db6f86707cfa78d21e lib/galaxy/datatypes/converters/vcf_to_bgzip_converter.xml --- a/lib/galaxy/datatypes/converters/vcf_to_bgzip_converter.xml +++ b/lib/galaxy/datatypes/converters/vcf_to_bgzip_converter.xml @@ -1,6 +1,6 @@ <tool id="CONVERTER_vcf_to_bgzip_0" name="Convert VCF to BGZIP" version="1.0.0" hidden="true"><!-- <description>__NOT_USED_CURRENTLY_FOR_CONVERTERS__</description> --> - <command interpreter="python">bgzip.py vcf $input1 $output1</command> + <command interpreter="python">bgzip.py -P vcf $input1 $output1</command><inputs><page><param format="vcf" name="input1" type="data" label="Choose Vcf file"/> diff -r 20e573ed9f8248f659e3e40b862f475bd548ba47 -r ac77414506d4fb46197cb6db6f86707cfa78d21e lib/galaxy/datatypes/converters/vcf_to_tabix_converter.xml --- a/lib/galaxy/datatypes/converters/vcf_to_tabix_converter.xml +++ b/lib/galaxy/datatypes/converters/vcf_to_tabix_converter.xml @@ -1,6 +1,6 @@ <tool id="CONVERTER_vcf_to_tabix_0" name="Convert Vcf to tabix" version="1.0.0" hidden="true"><!-- <description>__NOT_USED_CURRENTLY_FOR_CONVERTERS__</description> --> - <command interpreter="python">interval_to_tabix_converter.py vcf $input1 $bgzip $output1</command> + <command interpreter="python">interval_to_tabix_converter.py -P vcf $input1 $bgzip $output1</command><inputs><page><param format="vcf" name="input1" type="data" label="Choose Vcf file"/> diff -r 20e573ed9f8248f659e3e40b862f475bd548ba47 -r ac77414506d4fb46197cb6db6f86707cfa78d21e lib/galaxy/datatypes/converters/vcf_to_vcf_bgzip_converter.xml --- a/lib/galaxy/datatypes/converters/vcf_to_vcf_bgzip_converter.xml +++ b/lib/galaxy/datatypes/converters/vcf_to_vcf_bgzip_converter.xml @@ -1,6 +1,6 @@ <tool id="CONVERTER_vcf_to_vcf_bgzip_0" name="Convert VCF to VCF_BGZIP" version="1.0.0" hidden="true"><!-- <description>__NOT_USED_CURRENTLY_FOR_CONVERTERS__</description> --> - <command interpreter="python">bgzip.py vcf $input1 $output1</command> + <command interpreter="python">bgzip.py -P vcf $input1 $output1</command><inputs><page><param format="vcf" name="input1" type="data" label="Choose Vcf 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.