annotate hardklor.py @ 6:f416698530c3 draft default tip

"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit 44c3e37a12f60b01521d3e3f18b7f16664f954cc"
author galaxyp
date Tue, 07 Apr 2020 07:22:58 +0000
parents b192c8c3e77e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
1 """
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
2 Usage:
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
3 python hardklor.py ms1extenstion ms2extension ms1file
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
4 ms2file outputfile
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
5 """
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
6 import sys
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
7 import os
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
8 import subprocess
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
9
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
10
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
11 CONFIG_FILE = 'hk.conf'
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
12 extension_lookup = {
6
f416698530c3 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit 44c3e37a12f60b01521d3e3f18b7f16664f954cc"
galaxyp
parents: 0
diff changeset
13 'mzml': 'mzML',
f416698530c3 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit 44c3e37a12f60b01521d3e3f18b7f16664f954cc"
galaxyp
parents: 0
diff changeset
14 'mzxml': 'mzXML',
f416698530c3 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit 44c3e37a12f60b01521d3e3f18b7f16664f954cc"
galaxyp
parents: 0
diff changeset
15 'ms1': 'MS1',
f416698530c3 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit 44c3e37a12f60b01521d3e3f18b7f16664f954cc"
galaxyp
parents: 0
diff changeset
16 }
0
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
17
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
18 # input:
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
19 ms1_ext = sys.argv[1]
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
20 ms1_file = sys.argv[2]
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
21 output_file = sys.argv[3]
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
22 config_load = os.path.join(os.path.split(sys.argv[0])[0], 'hardklor.conf')
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
23
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
24 # parse options
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
25 options = {}
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
26 for arg in [x.split('=') for x in sys.argv[4:]]:
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
27 if arg[1] != '':
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
28 options[arg[0].replace('-', '')] = arg[1]
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
29
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
30
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
31 # create softlinks since hardklor needs "proper" extensions for input files
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
32 if ms1_ext in extension_lookup:
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
33 ms1_ext = extension_lookup[ms1_ext]
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
34 linkname = 'ms1_dsetlink.{0}'.format(ms1_ext)
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
35 os.symlink(ms1_file, linkname)
6
f416698530c3 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit 44c3e37a12f60b01521d3e3f18b7f16664f954cc"
galaxyp
parents: 0
diff changeset
36 ms1_file = linkname
0
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
37
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
38 # load template and dump to config file
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
39 with open(config_load) as fp:
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
40 config_str = fp.read()
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
41 config_to_dump = config_str.format(
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
42 instrument=options['instrument'],
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
43 resolution=options['resolution'],
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
44 centroided=options['centroided'],
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
45 mslvl=options['mslvl'],
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
46 depth=options['depth'],
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
47 algorithm=options['algorithm'],
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
48 charge_algo=options['charge_algo'],
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
49 mincharge=options['mincharge'],
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
50 maxcharge=options['maxcharge'],
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
51 correlation=options['correlation'],
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
52 sensitivity=options['sensitivity'],
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
53 maxfeat=options['maxfeat'],
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
54 inputfile=ms1_file,
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
55 outputfile=output_file,
6
f416698530c3 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit 44c3e37a12f60b01521d3e3f18b7f16664f954cc"
galaxyp
parents: 0
diff changeset
56 )
0
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
57 with open(CONFIG_FILE, 'w') as fp:
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
58 fp.write(config_to_dump)
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
59
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
60 # Run hardklor
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
61 err = subprocess.call(['hardklor', CONFIG_FILE])
b192c8c3e77e planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
62 sys.exit(err)