comparison mutation_analysis.py @ 22:d84c9791d8c4 draft

Uploaded
author davidvanzessen
date Tue, 07 Apr 2015 03:52:34 -0400
parents c9f9623f1f76
children 2433a1e110e1
comparison
equal deleted inserted replaced
21:c9f9623f1f76 22:d84c9791d8c4
96 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]])]) 96 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]])])
97 IDlist += [ID] 97 IDlist += [ID]
98 98
99 99
100 directory = outfile[:outfile.rfind("/") + 1] 100 directory = outfile[:outfile.rfind("/") + 1]
101 value = 0; 101 value = 0
102 valuedic = dict() 102 valuedic = dict()
103 for gene in genes: 103 for gene in genes:
104 with open(directory + gene + "_value.txt", 'r') as v: 104 with open(directory + gene + "_value.txt", 'r') as v:
105 valuedic[gene] = int(v.readlines()[0].rstrip()) 105 valuedic[gene] = int(v.readlines()[0].rstrip())
106 with open(directory + "total_value.txt", 'r') as v: 106 with open(directory + "total_value.txt", 'r') as v:
135 for ID in IDlist: 135 for ID in IDlist:
136 if first: 136 if first:
137 o.write("ID\tRGYWC\tWRCY\tWA\tTW\n") 137 o.write("ID\tRGYWC\tWRCY\tWA\tTW\n")
138 first = False 138 first = False
139 continue 139 continue
140 print ID
141 print RGYWCount[ID]
142 print WRCYCount[ID]
143 print WACount[ID]
144 print TWCount[ID]
145 o.write(ID + "\t" + str(RGYWCount[ID]) + "\t" + str(WRCYCount[ID]) + "\t" + str(WACount[ID]) + "\t" + str(TWCount[ID]) + "\n") 140 o.write(ID + "\t" + str(RGYWCount[ID]) + "\t" + str(WRCYCount[ID]) + "\t" + str(WACount[ID]) + "\t" + str(TWCount[ID]) + "\n")