# HG changeset patch # User peterjc # Date 1494941058 14400 # Node ID 71afa65f444acc44b3974ba36b358b4d3cfb5e36 # Parent 8945bad80f4af0f5f7711666c7651e2b69147274 v0.0.5 Internal changes to command line handling diff -r 8945bad80f4a -r 71afa65f444a tools/samtools_idxstats/README.rst --- a/tools/samtools_idxstats/README.rst Wed May 13 10:35:50 2015 -0400 +++ b/tools/samtools_idxstats/README.rst Tue May 16 09:24:18 2017 -0400 @@ -54,6 +54,8 @@ v0.0.3 - Embed samtools citation in tool XML. v0.0.4 - Reorder XML elements (internal change only). - Planemo for Tool Shed upload (``.shed.yml``, internal change only). +v0.0.5 - Use ```` (internal change only). + - Single quote command line arguments (internal change only). ======= ====================================================================== @@ -68,17 +70,17 @@ Planemo commands (which requires you have set your Tool Shed access details in ``~/.planemo.yml`` and that you have access rights on the Tool Shed):: - $ planemo shed_upload --shed_target testtoolshed --check_diff ~/repositories/pico_galaxy/tools/samtools_idxstats/ + $ planemo shed_update -t testtoolshed --check_diff tools/samtools_idxstats/ ... or:: - $ planemo shed_upload --shed_target toolshed --check_diff ~/repositories/pico_galaxy/tools/samtools_idxstats/ + $ planemo shed_update -t toolshed --check_diff tools/samtools_idxstats/ ... To just build and check the tar ball, use:: - $ planemo shed_upload --tar_only ~/repositories/pico_galaxy/tools/samtools_idxstats/ + $ planemo shed_upload --tar_only tools/samtools_idxstats/ ... $ tar -tzf shed_upload.tar.gz test-data/ex1.bam diff -r 8945bad80f4a -r 71afa65f444a tools/samtools_idxstats/samtools_idxstats.py --- a/tools/samtools_idxstats/samtools_idxstats.py Wed May 13 10:35:50 2015 -0400 +++ b/tools/samtools_idxstats/samtools_idxstats.py Tue May 16 09:24:18 2017 -0400 @@ -10,35 +10,30 @@ runs "samtools idxstats" and captures the output to the desired tabular file. """ -import sys + import os -import subprocess +import sys import tempfile if "-v" in sys.argv or "--version" in sys.argv: - #Galaxy seems to invert the order of the two lines + # Galaxy seems to invert the order of the two lines print "(Galaxy wrapper v0.0.2)" cmd = "samtools 2>&1 | grep -i ^Version" sys.exit(os.system(cmd)) -def sys_exit(msg, error_level=1): - """Print error message to stdout and quit with given error level.""" - sys.stderr.write("%s\n" % msg) - sys.exit(error_level) - if len(sys.argv) != 4: - sys_exit("Require three arguments: BAM, BAI, tabular filenames") + sys.exit("Require three arguments: BAM, BAI, tabular filenames") bam_filename, bai_filename, tabular_filename = sys.argv[1:] if not os.path.isfile(bam_filename): - sys_exit("Input BAM file not found: %s" % bam_filename) + sys.exit("Input BAM file not found: %s" % bam_filename) if not os.path.isfile(bai_filename): if bai_filename == "None": - sys_exit("Error: Galaxy did not index your BAM file") - sys_exit("Input BAI file not found: %s" % bai_filename) + sys.exit("Error: Galaxy did not index your BAM file") + sys.exit("Input BAI file not found: %s" % bai_filename) -#Assign sensible names with real extensions, and setup symlinks: +# Assign sensible names with real extensions, and setup symlinks: tmp_dir = tempfile.mkdtemp() bam_file = os.path.join(tmp_dir, "temp.bam") bai_file = os.path.join(tmp_dir, "temp.bam.bai") @@ -48,14 +43,14 @@ assert os.path.isfile(bai_file), bai_file assert os.path.isfile(bam_file + ".bai"), bam_file -#Run samtools idxstats: +# Run samtools idxstats: cmd = 'samtools idxstats "%s" > "%s"' % (bam_file, tabular_filename) return_code = os.system(cmd) -#Remove the temp symlinks: +# Remove the temp symlinks: os.remove(bam_file) os.remove(bai_file) os.rmdir(tmp_dir) if return_code: - sys_exit("Return code %i from command:\n%s" % (return_code, cmd)) + sys.exit("Return code %i from command:\n%s" % (return_code, cmd)) diff -r 8945bad80f4a -r 71afa65f444a tools/samtools_idxstats/samtools_idxstats.xml --- a/tools/samtools_idxstats/samtools_idxstats.xml Wed May 13 10:35:50 2015 -0400 +++ b/tools/samtools_idxstats/samtools_idxstats.xml Tue May 16 09:24:18 2017 -0400 @@ -1,16 +1,14 @@ - + samtools idxstats - samtools samtools - - - - - - samtools_idxstats.py --version - samtools_idxstats.py "$input_bam" "${input_bam.metadata.bam_index}" "$out_tabular" + +python $__tool_directory__/samtools_idxstats.py --version + + +python $__tool_directory__/samtools_idxstats.py '$input_bam' '${input_bam.metadata.bam_index}' '$out_tabular' + diff -r 8945bad80f4a -r 71afa65f444a tools/samtools_idxstats/tool_dependencies.xml --- a/tools/samtools_idxstats/tool_dependencies.xml Wed May 13 10:35:50 2015 -0400 +++ b/tools/samtools_idxstats/tool_dependencies.xml Tue May 16 09:24:18 2017 -0400 @@ -1,6 +1,6 @@ - +