annotate ipapy2_MS1_annotation.py @ 0:6a23970e8093 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:01:15 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
1 from ipaPy2 import ipa
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
2 from utils import flattern_annotations, MSArgumentParser
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
3
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
4
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
5 def main(
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
6 input_dataset_database,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
7 input_dataset_adduct,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
8 ppm,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
9 ratiosd,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
10 ppmunk,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
11 ratiounk,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
12 ppmthr,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
13 pRTNone,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
14 pRTout,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
15 output_dataset,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
16 ncores,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
17 ):
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
18 write_func, file_path = output_dataset
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
19
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
20 annotations = ipa.MS1annotation(
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
21 input_dataset_database,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
22 input_dataset_adduct,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
23 ppm=ppm,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
24 ratiosd=ratiosd,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
25 ppmunk=ppmunk,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
26 ratiounk=ratiounk,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
27 ppmthr=ppmthr,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
28 pRTNone=pRTNone,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
29 pRTout=pRTout,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
30 ncores=ncores,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
31 )
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
32 annotations_flat = flattern_annotations(annotations)
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
33 write_func(annotations_flat, file_path)
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
34
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
35
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
36 if __name__ == "__main__":
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
37 parser = MSArgumentParser("""
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
38 Annotation of the dataset based on the MS1 information. Prior probabilities
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
39 are based on mass only, while post probabilities are based on mass, RT,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
40 previous knowledge and isotope patterns.
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
41 """)
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
42 parser.add_argument(
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
43 "--input_dataset_database",
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
44 nargs=2,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
45 action="load_data",
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
46 required=True,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
47 help=(
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
48 "A dataset containing the MS1 data. Ideally obtained from"
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
49 " map_isotope_patterns"
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
50 ),
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
51 )
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
52 parser.add_argument(
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
53 "--input_dataset_adducts",
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
54 nargs=2,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
55 action="load_data",
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
56 required=True,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
57 help="A dataset containing information on all possible adducts.",
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
58 )
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
59
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
60 args = parser.parse_args()
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
61 main(
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
62 args.input_dataset_database,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
63 args.input_dataset_adducts,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
64 args.ppm,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
65 args.ratiosd,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
66 args.ppmunk,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
67 args.ratiounk,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
68 args.ppmthr,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
69 args.pRTNone,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
70 args.pRTout,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
71 args.output_dataset,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
72 args.ncores,
6a23970e8093 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
recetox
parents:
diff changeset
73 )