Previous changeset 5:832c1fd57852 (2015-05-13) Next changeset 7:fb1313d79396 (2016-11-04) |
Commit message:
v0.2.3, ignore blank lines in ID file (contributed by Gildas Le Corguille) |
modified:
tools/seq_filter_by_id/README.rst tools/seq_filter_by_id/seq_filter_by_id.py tools/seq_filter_by_id/seq_filter_by_id.xml tools/seq_filter_by_id/tool_dependencies.xml |
b |
diff -r 832c1fd57852 -r 03e134cae41a tools/seq_filter_by_id/README.rst --- a/tools/seq_filter_by_id/README.rst Wed May 13 11:03:57 2015 -0400 +++ b/tools/seq_filter_by_id/README.rst Tue May 17 05:59:24 2016 -0400 |
b |
@@ -86,6 +86,9 @@ v0.2.2 - Use the ``format_source=...`` tag. - Reorder XML elements (internal change only). - Planemo for Tool Shed upload (``.shed.yml``, internal change only). +v0.2.3 - Ignore blank lines in ID file (contributed by Gildas Le Corguillé). + - Defensive quoting of filenames etc in the command definition + (internal change only). ======= ====================================================================== @@ -103,17 +106,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/venn_list/ + $ planemo shed_update -t testtoolshed --check_diff tools/seq_filter_by_id/ -m "New release" ... or:: - $ planemo shed_upload --shed_target toolshed --check_diff ~/repositories/pico_galaxy/tools/venn_list/ + $ planemo shed_update -t toolshed --check_diff tools/seq_filter_by_id/ -m "New release" ... To just build and check the tar ball, use:: - $ planemo shed_upload --tar_only ~/repositories/pico_galaxy/tools/venn_list/ + $ planemo shed_upload --tar_only tools/seq_filter_by_id/ ... $ tar -tzf shed_upload.tar.gz test-data/empty_file.dat |
b |
diff -r 832c1fd57852 -r 03e134cae41a tools/seq_filter_by_id/seq_filter_by_id.py --- a/tools/seq_filter_by_id/seq_filter_by_id.py Wed May 13 11:03:57 2015 -0400 +++ b/tools/seq_filter_by_id/seq_filter_by_id.py Tue May 17 05:59:24 2016 -0400 |
[ |
b'@@ -32,11 +32,7 @@\n import re\n from optparse import OptionParser\n \n-def sys_exit(msg, err=1):\n- sys.stderr.write(msg.rstrip() + "\\n")\n- sys.exit(err)\n-\n-#Parse Command Line\n+# Parse Command Line\n usage = """Use as follows:\n \n $ python seq_filter_by_id.py [options] tab1 cols1 [, tab2 cols2, ...]\n@@ -78,7 +74,7 @@\n options, args = parser.parse_args()\n \n if options.version:\n- print "v0.2.1"\n+ print "v0.2.3"\n sys.exit(0)\n \n in_file = options.input\n@@ -89,28 +85,28 @@\n drop_suffices = bool(options.suffix)\n \n if in_file is None or not os.path.isfile(in_file):\n- sys_exit("Missing input file: %r" % in_file)\n+ sys.exit("Missing input file: %r" % in_file)\n if out_positive_file is None and out_negative_file is None:\n- sys_exit("Neither output file requested")\n+ sys.exit("Neither output file requested")\n if seq_format is None:\n- sys_exit("Missing sequence format")\n+ sys.exit("Missing sequence format")\n if logic not in ["UNION", "INTERSECTION"]:\n- sys_exit("Logic agrument should be \'UNION\' or \'INTERSECTION\', not %r" % logic)\n+ sys.exit("Logic agrument should be \'UNION\' or \'INTERSECTION\', not %r" % logic)\n if options.id_list and args:\n- sys_exit("Cannot accepted IDs via both -t and as tabular files")\n+ sys.exit("Cannot accepted IDs via both -t and as tabular files")\n elif not options.id_list and not args:\n- sys_exit("Expected matched pairs of tabular files and columns (or -t given)")\n+ sys.exit("Expected matched pairs of tabular files and columns (or -t given)")\n if len(args) % 2:\n- sys_exit("Expected matched pairs of tabular files and columns, not: %r" % args)\n+ sys.exit("Expected matched pairs of tabular files and columns, not: %r" % args)\n \n \n-#Cope with three widely used suffix naming convensions,\n-#Illumina: /1 or /2\n-#Forward/revered: .f or .r\n-#Sanger, e.g. .p1k and .q1k\n-#See http://staden.sourceforge.net/manual/pregap4_unix_50.html\n-#re_f = re.compile(r"(/1|\\.f|\\.[sfp]\\d\\w*)$")\n-#re_r = re.compile(r"(/2|\\.r|\\.[rq]\\d\\w*)$")\n+# Cope with three widely used suffix naming convensions,\n+# Illumina: /1 or /2\n+# Forward/revered: .f or .r\n+# Sanger, e.g. .p1k and .q1k\n+# See http://staden.sourceforge.net/manual/pregap4_unix_50.html\n+# re_f = re.compile(r"(/1|\\.f|\\.[sfp]\\d\\w*)$")\n+# re_r = re.compile(r"(/2|\\.r|\\.[rq]\\d\\w*)$")\n re_suffix = re.compile(r"(/1|\\.f|\\.[sfp]\\d\\w*|/2|\\.r|\\.[rq]\\d\\w*)$")\n assert re_suffix.search("demo.f")\n assert re_suffix.search("demo.s1")\n@@ -125,19 +121,21 @@\n \n identifiers = []\n for i in range(len(args) // 2):\n- tabular_file = args[2*i]\n- cols_arg = args[2*i + 1]\n+ tabular_file = args[2 * i]\n+ cols_arg = args[2 * i + 1]\n if not os.path.isfile(tabular_file):\n- sys_exit("Missing tabular identifier file %r" % tabular_file)\n+ sys.exit("Missing tabular identifier file %r" % tabular_file)\n try:\n- columns = [int(arg)-1 for arg in cols_arg.split(",")]\n+ columns = [int(arg) - 1 for arg in cols_arg.split(",")]\n except ValueError:\n- sys_exit("Expected list of columns (comma separated integers), got %r" % cols_arg)\n+ sys.exit("Expected list of columns (comma separated integers), got %r" % cols_arg)\n if min(columns) < 0:\n- sys_exit("Expect one-based column numbers (not zero-based counting), got %r" % cols_arg)\n+ sys.exit("Expect one-based column numbers (not zero-based counting), got %r" % cols_arg)\n identifiers.append((tabular_file, columns))\n \n name_warn = False\n+\n+\n def check_white_space(name):\n parts = name.split(None, 1)\n global name_warn\n@@ -169,28 +167,29 @@\n clean_name = check_white_space\n \n \n-mapped_chars = { \'>\' :\'__gt__\',\n- \'<\' :\'__lt__\',\n- "\'" :\'__sq__\',\n- \'"\' :\'__dq__\',\n- \'[\' :\'__ob__\',\n- \']\' :\'__cb__\',\n- \'{\' :\'__oc__\',\n- \'}\' :\'__cc__\',\n- \'@\' : \'__at__\',\n- \'\\n\' : \'__cn__\',\n- \'\\r\' : \'__cr__\',\n- '..b'e is not None:\n print "Generating non-matching FASTQ file"\n- negative_handle = open(out_negative_file, "w")\n+ negative_handle = open(neg_file, "w")\n for title, seq, qual in FastqGeneralIterator(handle):\n- if clean_name(title.split(None, 1)[0]) not in ids:\n+ if clean_name(title.split(None, 1)[0]) not in wanted:\n negative_handle.write("@%s\\n%s\\n+\\n%s\\n" % (title, seq, qual))\n negative_handle.close()\n handle.close()\n@@ -345,48 +347,48 @@\n try:\n from Bio.SeqIO.SffIO import SffIterator, SffWriter\n except ImportError:\n- sys_exit("SFF filtering requires Biopython 1.54 or later")\n+ sys.exit("SFF filtering requires Biopython 1.54 or later")\n \n try:\n from Bio.SeqIO.SffIO import ReadRocheXmlManifest\n except ImportError:\n- #Prior to Biopython 1.56 this was a private function\n+ # Prior to Biopython 1.56 this was a private function\n from Bio.SeqIO.SffIO import _sff_read_roche_index_xml as ReadRocheXmlManifest\n \n- in_handle = open(in_file, "rb") #must be binary mode!\n+ in_handle = open(in_file, "rb") # must be binary mode!\n try:\n manifest = ReadRocheXmlManifest(in_handle)\n except ValueError:\n manifest = None\n \n- #This makes two passes though the SFF file with isn\'t so efficient,\n- #but this makes the code simple.\n+ # This makes two passes though the SFF file with isn\'t so efficient,\n+ # but this makes the code simple.\n pos_count = neg_count = 0\n- if out_positive_file is not None:\n- out_handle = open(out_positive_file, "wb")\n+ if pos_file is not None:\n+ out_handle = open(pos_file, "wb")\n writer = SffWriter(out_handle, xml=manifest)\n- in_handle.seek(0) #start again after getting manifest\n- pos_count = writer.write_file(rec for rec in SffIterator(in_handle) if clean_name(rec.id) in ids)\n+ in_handle.seek(0) # start again after getting manifest\n+ pos_count = writer.write_file(rec for rec in SffIterator(in_handle) if clean_name(rec.id) in wanted)\n out_handle.close()\n- if out_negative_file is not None:\n- out_handle = open(out_negative_file, "wb")\n+ if neg_file is not None:\n+ out_handle = open(neg_file, "wb")\n writer = SffWriter(out_handle, xml=manifest)\n- in_handle.seek(0) #start again\n- neg_count = writer.write_file(rec for rec in SffIterator(in_handle) if clean_name(rec.id) not in ids)\n+ in_handle.seek(0) # start again\n+ neg_count = writer.write_file(rec for rec in SffIterator(in_handle) if clean_name(rec.id) not in wanted)\n out_handle.close()\n- #And we\'re done\n+ # And we\'re done\n in_handle.close()\n- #At the time of writing, Galaxy doesn\'t show SFF file read counts,\n- #so it is useful to put them in stdout and thus shown in job info.\n+ # At the time of writing, Galaxy doesn\'t show SFF file read counts,\n+ # so it is useful to put them in stdout and thus shown in job info.\n return pos_count, neg_count\n \n \n-if seq_format.lower()=="sff":\n+if seq_format.lower() == "sff":\n # Now write filtered SFF file based on IDs wanted\n pos_count, neg_count = sff_filter(in_file, out_positive_file, out_negative_file, ids)\n # At the time of writing, Galaxy doesn\'t show SFF file read counts,\n # so it is useful to put them in stdout and thus shown in job info.\n-elif seq_format.lower()=="fasta":\n+elif seq_format.lower() == "fasta":\n # Write filtered FASTA file based on IDs from tabular file\n pos_count, neg_count = fasta_filter(in_file, out_positive_file, out_negative_file, ids)\n print "%i with and %i without specified IDs" % (pos_count, neg_count)\n@@ -395,4 +397,4 @@\n fastq_filter(in_file, out_positive_file, out_negative_file, ids)\n # This does not currently track the counts\n else:\n- sys_exit("Unsupported file type %r" % seq_format)\n+ sys.exit("Unsupported file type %r" % seq_format)\n' |
b |
diff -r 832c1fd57852 -r 03e134cae41a tools/seq_filter_by_id/seq_filter_by_id.xml --- a/tools/seq_filter_by_id/seq_filter_by_id.xml Wed May 13 11:03:57 2015 -0400 +++ b/tools/seq_filter_by_id/seq_filter_by_id.xml Tue May 17 05:59:24 2016 -0400 |
b |
@@ -1,4 +1,4 @@ -<tool id="seq_filter_by_id" name="Filter sequences by ID" version="0.2.2"> +<tool id="seq_filter_by_id" name="Filter sequences by ID" version="0.2.3"> <description>from a tabular file</description> <requirements> <requirement type="package" version="1.64">biopython</requirement> @@ -12,17 +12,17 @@ <version_command interpreter="python">seq_filter_by_id.py --version</version_command> <command interpreter="python"> seq_filter_by_id.py -i "$input_file" -f "$input_file.ext" -#if $output_choice_cond.output_choice=="both" - -p $output_pos -n $output_neg -#elif $output_choice_cond.output_choice=="pos" - -p $output_pos -#elif $output_choice_cond.output_choice=="neg" - -n $output_neg +#if str($output_choice_cond.output_choice)=="both" + -p "$output_pos" -n "$output_neg" +#elif str($output_choice_cond.output_choice)=="pos" + -p "$output_pos" +#elif str($output_choice_cond.output_choice)=="neg" + -n "$output_neg" #end if -#if $adv_opts.adv_opts_selector=="advanced" and $adv_opts.strip_suffix +#if str($adv_opts.adv_opts_selector)=="advanced" and $adv_opts.strip_suffix -s #end if -#if $id_opts.id_opts_selector=="tabular": +#if str($id_opts.id_opts_selector)=="tabular": ## TODO - Decide on best way to expose multiple ID files via the XML wrapper. ## Single tabular file, can call the Python script with either UNION or INTERSECTION -l UNION "$id_opts.input_tabular" "$id_opts.columns" |
b |
diff -r 832c1fd57852 -r 03e134cae41a tools/seq_filter_by_id/tool_dependencies.xml --- a/tools/seq_filter_by_id/tool_dependencies.xml Wed May 13 11:03:57 2015 -0400 +++ b/tools/seq_filter_by_id/tool_dependencies.xml Tue May 17 05:59:24 2016 -0400 |
b |
@@ -1,6 +1,6 @@ <?xml version="1.0"?> <tool_dependency> <package name="biopython" version="1.64"> - <repository changeset_revision="5477a05cc158" name="package_biopython_1_64" owner="biopython" toolshed="https://toolshed.g2.bx.psu.edu" /> + <repository changeset_revision="b64c8edb7e45" name="package_biopython_1_64" owner="biopython" toolshed="https://toolshed.g2.bx.psu.edu" /> </package> </tool_dependency> |