Mercurial > repos > recetox > ipapy2_ms1_annotation
comparison ipapy2_MS2_annotation.py @ 0:7f84a8a5edde draft default tip
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
author | recetox |
---|---|
date | Fri, 16 May 2025 08:00:41 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:7f84a8a5edde |
---|---|
1 from ipaPy2 import ipa | |
2 from utils import flattern_annotations, MSArgumentParser | |
3 | |
4 | |
5 def main( | |
6 input_dataset_mapped_isotope_patterns, | |
7 input_dataset_MS2, | |
8 input_dataset_adducts, | |
9 input_dataset_MS2_DB, | |
10 ppm, | |
11 ratiosd, | |
12 ppmunk, | |
13 ratiounk, | |
14 ppmthr, | |
15 pRTNone, | |
16 pRTout, | |
17 mzdCS, | |
18 ppmCS, | |
19 CSunk, | |
20 evfilt, | |
21 output_dataset, | |
22 ncores, | |
23 ): | |
24 annotations = ipa.MSMSannotation( | |
25 input_dataset_mapped_isotope_patterns, | |
26 input_dataset_MS2, | |
27 input_dataset_adducts, | |
28 input_dataset_MS2_DB, | |
29 ppm=ppm, | |
30 ratiosd=ratiosd, | |
31 ppmunk=ppmunk, | |
32 ratiounk=ratiounk, | |
33 ppmthr=ppmthr, | |
34 pRTNone=pRTNone, | |
35 pRTout=pRTout, | |
36 mzdCS=mzdCS, | |
37 ppmCS=ppmCS, | |
38 CSunk=CSunk, | |
39 evfilt=evfilt, | |
40 ncores=ncores, | |
41 ) | |
42 annotations_flat = flattern_annotations(annotations) | |
43 write_func, file_path = output_dataset | |
44 write_func(annotations_flat, file_path) | |
45 | |
46 | |
47 if __name__ == "__main__": | |
48 parser = MSArgumentParser( | |
49 """Annotation of the dataset base on the MS1 and MS2 information. Prior | |
50 probabilities are based on mass only, while post probabilities are based | |
51 on mass, RT, previous knowledge and isotope patterns.""" | |
52 ) | |
53 parser.add_argument( | |
54 "--input_dataset_mapped_isotope_patterns", | |
55 nargs=2, | |
56 action="load_data", | |
57 required=True, | |
58 help=( | |
59 "A dataset containing the MS1 data. Ideally obtained from" | |
60 " map_isotope_patterns" | |
61 ), | |
62 ) | |
63 parser.add_argument( | |
64 "--input_dataset_MS2", | |
65 nargs=2, | |
66 action="load_data", | |
67 required=True, | |
68 help="A dataset containing the MS2 fragmentation data", | |
69 ) | |
70 parser.add_argument( | |
71 "--input_dataset_adducts", | |
72 nargs=2, | |
73 action="load_data", | |
74 required=True, | |
75 help=( | |
76 "A dataset containing the information on all the possible adducts given the" | |
77 " database. Ideally obtained from compute_all_adducts" | |
78 ), | |
79 ) | |
80 parser.add_argument( | |
81 "--input_dataset_MS2_DB", | |
82 nargs=2, | |
83 action="load_data", | |
84 required=True, | |
85 help="A dataset containing the MS2 database", | |
86 ) | |
87 parser.add_argument( | |
88 "--mzdCS", | |
89 type=int, | |
90 default=0, | |
91 help="""maximum mz difference allowed when computing cosine similarity | |
92 scores. If one wants to use this parameter instead of ppmCS, this | |
93 must be set to 0. Default 0.""", | |
94 ) | |
95 parser.add_argument( | |
96 "--ppmCS", | |
97 type=int, | |
98 default=10, | |
99 help="""maximum ppm allowed when computing cosine similarity scores. | |
100 If one wants to use this parameter instead of mzdCS, this must be | |
101 set to 0. Default 10.""", | |
102 ) | |
103 parser.add_argument( | |
104 "--CSunk", | |
105 type=float, | |
106 default=0.7, | |
107 help="""cosine similarity score associated with the 'unknown' annotation. | |
108 Default 0.7""", | |
109 ) | |
110 parser.add_argument( | |
111 "--evfilt", | |
112 type=bool, | |
113 default=False, | |
114 help="""Default value False. If true, only spectrum acquired with the same | |
115 collision energy are considered.""", | |
116 ) | |
117 args = parser.parse_args() | |
118 main( | |
119 args.input_dataset_mapped_isotope_patterns, | |
120 args.input_dataset_MS2, | |
121 args.input_dataset_adducts, | |
122 args.input_dataset_MS2_DB, | |
123 args.ppm, | |
124 args.ratiosd, | |
125 args.ppmunk, | |
126 args.ratiounk, | |
127 args.ppmthr, | |
128 args.pRTNone, | |
129 args.pRTout, | |
130 args.mzdCS, | |
131 args.ppmCS, | |
132 args.CSunk, | |
133 args.evfilt, | |
134 args.output_dataset, | |
135 args.ncores, | |
136 ) |