diff mutation_analysis.py @ 107:01c9993865af draft

Uploaded
author davidvanzessen
date Wed, 13 Jul 2016 08:04:13 -0400
parents 603a10976e9c
children 6add3e66f4fa
line wrap: on
line diff
--- a/mutation_analysis.py	Wed Jun 29 05:13:25 2016 -0400
+++ b/mutation_analysis.py	Wed Jul 13 08:04:13 2016 -0400
@@ -86,6 +86,7 @@
 
 aa_mutations_by_id_file = outfile[:outfile.rindex("/")] + "/aa_id_mutations.txt"
 with open(aa_mutations_by_id_file, 'w') as o:
+	o.write("ID\tbest_match\t" + "\t".join([str(x) for x in range(1,AALength)]) + "\n")
 	for ID in mutationListByID.keys():
 		AA_mutation_for_ID = AA_mutation_empty[:]
 		for mutation in mutationListByID[ID]:
@@ -95,7 +96,7 @@
 				AA_mutation_for_ID[AA_mutation_position] += 1
 				clss = genedic[ID][:2]
 				AA_mutation_dic[clss][AA_mutation_position] += 1
-		o.write(ID + "\t" + "\t".join([str(x) for x in AA_mutation_for_ID[1:]]) + "\n")
+		o.write(ID + "\t" + genedic[ID] + "\t" + "\t".join([str(x) for x in AA_mutation_for_ID[1:]]) + "\n")
 
 
 
@@ -133,7 +134,7 @@
 
 aa_mutations_by_id_file = outfile[:outfile.rindex("/")] + "/absent_aa_id.txt"
 with open(aa_mutations_by_id_file, 'w') as o:
-	o.write("ID\tcdr1length\tcdr2length\t" + "\t".join([str(x) for x in range(1,AALength-1)]) + "\n")
+	o.write("ID\tcdr1length\tcdr2length\tbest_match\t" + "\t".join([str(x) for x in range(1,AALength)]) + "\n")
 	for ID in IDlist:
 		absentAAbyID = [1] * (AALength-1)
 		cdr1Length = cdr1LengthDic[ID]
@@ -143,7 +144,7 @@
 		cdr2Length = cdr2LengthDic[ID]
 		for c in absentAACDR2Dic[cdr2Length]:
 			absentAAbyID[c] -= 1
-		o.write(ID + "\t" + str(cdr1Length) + "\t" + str(cdr2Length) + "\t" + "\t".join([str(x) for x in absentAAbyID]) + "\n")
+		o.write(ID + "\t" + str(cdr1Length) + "\t" + str(cdr2Length) + "\t" + genedic[ID] + "\t" + "\t".join([str(x) for x in absentAAbyID]) + "\n")