Mercurial > repos > recetox > ipapy2_ms2_annotation
comparison ipapy2_compute_bio.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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:6a23970e8093 |
---|---|
1 from ipaPy2 import ipa | |
2 from utils import CustomArgumentParser, group_by_peak_id | |
3 | |
4 | |
5 def main( | |
6 input_dataset_database, | |
7 input_dataset_annotations, | |
8 biochemical_mode, | |
9 connection_list, | |
10 output_dataset, | |
11 ncores, | |
12 ): | |
13 """ | |
14 Compute matrix of biochemical connections. Either based on a list of | |
15 possible connections in the form of a list of formulas or based on the | |
16 reactions present in the database. | |
17 """ | |
18 | |
19 if input_dataset_annotations is not None: | |
20 annotations = group_by_peak_id(input_dataset_annotations) | |
21 else: | |
22 annotations = None | |
23 | |
24 if biochemical_mode == "connections" and connection_list: | |
25 connections = connection_list.split(",") | |
26 else: | |
27 connections = [] | |
28 | |
29 Bio = ipa.Compute_Bio( | |
30 input_dataset_database, | |
31 annotations=annotations, | |
32 mode=biochemical_mode, | |
33 connections=connections, | |
34 ncores=ncores, | |
35 ) | |
36 write_func, file_path = output_dataset | |
37 write_func(Bio, file_path) | |
38 | |
39 | |
40 if __name__ == "__main__": | |
41 parser = CustomArgumentParser( | |
42 description=""" Compute matrix of biochemical connections. Either based on a list of | |
43 possible connections in the form of a list of formulas or based on the | |
44 reactions present in the database.""" | |
45 ) | |
46 parser.add_argument( | |
47 "--input_dataset_database", | |
48 nargs=2, | |
49 action="load_data", | |
50 required=True, | |
51 help=( | |
52 "a datset containing the database against which the annotationis performed." | |
53 ), | |
54 ) | |
55 parser.add_argument( | |
56 "--input_dataset_annotations", | |
57 nargs=2, | |
58 action="load_data", | |
59 help="a datset containing the annotations of the features.", | |
60 ) | |
61 parser.add_argument( | |
62 "--biochemical_mode", | |
63 type=str, | |
64 required=True, | |
65 help="""either 'reactions' (connections are computed based on the reactions | |
66 present in the database) or 'connections' (connections are computed | |
67 based on the list of connections provided). Default 'reactions'. """, | |
68 ) | |
69 parser.add_argument( | |
70 "--connection_list", type=str, help="list of connections" | |
71 ) | |
72 parser.add_argument( | |
73 "--ncores", | |
74 type=int, | |
75 default=None, | |
76 help="number of cores to use for the computation.", | |
77 ) | |
78 args = parser.parse_args() | |
79 | |
80 main( | |
81 args.input_dataset_database, | |
82 args.input_dataset_annotations, | |
83 args.biochemical_mode, | |
84 args.connection_list, | |
85 args.output_dataset, | |
86 args.ncores, | |
87 ) |