Mercurial > repos > recetox > recetox_aplcms_align_features
annotate mzml_id_getter.py @ 14:ec196e27a61a draft default tip
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 5da5b5e8b95d93a24424155e5aebfbd337d2c4b6
author | recetox |
---|---|
date | Thu, 31 Oct 2024 11:23:30 +0000 |
parents | abe783e0daca |
children |
rev | line source |
---|---|
2
abe783e0daca
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff
changeset
|
1 #!/usr/bin/env python |
abe783e0daca
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff
changeset
|
2 |
abe783e0daca
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff
changeset
|
3 import argparse |
abe783e0daca
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff
changeset
|
4 import sys |
abe783e0daca
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff
changeset
|
5 |
abe783e0daca
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff
changeset
|
6 from pymzml.run import Reader |
abe783e0daca
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff
changeset
|
7 |
abe783e0daca
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff
changeset
|
8 |
abe783e0daca
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff
changeset
|
9 def main(argv): |
abe783e0daca
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff
changeset
|
10 parser = argparse.ArgumentParser(description='Get run ID from an mzML file.') |
abe783e0daca
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff
changeset
|
11 parser.add_argument('mzml_file', help='Path to an mzML file to get run ID from.') |
abe783e0daca
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff
changeset
|
12 args = parser.parse_args() |
abe783e0daca
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff
changeset
|
13 |
abe783e0daca
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff
changeset
|
14 mzml = Reader(args.mzml_file) |
abe783e0daca
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff
changeset
|
15 id = mzml.info['run_id'] |
abe783e0daca
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff
changeset
|
16 |
abe783e0daca
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff
changeset
|
17 if id is not None: |
abe783e0daca
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff
changeset
|
18 with open("sample_name.txt", mode='x') as f: |
abe783e0daca
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff
changeset
|
19 f.write(id) |
abe783e0daca
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff
changeset
|
20 |
abe783e0daca
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff
changeset
|
21 |
abe783e0daca
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff
changeset
|
22 if __name__ == '__main__': |
abe783e0daca
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff
changeset
|
23 main(sys.argv[1:]) |