Mercurial > repos > iuc > mzmine_batch
comparison set_path.py @ 1:90d60c9da21e draft default tip
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/blob/master/tools/mzmine/ commit 889d26f1e96edf1f2608ce0dba2d66e8ee60e313
| author | iuc |
|---|---|
| date | Fri, 10 Nov 2023 14:20:45 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:02e802817d48 | 1:90d60c9da21e |
|---|---|
| 1 import argparse | |
| 2 import re | |
| 3 import sys | |
| 4 from xml.etree import ElementTree | |
| 5 | |
| 6 parser = argparse.ArgumentParser( | |
| 7 prog="set_path.py", description="update paths in mzmine batch XML" | |
| 8 ) | |
| 9 parser.add_argument("--input", help="input XML") | |
| 10 parser.add_argument("--output", help="output XML") | |
| 11 parser.add_argument("--localdb", required=False, help="Local CVS DB for Search") | |
| 12 args = parser.parse_args() | |
| 13 | |
| 14 PATHSEP = re.compile(r"[/\\]") | |
| 15 tree = ElementTree.parse(args.input) | |
| 16 | |
| 17 for batchstep in tree.findall(".//batchstep"): | |
| 18 method = batchstep.attrib.get("method") | |
| 19 for current_file in batchstep.findall(".//current_file"): | |
| 20 if ( | |
| 21 method | |
| 22 == "io.github.mzmine.modules.dataprocessing.id_localcsvsearch.LocalCSVDatabaseSearchModule" | |
| 23 ): | |
| 24 if args.localdb: | |
| 25 current_file.text = args.localdb | |
| 26 else: | |
| 27 sys.exit("Batch file contains LocalCSVDatabaseSearchModule but no local DB CSV file given") | |
| 28 else: | |
| 29 current_file.text = f"./output/{PATHSEP.split(current_file.text)[-1]}" | |
| 30 | |
| 31 tree.write(args.output) |
