Mercurial > repos > davidvanzessen > mutation_analysis
diff mutation_analysis.py @ 21:c9f9623f1f76 draft
Uploaded
author | davidvanzessen |
---|---|
date | Thu, 02 Apr 2015 03:31:23 -0400 |
parents | 069419cccba4 |
children | d84c9791d8c4 |
line wrap: on
line diff
--- a/mutation_analysis.py Wed Apr 01 05:26:52 2015 -0400 +++ b/mutation_analysis.py Thu Apr 02 03:31:23 2015 -0400 @@ -72,6 +72,7 @@ aggctatIndex = 0 atagcctIndex = 0 first = True +IDlist = [] with open(infile, 'r') as i: for line in i: if first: @@ -93,6 +94,7 @@ WRCYCount[ID] = sum([1 for (x,y,z) in WRCY if z and z != "CDR3" and any([(x <= int(where) <= y) for (frm, where, to, a,b,c,d) in mutationdic[ID + "_" + z]])]) WACount[ID] = sum([1 for (x,y,z) in WA if z and z != "CDR3" and any([(x <= int(where) <= y) for (frm, where, to, a,b,c,d) in mutationdic[ID + "_" + z]])]) TWCount[ID] = sum([1 for (x,y,z) in TW if z and z != "CDR3" and any([(x <= int(where) <= y) for (frm, where, to, a,b,c,d) in mutationdic[ID + "_" + z]])]) + IDlist += [ID] directory = outfile[:outfile.rfind("/") + 1] @@ -124,3 +126,20 @@ y = valuedic["total"] z = str(round(x / float(valuedic["total"]) * 100, 1)) o.write("," + str(x) + "," + str(y) + "," + z + "\n") + + +#for testing +seq_motif_file = outfile[:outfile.rindex("/")] + "/motif_per_seq.txt" +first = True +with open(seq_motif_file, 'w') as o: + for ID in IDlist: + if first: + o.write("ID\tRGYWC\tWRCY\tWA\tTW\n") + first = False + continue + print ID + print RGYWCount[ID] + print WRCYCount[ID] + print WACount[ID] + print TWCount[ID] + o.write(ID + "\t" + str(RGYWCount[ID]) + "\t" + str(WRCYCount[ID]) + "\t" + str(WACount[ID]) + "\t" + str(TWCount[ID]) + "\n")