changeset 2:abdd608c869b draft

Uploaded v0.0.5, checked script return code for errors X copes with a FASTA entry missing an ID.
author peterjc
date Wed, 24 Apr 2013 11:34:12 -0400
parents 262f08104540
children 44ab4c0f7683
files tools/filters/seq_filter_by_id.py tools/filters/seq_filter_by_id.txt tools/filters/seq_filter_by_id.xml
diffstat 3 files changed, 18 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/tools/filters/seq_filter_by_id.py	Mon Apr 15 12:27:30 2013 -0400
+++ b/tools/filters/seq_filter_by_id.py	Wed Apr 24 11:34:12 2013 -0400
@@ -29,7 +29,7 @@
 (formerly the Scottish Crop Research Institute, SCRI), UK. All rights reserved.
 See accompanying text file for licence details (MIT/BSD style).
 
-This is version 0.0.4 of the script, use -v or --version to get the version.
+This is version 0.0.5 of the script, use -v or --version to get the version.
 """
 import sys
 
@@ -38,7 +38,7 @@
     sys.exit(err)
 
 if "-v" in sys.argv or "--version" in sys.argv:
-    print "v0.0.4"
+    print "v0.0.5"
     sys.exit(0)
 
 #Parse Command Line
@@ -89,11 +89,18 @@
         if line[0] == ">":
             break
 
+    no_id_warned = False
     while True:
         if line[0] != ">":
             raise ValueError(
                 "Records in Fasta files should start with '>' character")
-        id = line[1:].split(None, 1)[0]
+        try:
+            id = line[1:].split(None, 1)[0]
+        except IndexError:
+            if not no_id_warned:
+                sys.stderr.write("WARNING - Malformed FASTA entry with no identifier\n")
+                no_id_warned = True
+            id = None
         lines = [line]
         line = handle.readline()
         while True:
--- a/tools/filters/seq_filter_by_id.txt	Mon Apr 15 12:27:30 2013 -0400
+++ b/tools/filters/seq_filter_by_id.txt	Wed Apr 24 11:34:12 2013 -0400
@@ -38,6 +38,8 @@
 v0.0.4 - Record script version when run from Galaxy.
        - Faster FASTA code which preserves the original line wrapping.
        - Basic unit test included.
+v0.0.5 - Check for errors using Python script's return code.
+       - Cope with malformed FASTA entries without an identifier.
 
 
 Developers
--- a/tools/filters/seq_filter_by_id.xml	Mon Apr 15 12:27:30 2013 -0400
+++ b/tools/filters/seq_filter_by_id.xml	Wed Apr 24 11:34:12 2013 -0400
@@ -1,4 +1,4 @@
-<tool id="seq_filter_by_id" name="Filter sequences by ID" version="0.0.4">
+<tool id="seq_filter_by_id" name="Filter sequences by ID" version="0.0.5">
 	<description>from a tabular file</description>
 	<version_command interpreter="python">seq_filter_by_id.py --version</version_command>
 	<command interpreter="python">
@@ -11,6 +11,11 @@
  - $output_neg
 #end if
 	</command>
+        <stdio>
+                <!-- Anything other than zero is an error -->
+                <exit_code range="1:" />
+                <exit_code range=":-1" />
+        </stdio>
 	<inputs>
 		<param name="input_file" type="data" format="fasta,fastq,sff" label="Sequence file to filter on the identifiers" help="FASTA, FASTQ, or SFF format." />
 		<param name="input_tabular" type="data" format="tabular" label="Tabular file containing sequence identifiers"/>