annotate mutation_column_checker.py @ 82:a103134ee6e0 draft

Uploaded
author davidvanzessen
date Thu, 25 Feb 2021 10:32:32 +0000
parents b6f9a640e098
children 729738462297
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
81
b6f9a640e098 Uploaded
davidvanzessen
parents:
diff changeset
1 import re
b6f9a640e098 Uploaded
davidvanzessen
parents:
diff changeset
2
b6f9a640e098 Uploaded
davidvanzessen
parents:
diff changeset
3 mutationMatcher = re.compile("^([nactg])(\d+).([nactg]),?[ ]?([A-Z])?(\d+)?[>]?([A-Z;])?(.*)?")
b6f9a640e098 Uploaded
davidvanzessen
parents:
diff changeset
4
b6f9a640e098 Uploaded
davidvanzessen
parents:
diff changeset
5 with open("7_V-REGION-mutation-and-AA-change-table.txt", 'r') as file_handle:
b6f9a640e098 Uploaded
davidvanzessen
parents:
diff changeset
6 first = True
b6f9a640e098 Uploaded
davidvanzessen
parents:
diff changeset
7 fr3_index = -1
b6f9a640e098 Uploaded
davidvanzessen
parents:
diff changeset
8 for i, line in enumerate(file_handle):
b6f9a640e098 Uploaded
davidvanzessen
parents:
diff changeset
9 line_split = line.split("\t")
b6f9a640e098 Uploaded
davidvanzessen
parents:
diff changeset
10 if first:
b6f9a640e098 Uploaded
davidvanzessen
parents:
diff changeset
11 fr3_index = line_split.index("FR3-IMGT")
b6f9a640e098 Uploaded
davidvanzessen
parents:
diff changeset
12 first = False
b6f9a640e098 Uploaded
davidvanzessen
parents:
diff changeset
13 continue
b6f9a640e098 Uploaded
davidvanzessen
parents:
diff changeset
14
b6f9a640e098 Uploaded
davidvanzessen
parents:
diff changeset
15 if len(line_split) < fr3_index:
b6f9a640e098 Uploaded
davidvanzessen
parents:
diff changeset
16 continue
b6f9a640e098 Uploaded
davidvanzessen
parents:
diff changeset
17
b6f9a640e098 Uploaded
davidvanzessen
parents:
diff changeset
18 fr3_data = line_split[fr3_index]
b6f9a640e098 Uploaded
davidvanzessen
parents:
diff changeset
19 if len(fr3_data) > 5:
b6f9a640e098 Uploaded
davidvanzessen
parents:
diff changeset
20 try:
b6f9a640e098 Uploaded
davidvanzessen
parents:
diff changeset
21 test = [mutationMatcher.match(x).groups() for x in fr3_data.split("|") if x]
b6f9a640e098 Uploaded
davidvanzessen
parents:
diff changeset
22 except:
b6f9a640e098 Uploaded
davidvanzessen
parents:
diff changeset
23 print(line_split[1])
b6f9a640e098 Uploaded
davidvanzessen
parents:
diff changeset
24 print("Something went wrong at line {line} with:".format(line=line_split[0]))
b6f9a640e098 Uploaded
davidvanzessen
parents:
diff changeset
25 #print([x for x in fr3_data.split("|") if not mutationMatcher.match(x)])
b6f9a640e098 Uploaded
davidvanzessen
parents:
diff changeset
26 if i % 100000 == 0:
b6f9a640e098 Uploaded
davidvanzessen
parents:
diff changeset
27 print(i)