annotate hardklor.py @ 6:73fc27617b2e draft default tip

"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit 44c3e37a12f60b01521d3e3f18b7f16664f954cc"
author galaxyp
date Tue, 07 Apr 2020 03:27:32 -0400
parents d796e6613d19
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
1 """
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
2 Usage:
d796e6613d19 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
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
4 ms2file outputfile
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
5 """
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
6 import sys
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
7 import os
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
8 import subprocess
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
9
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
10
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
11 CONFIG_FILE = 'hk.conf'
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
12 extension_lookup = {
6
73fc27617b2e "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit 44c3e37a12f60b01521d3e3f18b7f16664f954cc"
galaxyp
parents: 0
diff changeset
13 'mzml': 'mzML',
73fc27617b2e "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit 44c3e37a12f60b01521d3e3f18b7f16664f954cc"
galaxyp
parents: 0
diff changeset
14 'mzxml': 'mzXML',
73fc27617b2e "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit 44c3e37a12f60b01521d3e3f18b7f16664f954cc"
galaxyp
parents: 0
diff changeset
15 'ms1': 'MS1',
73fc27617b2e "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit 44c3e37a12f60b01521d3e3f18b7f16664f954cc"
galaxyp
parents: 0
diff changeset
16 }
0
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
17
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
18 # input:
d796e6613d19 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]
d796e6613d19 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]
d796e6613d19 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]
d796e6613d19 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')
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
23
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
24 # parse options
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
25 options = {}
d796e6613d19 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:]]:
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
27 if arg[1] != '':
d796e6613d19 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]
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
29
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
30
d796e6613d19 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
d796e6613d19 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:
d796e6613d19 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]
d796e6613d19 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)
d796e6613d19 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
73fc27617b2e "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit 44c3e37a12f60b01521d3e3f18b7f16664f954cc"
galaxyp
parents: 0
diff changeset
36 ms1_file = linkname
0
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
37
d796e6613d19 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
d796e6613d19 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:
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
40 config_str = fp.read()
d796e6613d19 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(
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
42 instrument=options['instrument'],
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
43 resolution=options['resolution'],
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
44 centroided=options['centroided'],
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
45 mslvl=options['mslvl'],
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
46 depth=options['depth'],
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
47 algorithm=options['algorithm'],
d796e6613d19 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'],
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
49 mincharge=options['mincharge'],
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
50 maxcharge=options['maxcharge'],
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
51 correlation=options['correlation'],
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
52 sensitivity=options['sensitivity'],
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
53 maxfeat=options['maxfeat'],
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
54 inputfile=ms1_file,
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
55 outputfile=output_file,
6
73fc27617b2e "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit 44c3e37a12f60b01521d3e3f18b7f16664f954cc"
galaxyp
parents: 0
diff changeset
56 )
0
d796e6613d19 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:
d796e6613d19 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)
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
59
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
60 # Run hardklor
d796e6613d19 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])
d796e6613d19 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/hardklor commit f37e6d0357de4d9b1cd743ca291a7d4df2cc7a5f-dirty
galaxyp
parents:
diff changeset
62 sys.exit(err)