~ubuntu-branches/ubuntu/wily/openms/wily

« back to all changes in this revision

Viewing changes to pyOpenMS/tests/unittests/test_Smoothing.py

  • Committer: Package Import Robot
  • Author(s): Filippo Rusconi
  • Date: 2013-12-20 11:30:16 UTC
  • mfrom: (5.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20131220113016-wre5g9bteeheq6he
Tags: 1.11.1-3
* remove version number from libbost development package names;
* ensure that AUTHORS is correctly shipped in all packages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import unittest
 
2
import os
 
3
 
 
4
import pyopenms
 
5
 
 
6
class TestGaussFilter(unittest.TestCase):
 
7
 
 
8
    def setUp(self):
 
9
        dirname = os.path.dirname(os.path.abspath(__file__))
 
10
        self.filename = os.path.join(dirname, "test2.mzML")
 
11
        self.exp = pyopenms.MSExperiment()
 
12
        pyopenms.MzMLFile().load(self.filename, self.exp)
 
13
 
 
14
    def test_init(self):
 
15
        thisfilter = pyopenms.GaussFilter();
 
16
 
 
17
    def test_run(self):
 
18
        thisfilter = pyopenms.GaussFilter();
 
19
        old_firstspec = self.exp[0]
 
20
        thisfilter.filterExperiment(self.exp)
 
21
 
 
22
        self.assertNotEqual(self.exp.size(), 0)
 
23
        self.assertNotEqual(old_firstspec, self.exp[0])
 
24
 
 
25
        # MZ should not change, Intensity should
 
26
        self.assertEqual(old_firstspec[10].getMZ(), self.exp[0][10].getMZ())
 
27
        self.assertNotEqual(old_firstspec[10].getIntensity(), self.exp[0][10].getIntensity())
 
28
 
 
29
class TestSavitzkyGolayFilter(unittest.TestCase):
 
30
 
 
31
    def setUp(self):
 
32
        dirname = os.path.dirname(os.path.abspath(__file__))
 
33
        self.filename = os.path.join(dirname, "test2.mzML")
 
34
        self.exp = pyopenms.MSExperiment()
 
35
        pyopenms.MzMLFile().load(self.filename, self.exp)
 
36
 
 
37
    def test_init(self):
 
38
        thisfilter = pyopenms.SavitzkyGolayFilter();
 
39
 
 
40
    def test_run(self):
 
41
        thisfilter = pyopenms.SavitzkyGolayFilter();
 
42
        old_firstspec = self.exp[0]
 
43
        thisfilter.filterExperiment(self.exp)
 
44
 
 
45
        self.assertNotEqual(self.exp.size(), 0)
 
46
        self.assertNotEqual(old_firstspec, self.exp[0])
 
47
 
 
48
        # MZ should not change, Intensity should
 
49
        self.assertEqual(old_firstspec[10].getMZ(), self.exp[0][10].getMZ())
 
50
        self.assertNotEqual(old_firstspec[10].getIntensity(), self.exp[0][10].getIntensity())
 
51
 
 
52
class TestLowessSmoothing(unittest.TestCase):
 
53
 
 
54
    def setUp(self):
 
55
        pass
 
56
 
 
57
    def test_init(self):
 
58
        thisfilter = pyopenms.LowessSmoothing();
 
59
 
 
60
    def test_init(self):
 
61
        thisfilter = pyopenms.LowessSmoothing();
 
62
        x = [1.0,2.0,3.0,4.0]
 
63
        y = [10.0,11.0,12.0,13.0]
 
64
        y_smoothed = [0.0]
 
65
        thisfilter.smoothData(x,y,y_smoothed)
 
66
 
 
67
        self.assertNotEqual( len(y_smoothed), 0)
 
68
 
 
69
        # The smoothed data should be different from the input data
 
70
        self.assertNotEqual( y_smoothed, y)
 
71
        self.assertNotEqual( y_smoothed[0], y[0])
 
72
 
 
73
if __name__ == '__main__':
 
74
    unittest.main()