Mercurial > repos > recetox > recetox_aplcms_merge_known_table
annotate mzml_id_getter.py @ 9:17a48d0a80f4 draft
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b88eaca14b030fc0023989f3c83479e4975d172a
| author | recetox | 
|---|---|
| date | Thu, 01 Aug 2024 10:57:55 +0000 | 
| parents | 211f85249b1c | 
| children | 
| rev | line source | 
|---|---|
| 
0
 
211f85249b1c
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 | 
| 
 
211f85249b1c
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
 
recetox 
parents:  
diff
changeset
 | 
2 | 
| 
 
211f85249b1c
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
 
recetox 
parents:  
diff
changeset
 | 
3 import argparse | 
| 
 
211f85249b1c
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
 
recetox 
parents:  
diff
changeset
 | 
4 import sys | 
| 
 
211f85249b1c
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
 
recetox 
parents:  
diff
changeset
 | 
5 | 
| 
 
211f85249b1c
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 | 
| 
 
211f85249b1c
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
 
recetox 
parents:  
diff
changeset
 | 
7 | 
| 
 
211f85249b1c
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
 
recetox 
parents:  
diff
changeset
 | 
8 | 
| 
 
211f85249b1c
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
 
recetox 
parents:  
diff
changeset
 | 
9 def main(argv): | 
| 
 
211f85249b1c
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.') | 
| 
 
211f85249b1c
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.') | 
| 
 
211f85249b1c
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() | 
| 
 
211f85249b1c
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
 
recetox 
parents:  
diff
changeset
 | 
13 | 
| 
 
211f85249b1c
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) | 
| 
 
211f85249b1c
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'] | 
| 
 
211f85249b1c
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
 
recetox 
parents:  
diff
changeset
 | 
16 | 
| 
 
211f85249b1c
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: | 
| 
 
211f85249b1c
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: | 
| 
 
211f85249b1c
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
 
recetox 
parents:  
diff
changeset
 | 
19 f.write(id) | 
| 
 
211f85249b1c
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
 
recetox 
parents:  
diff
changeset
 | 
20 | 
| 
 
211f85249b1c
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
 
recetox 
parents:  
diff
changeset
 | 
21 | 
| 
 
211f85249b1c
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 506df2aef355b3791567283e1a175914f06b405a
 
recetox 
parents:  
diff
changeset
 | 
22 if __name__ == '__main__': | 
| 
 
211f85249b1c
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:]) | 
