MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / test0

Function test0

src/pyOpenMS/tests/unittests/test_MzXMLConsumer.py:6–38  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4from .collections_ import Counter
5
6def test0():
7 fh = pyopenms.MzXMLFile()
8 here = os.path.dirname(os.path.abspath(__file__))
9 path = os.path.join(here, "test2.mzXML").encode()
10
11 class Consumer(object):
12
13 def __init__(self):
14 self.speclevels = []
15 self.rts = []
16
17 def consumeSpectrum(self, spec):
18 self.speclevels.append(spec.getMSLevel())
19 self.rts.append(spec.getRT())
20
21 def consumeChromatogram(self, chromo):
22 raise Exception("should never be called as we have no chromoatograms in example file")
23
24 def setExpectedSize(self, num_specs, num_chromo):
25 assert num_specs == 5, num_specs
26 assert num_chromo == 0, num_chromo
27
28 def setExperimentalSettings(self, exp):
29 assert isinstance(exp, pyopenms.ExperimentalSettings)
30
31 consumer = Consumer()
32 fh.transform(path, consumer)
33 cc = Counter(consumer.speclevels)
34 assert set(cc.keys()) == set([1, 2])
35 assert cc[1] == 2
36 assert cc[2] == 3
37 assert abs(min(consumer.rts) - 4200.76) < 0.01
38 assert abs(max(consumer.rts) - 4202.03) < 0.01

Callers

nothing calls this directly

Calls 5

transformMethod · 0.95
MzXMLFileMethod · 0.80
encodeMethod · 0.80
ConsumerClass · 0.70
CounterClass · 0.70

Tested by

no test coverage detected