changeset 1:9c8c5079c8af draft

Uploaded v0.0.2, adds unit tests. Note that for the tests to pass requires commit which has not yet reached galaxy-dist: https://bitbucket.org/galaxy/galaxy-central/commits/8264c77e4f07c0dee932add796f5ee7ce02245b3
author peterjc
date Mon, 29 Apr 2013 13:14:23 -0400
parents a4b9836f8f47
children 7c0642fc57ad
files test-data/four_human_proteins.fasta test-data/four_human_proteins.rename.fasta test-data/four_human_proteins.rename.tabular tools/filters/seq_rename.py tools/filters/seq_rename.txt tools/filters/seq_rename.xml
diffstat 6 files changed, 110 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/four_human_proteins.fasta	Mon Apr 29 13:14:23 2013 -0400
@@ -0,0 +1,61 @@
+>sp|Q9BS26|ERP44_HUMAN Endoplasmic reticulum resident protein 44 OS=Homo sapiens GN=ERP44 PE=1 SV=1
+MHPAVFLSLPDLRCSLLLLVTWVFTPVTTEITSLDTENIDEILNNADVALVNFYADWCRF
+SQMLHPIFEEASDVIKEEFPNENQVVFARVDCDQHSDIAQRYRISKYPTLKLFRNGMMMK
+REYRGQRSVKALADYIRQQKSDPIQEIRDLAEITTLDRSKRNIIGYFEQKDSDNYRVFER
+VANILHDDCAFLSAFGDVSKPERYSGDNIIYKPPGHSAPDMVYLGAMTNFDVTYNWIQDK
+CVPLVREITFENGEELTEEGLPFLILFHMKEDTESLEIFQNEVARQLISEKGTINFLHAD
+CDKFRHPLLHIQKTPADCPVIAIDSFRHMYVFGDFKDVLIPGKLKQFVFDLHSGKLHREF
+HHGPDPTDTAPGEQAQDVASSPPESSFQKLAPSEYRYTLLRDRDEL
+>sp|Q9NSY1|BMP2K_HUMAN BMP-2-inducible protein kinase OS=Homo sapiens GN=BMP2K PE=1 SV=2
+MKKFSRMPKSEGGSGGGAAGGGAGGAGAGAGCGSGGSSVGVRVFAVGRHQVTLEESLAEG
+GFSTVFLVRTHGGIRCALKRMYVNNMPDLNVCKREITIMKELS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GPLGPLYASSNPEYLSASDVFPCSVYVPDEWEVSR
+EKITLLRELGQGSFGMVYEGNARDIIKGEAETRVAVKTVNESASLRERIEFLNEASVMKG
+FTCHHVVRLLGVVSKGQPTLVVMELMAHGDLKSYLRSLRPEAENNPGRPPPTLQEMIQMA
+AEIADGMAYLNAKKFVHRDLAARNCMVAHDFTVKIGDFGMTRDIYETDYYRKGGKGLLPV
+RWMAPESLKDGVFTTSSDMWSFGVVLWEITSLAEQPYQGLSNEQVLKFVMDGGYLDQPDN
+CPERVTDLMRMCWQFNPKMRPTFLEIVNLLKDDLHPSFPEVSFFHSEENKAPESEELEME
+FEDMENVPLDRSSHCQREEAGGRDGGSSLGFKRSYEEHIPYTHMNGGKKNGRILTLPRSN
+PS
+>sp|P08100|OPSD_HUMAN Rhodopsin OS=Homo sapiens GN=RHO PE=1 SV=1
+MNGTEGPNFYVPFSNATGVVRSPFEYPQYYLAEPWQFSMLAAYMFLLIVLGFPINFLTLY
+VTVQHKKLRTPLNYILLNLAVADLFMVLGGFTSTLYTSLHGYFVFGPTGCNLEGFFATLG
+GEIALWSLVVLAIERYVVVCKPMSNFRFGENHAIMGVAFTWVMALACAAPPLAGWSRYIP
+EGLQCSCGIDYYTLKPEVNNESFVIYMFVVHFTIPMIIIFFCYGQLVFTVKEAAAQQQES
+ATTQKAEKEVTRMVIIMVIAFLICWVPYASVAFYIFTHQGSNFGPIFMTIPAFFAKSAAI
+YNPVIYIMMNKQFRNCMLTTICCGKNPLGDDEASATVSKTETSQVAPA
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/four_human_proteins.rename.fasta	Mon Apr 29 13:14:23 2013 -0400
@@ -0,0 +1,8 @@
+>Q9BS26 Endoplasmic reticulum resident protein 44 OS=Homo sapiens GN=ERP44 PE=1 SV=1
+MHPAVFLSLPDLRCSLLLLVTWVFTPVTTEITSLDTENIDEILNNADVALVNFYADWCRFSQMLHPIFEEASDVIKEEFPNENQVVFARVDCDQHSDIAQRYRIS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FMTIPAFFAKSAAIYNPVIYIMMNKQFRNCMLTTICCGKNPLGDDEASATVSKTETSQVAPA
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/four_human_proteins.rename.tabular	Mon Apr 29 13:14:23 2013 -0400
@@ -0,0 +1,5 @@
+#FASTA	ID
+sp|Q9BS26|ERP44_HUMAN	Q9BS26
+sp|Q9NSY1|BMP2K_HUMAN	Q9NSY1
+sp|P06213|INSR_HUMAN	P06213
+sp|P08100|OPSD_HUMAN	P08100
--- a/tools/filters/seq_rename.py	Tue Jun 07 17:43:26 2011 -0400
+++ b/tools/filters/seq_rename.py	Mon Apr 29 13:14:23 2013 -0400
@@ -17,14 +17,18 @@
 molecular biology and bioinformatics. Bioinformatics 25(11) 1422-3.
 http://dx.doi.org/10.1093/bioinformatics/btp163 pmid:19304878.
 
