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