annotate mzml_id_getter.py @ 1:7b0bf5d403ba draft

planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 4254c6f6f05915ceab5af5d7040ac2c44a8364b4
author recetox
date Mon, 03 Apr 2023 14:56:27 +0000
parents 4d7db9cdd952
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
4d7db9cdd952 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
4d7db9cdd952 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff changeset
2
4d7db9cdd952 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff changeset
3 import argparse
4d7db9cdd952 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff changeset
4 import sys
4d7db9cdd952 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff changeset
5
4d7db9cdd952 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
4d7db9cdd952 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff changeset
7
4d7db9cdd952 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff changeset
8
4d7db9cdd952 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff changeset
9 def main(argv):
4d7db9cdd952 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.')
4d7db9cdd952 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.')
4d7db9cdd952 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()
4d7db9cdd952 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff changeset
13
4d7db9cdd952 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)
4d7db9cdd952 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']
4d7db9cdd952 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff changeset
16
4d7db9cdd952 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:
4d7db9cdd952 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:
4d7db9cdd952 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff changeset
19 f.write(id)
4d7db9cdd952 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff changeset
20
4d7db9cdd952 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff changeset
21
4d7db9cdd952 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
recetox
parents:
diff changeset
22 if __name__ == '__main__':
4d7db9cdd952 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:])