-This script is copyright 2011 by Peter Cock, The James Hutton Institute UK.
+This script is copyright 2011-2013 by Peter Cock, The James Hutton Institute UK.
 All rights reserved. See accompanying text file for licence details (MIT/BSD
 style).
 
-This is version 0.0.1 of the script.
+This is version 0.0.2 of the script.
 """
 import sys
 
+if "-v" in sys.argv or "--version" in sys.argv:
+    print "v0.0.2"
+    sys.exit(0)
+
 def stop_err(msg, err=1):
     sys.stderr.write(msg.rstrip() + "\n")
     sys.exit(err)
@@ -33,7 +37,7 @@
 try:
     tabular_file, old_col_arg, new_col_arg, in_file, seq_format, out_file = sys.argv[1:]
 except ValueError:
-    stop_err("Expected six arguments, got %i:\n%s" % (len(sys.argv)-1, " ".join(sys.argv)))
+    stop_err("Expected six arguments (tabular file, old col, new col, input file, format, output file), got %i:\n%s" % (len(sys.argv)-1, " ".join(sys.argv)))
 
 try:
     if old_col_arg.startswith("c"):
--- a/tools/filters/seq_rename.txt	Tue Jun 07 17:43:26 2011 -0400
+++ b/tools/filters/seq_rename.txt	Mon Apr 29 13:14:23 2013 -0400
@@ -15,6 +15,9 @@
 from column(s) of tabular file.
 
 
+Manual Installation
+===================
+
 There are just two files to install:
 
 * seq_rename.py (the Python script)
@@ -35,6 +38,9 @@
 =======
 
 v0.0.1 - Initial version.
+v0.0.2 - Record script version when run from Galaxy.
+       - Add unit test.
+       - Check for errors using Python script's return code.
 
 
 Developers
@@ -43,17 +49,20 @@
 This script and related tools are being developed on the following hg branch:
 http://bitbucket.org/peterjc/galaxy-central/src/tools
 
-For making the "Galaxy Tool Shed" http://community.g2.bx.psu.edu/ tarball use
+For making the "Galaxy Tool Shed" http://toolshed.g2.bx.psu.edu/ tarball use
 the following command from the Galaxy root folder:
 
-tar -czf seq_rename.tar.gz tools/filters/seq_rename.*
+$ tar -czf seq_rename.tar.gz tools/filters/seq_rename.* test-data/four_human_proteins.fasta test-data/four_human_proteins.rename.tabular test-data/four_human_proteins.rename.fasta
 
 Check this worked:
 
 $ tar -tzf seq_rename.tar.gz
-filter/seq_rename.py
-filter/seq_rename.txt
-filter/seq_rename.xml
+tools/filter/seq_rename.py
+tools/filter/seq_rename.txt
+tools/filter/seq_rename.xml
+test-data/four_human_proteins.fasta
+test-data/four_human_proteins.rename.tabular
+test-data/four_human_proteins.rename.fasta
 
 
 Licence (MIT/BSD style)
--- a/tools/filters/seq_rename.xml	Tue Jun 07 17:43:26 2011 -0400
+++ b/tools/filters/seq_rename.xml	Mon Apr 29 13:14:23 2013 -0400
@@ -1,14 +1,19 @@
-<tool id="seq_rename" name="Rename sequences" version="0.0.1">
+<tool id="seq_rename" name="Rename sequences" version="0.0.2">
 	<description>with ID mapping from a tabular file</description>
+	<version_commmand interpreter="python">seq_rename.py --version</version_commmand>
 	<command interpreter="python">
 seq_rename.py $input_tabular $old_column $new_column $input_file $input_file.ext $output_file
 	</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,qual,fastq,sff" label="Sequence file" help="FASTA, QUAL, FASTQ, or SFF format." />
 		<param name="input_tabular" type="data" format="tabular" label="Tabular file containing sequence identifiers"/>
 		<param name="old_column" type="data_column" data_ref="input_tabular" multiple="False" numerical="False" label="Column containing current (old) sequence identifiers"/>
-                <param name="new_column" type="data_column" data_ref="input_tabular" multiple="False" numerical="False" label="Column contai
-ning new sequence identifiers"/>
+                <param name="new_column" type="data_column" data_ref="input_tabular" multiple="False" numerical="False" label="Column containing new sequence identifiers"/>
 	</inputs>
 	<outputs>
 		<data name="output_file" format="fasta" label="Renamed ${on_string}">
@@ -24,6 +29,13 @@
 		</data>
 	</outputs>
 	<tests>
+		<test>
+			<param name="input_file" value="four_human_proteins.fasta" ftype="fasta" />
+			<param name="input_tabular" value="four_human_proteins.rename.tabular" ftype="tabular" />
+			<param name="old_column" value="1" />
+			<param name="new_column" value="2" />
+			<output name="output_file" file="four_human_proteins.rename.fasta" ftype="fasta" />
+		</test>
 	</tests>
 	<requirements>
 		<requirement type="python-module">Bio</requirement>