Mercurial > repos > recetox > ipapy2_gibbs_sampler_add
annotate ipapy2_gibbs_sampler_add.py @ 0:428abc41a101 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:46 +0000 | 
| parents | |
| children | 
| rev | line source | 
|---|---|
| 
0
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
1 from ipaPy2 import ipa | 
| 
 
428abc41a101
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, GibbsArgumentParser, group_by_peak_id | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
3 | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
4 | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
5 def main( | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
6 mapped_isotope_patterns, | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
7 annotations_df, | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
8 noits, | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
9 burn, | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
10 delta_add, | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
11 all_out, | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
12 zs, | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
13 zs_out, | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
14 output_dataset, | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
15 ): | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
16 df = mapped_isotope_patterns | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
17 | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
18 annotations_df = annotations_df | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
19 annotations_df["post"] = annotations_df["post"].replace("", 0) | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
20 annotations_df = annotations_df.replace("", None) | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
21 annotations = group_by_peak_id(annotations_df) | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
22 | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
23 if not zs: | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
24 zs = None | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
25 | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
26 zs = ipa.Gibbs_sampler_add( | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
27 df, | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
28 annotations, | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
29 noits=noits, | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
30 burn=burn, | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
31 delta_add=delta_add, | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
32 all_out=all_out, | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
33 zs=zs, | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
34 ) | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
35 | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
36 annotations_flat = flattern_annotations(annotations) | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
37 write_func, file_path = output_dataset | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
38 write_func(annotations_flat, file_path) | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
39 | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
40 if all_out: | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
41 write_func, file_path = zs_out | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
42 write_func(zs, file_path) | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
43 | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
44 | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
45 if __name__ == "__main__": | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
46 parser = GibbsArgumentParser(description="cluster features before IPA pipeline.") | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
47 parser.add_argument( | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
48 "--input_dataset_mapped_isotope_patterns", | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
49 nargs=2, | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
50 action="load_data", | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
51 required=True, | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
52 help=( | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
53 "A dataset containing the MS1 data. Ideally obtained from" | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
54 " map_isotope_patterns" | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
55 ), | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
56 ) | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
57 parser.add_argument( | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
58 "--input_dataset_annotations", | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
59 nargs=2, | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
60 action="load_data", | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
61 required=True, | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
62 help="a datset containing the annotations of the features.", | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
63 ) | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
64 | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
65 args = parser.parse_args() | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
66 main( | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
67 args.input_dataset_mapped_isotope_patterns, | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
68 args.input_dataset_annotations, | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
69 args.noits, | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
70 args.burn, | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
71 args.delta_add, | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
72 args.all_out, | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
73 args.zs, | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
74 args.zs_out, | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
75 args.output_dataset, | 
| 
 
428abc41a101
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2 commit 64b61ff2823b4f54868c0ab7a4c0dc49eaf2979a
 
recetox 
parents:  
diff
changeset
 | 
76 ) | 
