-
-
Notifications
You must be signed in to change notification settings - Fork 307
/
FeatureFinderCentroided.py
103 lines (79 loc) · 3.1 KB
/
FeatureFinderCentroided.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import argparse
import pyopenms as pms
from common import addDataProcessing, writeParamsIfRequested, updateDefaults
def run_featurefinder_centroided(input_path, params, seeds, out_path):
fh = pms.MzMLFile()
options = pms.PeakFileOptions()
options.setMSLevels([1,1])
fh.setOptions(options)
input_map = pms.MSExperiment()
fh.load(input_path, input_map)
input_map.updateRanges()
ff = pms.FeatureFinder()
ff.setLogType(pms.LogType.CMD)
features = pms.FeatureMap()
name = pms.FeatureFinderAlgorithmPicked.getProductName()
ff.run(name, input_map, features, params, seeds)
features.setUniqueIds()
addDataProcessing(features, params, pms.ProcessingAction.QUANTITATION)
fh = pms.FeatureXMLFile()
fh.store(out_path, features)
def main():
parser = argparse.ArgumentParser(description="FeatureFinderCentroided")
parser.add_argument("-in",
action="store",
type=str,
dest="in_",
metavar="input_file",
)
parser.add_argument("-seeds",
action="store",
type=str,
metavar="seeds_file",
)
parser.add_argument("-out",
action="store",
type=str,
metavar="output_file",
)
parser.add_argument("-ini",
action="store",
type=str,
metavar="ini_file",
)
parser.add_argument("-dict_ini",
action="store",
type=str,
metavar="python_dict_ini_file",
)
parser.add_argument("-write_ini",
action="store",
type=str,
metavar="ini_file",
)
parser.add_argument("-write_dict_ini",
action="store",
type=str,
metavar="python_dict_ini_file",
)
args = parser.parse_args()
run_mode = args.in_ is not None and args.out is not None\
and (args.ini is not None or args.dict_ini is not None)
write_mode = args.write_ini is not None or args.write_dict_ini is not None
ok = run_mode or write_mode
if not ok:
parser.error("either specify -in, -out and -(dict)ini for running "
"the peakpicker\nor -write(dict)ini for creating std "
"ini file")
name = pms.FeatureFinderAlgorithmPicked.getProductName()
defaults = pms.FeatureFinder().getParameters(name)
write_requested = writeParamsIfRequested(args, defaults)
if not write_requested:
updateDefaults(args, defaults)
seeds = pms.FeatureMap()
if args.seeds:
fh = pms.FeatureXMLFile()
fh.load(args.seeds, seeds)
run_featurefinder_centroided(args.in_, defaults, seeds, args.out)
if __name__ == "__main__":
main()