# HG changeset patch # User davidvanzessen # Date 1390482848 18000 # Node ID 03dbb4601b15135767d473a56f98adb991360676 Uploaded diff -r 000000000000 -r 03dbb4601b15 igblastmerge.py --- /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() diff -r 000000000000 -r 03dbb4601b15 igblastmerge.xml --- /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 @@ + + + + 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 + + + + + + + + + + + + + + Step 3 of the Immune Repertoire tools, merges the parsed reports generated in step 2 into one file with an Sample ID. + + +