-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDatabaseXplorer.py
81 lines (62 loc) · 2.71 KB
/
DatabaseXplorer.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
"""
Author: Carolina Rojas Ramirez
Date: 11/09/2021
"""
from tkinter import filedialog
import pickle
from terminalFragmentor_Main import FragmentSite
from terminalFragmentor_Main import ThyIon
from InternalFragmentor_Main import interfrag
def internal_database():
"""
Function to explore .ions files that contain a terminal fragment database
:return:
"""
ions_file = filedialog.askopenfilename(title='Choose Ions File', filetypes=[('Theoretical Fragments', '.theofrags')])
with open(ions_file, 'rb') as picklefile:
saved_database = pickle.load(picklefile)
for analysis_num in saved_database:
count = 0
print(f"The analysis is {analysis_num} and the protein sequence is {saved_database[analysis_num][0]}")
print(f"The amount of passes are :{len(saved_database[analysis_num][1])}")
passes = saved_database[analysis_num][1]
for pass_label in passes:
print(pass_label)
for item in passes[pass_label]:
# print(item)
# print(len(item))
count+=len(item)
# for ion in item:
# print(ion)
print(count)
def terminal_database():
"""
Function to explore .ions files that contain a terminal fragment database
:return:
"""
ions_file = filedialog.askopenfilename(title='Choose Ions File', filetypes=[('Ions File', '.ions')])
with open(ions_file, 'rb') as picklefile:
saved_database = pickle.load(picklefile)
protein_seq = saved_database[0]
analysis_dict = saved_database[1]
# print(analysis_dict)
count_ions = 0
#Analysis
for analysis in analysis_dict:
# print(analysis)
# print(analysis_dict[analysis])
for analysis_pass in analysis_dict[analysis]:
# print(analysis_pass)
# print(analysis_dict[analysis][analysis_pass])
for site in analysis_dict[analysis][analysis_pass][1]:
# print(site)
fragsite = analysis_dict[analysis][analysis_pass][1][site]
# print(fragsite)
# print(fragsite.theo_ions)
for ion in fragsite.theo_ions:
# print(f"{fragsite.theo_ions[ion].mz_mono}_{fragsite.theo_ions[ion].charge}_{fragsite.theo_ions[ion].ion_type}{fragsite.theo_ions[ion].ion_type_indx}_{fragsite.theo_ions[ion].thy_mods}")
count_ions += 1
print(count_ions)
if __name__ == '__main__':
# terminal_database()
internal_database()