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