changeset 0:03dbb4601b15 draft

Uploaded
author davidvanzessen
date Thu, 23 Jan 2014 08:14:08 -0500
parents
children 07a23652bc2a
files igblastmerge.py igblastmerge.xml
diffstat 2 files changed, 81 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/igblastmerge.py	Thu Jan 23 08:14:08 2014 -0500
@@ -0,0 +1,52 @@
+import sys
+# error
+def stop_err( msg ):
+	sys.stderr.write( "%s\n" % msg )
+	sys.exit()
+
+# main
+def main():
+    args = sys.argv[1:-2]
+
+    try:
+        o = open(sys.argv[-1], 'w')
+        i = open(args[1], 'r')
+        separator = "\t"
+        newline = "\n"
+        line = i.readline()
+        #write the header
+        o.write(line[:line.rfind(newline)] + separator + "Sample" + separator + "Replicate" + newline)
+        i.close()
+
+        current = 1
+        sampleID = args[0]
+        count = 1
+
+        while True:
+            print str(o)
+            f = open(args[current], 'r')
+            line = f.readline()
+            line = f.readline()
+            while line:
+                o.write(line[:line.rfind(newline)] + separator + sampleID + separator + str(count) + newline)
+                line = f.readline()
+            f.close()
+
+            if current >= (len(args) - 1):
+                break
+            if args[current + 1].find("/") is -1:
+                sampleID = args[current + 1]
+                current += 1
+                count = 1
+            else:
+                count += 1
+            current += 1
+        o.close()
+
+    except Exception, ex:
+        stop_err('Error running new_column.py\n' + str(ex))
+    sys.exit(0)
+
+if __name__ == "__main__":
+	print sys.argv
+	main()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/igblastmerge.xml	Thu Jan 23 08:14:08 2014 -0500
@@ -0,0 +1,29 @@
+<tool id="experimentaldesign_igg" name="ExperimentalDesign" version="1.0">
+	<description> </description>
+	<command interpreter="python">
+		igblastmerge.py 
+		#for $i, $f in enumerate($patients)
+            $f.id
+            #for $j, $g in enumerate($f.samples)
+            	${g.sample}
+            #end for
+
+		#end for
+		--output $out_file
+	</command>
+	<inputs>
+		<repeat name="patients" title="Patients" min="1" default="1">
+            <repeat name="samples" title="Sample" min="1" default="1">
+                <param name="sample" format="tabular" type="data" label="Sample to Process" />
+            </repeat>
+			<param name="id" type="text" label="ID" />
+		</repeat>
+	</inputs>
+	<outputs>
+		<data format="tabular" name="out_file" />
+	</outputs>
+	<help>
+		Step 3 of the Immune Repertoire tools, merges the parsed reports generated in step 2 into one file with an Sample ID.
+	</help>
+
+</tool>