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

« back to all changes in this revision

Viewing changes to source/TEST/SILACFiltering_test.C

  • Committer: Package Import Robot
  • Author(s): Filippo Rusconi
  • Date: 2012-11-12 15:58:12 UTC
  • Revision ID: package-import@ubuntu.com-20121112155812-vr15wtg9b50cuesg
Tags: upstream-1.9.0
ImportĀ upstreamĀ versionĀ 1.9.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- mode: C++; tab-width: 2; -*-
 
2
// vi: set ts=2:
 
3
//
 
4
// --------------------------------------------------------------------------
 
5
//                   OpenMS Mass Spectrometry Framework
 
6
// --------------------------------------------------------------------------
 
7
//  Copyright (C) 2003-2011 -- Oliver Kohlbacher, Knut Reinert
 
8
//
 
9
//  This library is free software; you can redistribute it and/or
 
10
//  modify it under the terms of the GNU Lesser General Public
 
11
//  License as published by the Free Software Foundation; either
 
12
//  version 2.1 of the License, or (at your option) any later version.
 
13
//
 
14
//  This library is distributed in the hope that it will be useful,
 
15
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
17
//  Lesser General Public License for more details.
 
18
//
 
19
//  You should have received a copy of the GNU Lesser General Public
 
20
//  License along with this library; if not, write to the Free Software
 
21
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
22
//
 
23
// --------------------------------------------------------------------------
 
24
// $Maintainer: Lars Nilse $
 
25
// $Authors: Lars Nilse, Holger Plattfaut $
 
26
// --------------------------------------------------------------------------
 
27
 
 
28
#include <OpenMS/CONCEPT/ClassTest.h>
 
29
 
 
30
#include <OpenMS/FILTERING/DATAREDUCTION/SILACFilter.h>
 
31
#include <OpenMS/FILTERING/DATAREDUCTION/SILACFiltering.h>
 
32
#include <OpenMS/FORMAT/MzMLFile.h>
 
33
#include <OpenMS/TRANSFORMATIONS/FEATUREFINDER/PeakWidthEstimator.h>
 
34
 
 
35
using namespace OpenMS;
 
36
using namespace std;
 
37
 
 
38
START_TEST(SILACFiltering, "$Id: SILACFiltering_test.C 9214 2011-11-21 16:54:37Z waldi $")
 
39
 
 
40
MSExperiment<> input;
 
41
MzMLFile().load(OPENMS_GET_TEST_DATA_PATH("SILACFiltering_test.mzML"), input);
 
42
const PeakWidthEstimator::Result peak_width(PeakWidthEstimator::estimateFWHM(input));
 
43
 
 
44
/////////////////////////////////////////////////////////////
 
45
/////////////////////////////////////////////////////////////
 
46
 
 
47
std::vector<DoubleReal> mass_separations;
 
48
mass_separations.push_back(8.0142);
 
49
SILACFiltering filtering(input, peak_width, 0);
 
50
SILACFilter filter(mass_separations, 2, 2, 3, 0, .9, false);
 
51
 
 
52
START_SECTION((SILACFiltering(MSExperiment< Peak1D > &exp, const PeakWidthEstimator::Result &, const DoubleReal intensity_cutoff, const String debug_filebase_="")))
 
53
{
 
54
  TEST_EQUAL(filtering.filters_.size(), 0);
 
55
  TEST_EQUAL(filtering.blacklist.size(), 0);
 
56
}
 
57
END_SECTION
 
58
 
 
59
START_SECTION((void addFilter(SILACFilter &filter)))
 
60
{
 
61
  filtering.addFilter(filter);
 
62
  TEST_EQUAL(filtering.filters_.size(), 1);
 
63
}
 
64
END_SECTION
 
65
 
 
66
START_SECTION((void filterDataPoints()))
 
67
{
 
68
  filtering.filterDataPoints();
 
69
  SILACFiltering::Filters::iterator filter_it = filtering.filters_.begin();
 
70
 
 
71
  std::vector<SILACPattern> &p = filter_it->getElements();
 
72
  TEST_EQUAL(p.size(), 3);
 
73
  TEST_REAL_SIMILAR(p[0].rt, 830);
 
74
  TEST_REAL_SIMILAR(p[0].mz, 670.84);
 
75
  TEST_REAL_SIMILAR(p[1].rt, 830);
 
76
  TEST_REAL_SIMILAR(p[1].mz, 670.84);
 
77
  TEST_REAL_SIMILAR(p[2].rt, 833);
 
78
  TEST_REAL_SIMILAR(p[2].mz, 670.84);
 
79
}
 
80
END_SECTION
 
81
 
 
82
START_SECTION([SILACFiltering::SpectrumInterpolation] SpectrumInterpolation(const MSSpectrum<> &, const SILACFiltering &))
 
83
  SILACFiltering::SpectrumInterpolation si(input[0], filtering);
 
84
END_SECTION
 
85
 
 
86
START_SECTION([SILACFiltering::SpectrumInterpolation] ~SpectrumInterpolation())
 
87
  SILACFiltering::SpectrumInterpolation si(input[0], filtering);
 
88
END_SECTION
 
89
 
 
90
START_SECTION([SILACFiltering::SpectrumInterpolation] DoubleReal operator()(DoubleReal mz) const)
 
91
  SILACFiltering::SpectrumInterpolation si(input[0], filtering);
 
92
  TEST_REAL_SIMILAR(si(670.5), 0)
 
93
  TEST_REAL_SIMILAR(si(671.1), 0)
 
94
END_SECTION
 
95
 
 
96
/////////////////////////////////////////////////////////////
 
97
/////////////////////////////////////////////////////////////
 
98
END_TEST
 
99