-
Notifications
You must be signed in to change notification settings - Fork 0
/
pd_psm_parser.py
58 lines (56 loc) · 2.65 KB
/
pd_psm_parser.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
## Fetch column ids for the columns of interest to be used for
def get_dda_header_idx(infile):
for i in open(infile):
split_i = i.rstrip().split('\t')
if '"' in split_i[0]:
try:
seq = split_i.index('"Annotated Sequence"')
mod = split_i.index('"Modifications"')
charge = split_i.index('"Charge"')
rt = split_i.index('"RT [min]"')
mz = split_i.index('"m/z [Da]"')
pro = split_i.index('"Master Protein Accessions"')
scan = split_i.index('"First Scan"')
file = split_i.index('"Spectrum File"')
#searchid = split_i.index('"Search ID"')
return seq, mod, pro, charge, rt, mz, scan, file
break
except:
seq = split_i.index('"Sequence"')
mod = split_i.index('"Modifications"')
charge = split_i.index('"Charge"')
rt = split_i.index('"RT [min]"')
pro = split_i.index('"Master Protein Accessions"')
mz = split_i.index('"m/z [Da]"')
scan = split_i.index('"First Scan"')
file = split_i.index('"Spectrum File"')
#searchid = split_i.index('"Search ID"')
return seq, mod, pro, charge, rt, mz, scan, file
break
else:
try:
seq = split_i.index('Annotated Sequence')
mod = split_i.index('Modifications')
charge = split_i.index('Charge')
rt = split_i.index('RT [min]')
mz = split_i.index('m/z [Da]')
pro = split_i.index('Master Protein Accessions')
scan = split_i.index('First Scan')
file = split_i.index('Spectrum File')
#searchid = split_i.index('Search ID')
return seq, mod, pro, charge, rt, mz, scan, file
break
except:
seq = split_i.index('Sequence')
mod = split_i.index('Modifications')
charge = split_i.index('Charge')
rt = split_i.index('RT [min]')
mz = split_i.index('m/z [Da]')
pro = split_i.index('Master Protein Accessions')
scan = split_i.index('First Scan')
file = split_i.index('Spectrum File')
#searchid = split_i.index('Search ID')
return seq, mod, pro, charge, rt, mz, scan, file
break
if __name__== "__main__":
get_header_idx(args.infile[0])