comparison shm_csr.py @ 17:b95fa7e426c3 draft

Uploaded
author davidvanzessen
date Thu, 24 Nov 2016 10:24:19 -0500
parents 4e596473c25c
children ce25fb581ca3
comparison
equal deleted inserted replaced
16:4e596473c25c 17:b95fa7e426c3
245 with open(directory + "all_" + fname + "_value.txt", 'r') as v: 245 with open(directory + "all_" + fname + "_value.txt", 'r') as v:
246 valuedic["total_" + fname] = float(v.readlines()[0].rstrip()) 246 valuedic["total_" + fname] = float(v.readlines()[0].rstrip())
247 247
248 248
249 def get_xyz(lst, gene, f, fname): 249 def get_xyz(lst, gene, f, fname):
250 250 x = round(round(f(lst), 1))
251 x = int(round(f(lst)))
252 y = valuedic[gene + "_" + fname] 251 y = valuedic[gene + "_" + fname]
253 z = str(round(x / float(y) * 100, 1)) if y != 0 else "0" 252 z = str(round(x / float(y) * 100, 1)) if y != 0 else "0"
254 if gene == "unmatched":
255 print x, y, z
256 return (str(x), str(y), z) 253 return (str(x), str(y), z)
257 254
258 dic = {"RGYW": RGYWCount, "WRCY": WRCYCount, "WA": WACount, "TW": TWCount} 255 dic = {"RGYW": RGYWCount, "WRCY": WRCYCount, "WA": WACount, "TW": TWCount}
259 arr = ["RGYW", "WRCY", "WA", "TW"] 256 arr = ["RGYW", "WRCY", "WA", "TW"]
260 257
280 277
281 278
282 # for testing 279 # for testing
283 seq_motif_file = outfile[:outfile.rindex("/")] + "/motif_per_seq.txt" 280 seq_motif_file = outfile[:outfile.rindex("/")] + "/motif_per_seq.txt"
284 with open(seq_motif_file, 'w') as o: 281 with open(seq_motif_file, 'w') as o:
285 o.write("ID\tRGYWC\tWRCY\tWA\tTW\n") 282 o.write("ID\tRGYW\tWRCY\tWA\tTW\n")
286 for ID in IDlist: 283 for ID in IDlist:
287 #o.write(ID + "\t" + str(round(RGYWCount[ID], 2)) + "\t" + str(round(WRCYCount[ID], 2)) + "\t" + str(round(WACount[ID], 2)) + "\t" + str(round(TWCount[ID], 2)) + "\n") 284 #o.write(ID + "\t" + str(round(RGYWCount[ID], 2)) + "\t" + str(round(WRCYCount[ID], 2)) + "\t" + str(round(WACount[ID], 2)) + "\t" + str(round(TWCount[ID], 2)) + "\n")
288 o.write(ID + "\t" + str(RGYWCount[ID]) + "\t" + str(WRCYCount[ID]) + "\t" + str(WACount[ID]) + "\t" + str(TWCount[ID]) + "\n") 285 o.write(ID + "\t" + str(RGYWCount[ID]) + "\t" + str(WRCYCount[ID]) + "\t" + str(WACount[ID]) + "\t" + str(TWCount[ID]) + "\n")