Mercurial > repos > davidvanzessen > mutation_analysis
comparison mutation_analysis.py @ 107:01c9993865af draft
Uploaded
| author | davidvanzessen |
|---|---|
| date | Wed, 13 Jul 2016 08:04:13 -0400 |
| parents | 603a10976e9c |
| children | 6add3e66f4fa |
comparison
equal
deleted
inserted
replaced
| 106:074ae1e30e8f | 107:01c9993865af |
|---|---|
| 84 AA_mutation_dic = {"ca": AA_mutation[:], "cg": AA_mutation[:], "cm": AA_mutation[:], "un": AA_mutation[:]} | 84 AA_mutation_dic = {"ca": AA_mutation[:], "cg": AA_mutation[:], "cm": AA_mutation[:], "un": AA_mutation[:]} |
| 85 AA_mutation_empty = AA_mutation[:] | 85 AA_mutation_empty = AA_mutation[:] |
| 86 | 86 |
| 87 aa_mutations_by_id_file = outfile[:outfile.rindex("/")] + "/aa_id_mutations.txt" | 87 aa_mutations_by_id_file = outfile[:outfile.rindex("/")] + "/aa_id_mutations.txt" |
| 88 with open(aa_mutations_by_id_file, 'w') as o: | 88 with open(aa_mutations_by_id_file, 'w') as o: |
| 89 o.write("ID\tbest_match\t" + "\t".join([str(x) for x in range(1,AALength)]) + "\n") | |
| 89 for ID in mutationListByID.keys(): | 90 for ID in mutationListByID.keys(): |
| 90 AA_mutation_for_ID = AA_mutation_empty[:] | 91 AA_mutation_for_ID = AA_mutation_empty[:] |
| 91 for mutation in mutationListByID[ID]: | 92 for mutation in mutationListByID[ID]: |
| 92 if mutation[4]: | 93 if mutation[4]: |
| 93 AA_mutation_position = int(mutation[4]) | 94 AA_mutation_position = int(mutation[4]) |
| 94 AA_mutation[AA_mutation_position] += 1 | 95 AA_mutation[AA_mutation_position] += 1 |
| 95 AA_mutation_for_ID[AA_mutation_position] += 1 | 96 AA_mutation_for_ID[AA_mutation_position] += 1 |
| 96 clss = genedic[ID][:2] | 97 clss = genedic[ID][:2] |
| 97 AA_mutation_dic[clss][AA_mutation_position] += 1 | 98 AA_mutation_dic[clss][AA_mutation_position] += 1 |
| 98 o.write(ID + "\t" + "\t".join([str(x) for x in AA_mutation_for_ID[1:]]) + "\n") | 99 o.write(ID + "\t" + genedic[ID] + "\t" + "\t".join([str(x) for x in AA_mutation_for_ID[1:]]) + "\n") |
| 99 | 100 |
| 100 | 101 |
| 101 | 102 |
| 102 #absent AA stuff | 103 #absent AA stuff |
| 103 absentAACDR1Dic = defaultdict(list) | 104 absentAACDR1Dic = defaultdict(list) |
| 131 absentAA[c] -= 1 | 132 absentAA[c] -= 1 |
| 132 | 133 |
| 133 | 134 |
| 134 aa_mutations_by_id_file = outfile[:outfile.rindex("/")] + "/absent_aa_id.txt" | 135 aa_mutations_by_id_file = outfile[:outfile.rindex("/")] + "/absent_aa_id.txt" |
| 135 with open(aa_mutations_by_id_file, 'w') as o: | 136 with open(aa_mutations_by_id_file, 'w') as o: |
| 136 o.write("ID\tcdr1length\tcdr2length\t" + "\t".join([str(x) for x in range(1,AALength-1)]) + "\n") | 137 o.write("ID\tcdr1length\tcdr2length\tbest_match\t" + "\t".join([str(x) for x in range(1,AALength)]) + "\n") |
| 137 for ID in IDlist: | 138 for ID in IDlist: |
| 138 absentAAbyID = [1] * (AALength-1) | 139 absentAAbyID = [1] * (AALength-1) |
| 139 cdr1Length = cdr1LengthDic[ID] | 140 cdr1Length = cdr1LengthDic[ID] |
| 140 for c in absentAACDR1Dic[cdr1Length]: | 141 for c in absentAACDR1Dic[cdr1Length]: |
| 141 absentAAbyID[c] -= 1 | 142 absentAAbyID[c] -= 1 |
| 142 | 143 |
| 143 cdr2Length = cdr2LengthDic[ID] | 144 cdr2Length = cdr2LengthDic[ID] |
| 144 for c in absentAACDR2Dic[cdr2Length]: | 145 for c in absentAACDR2Dic[cdr2Length]: |
| 145 absentAAbyID[c] -= 1 | 146 absentAAbyID[c] -= 1 |
| 146 o.write(ID + "\t" + str(cdr1Length) + "\t" + str(cdr2Length) + "\t" + "\t".join([str(x) for x in absentAAbyID]) + "\n") | 147 o.write(ID + "\t" + str(cdr1Length) + "\t" + str(cdr2Length) + "\t" + genedic[ID] + "\t" + "\t".join([str(x) for x in absentAAbyID]) + "\n") |
| 147 | 148 |
| 148 | 149 |
| 149 | 150 |
| 150 aa_mutations_file = outfile[:outfile.rindex("/")] + "/aa_mutations.txt" | 151 aa_mutations_file = outfile[:outfile.rindex("/")] + "/aa_mutations.txt" |
| 151 with open(aa_mutations_file, 'w') as o: | 152 with open(aa_mutations_file, 'w') as o: |
