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

« back to all changes in this revision

Viewing changes to source/TEST/ItraqFourPlexQuantitationMethod_test.C

  • 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
// --------------------------------------------------------------------------
 
2
//                   OpenMS -- Open-Source Mass Spectrometry               
 
3
// --------------------------------------------------------------------------
 
4
// Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
 
5
// ETH Zurich, and Freie Universitaet Berlin 2002-2013.
 
6
// 
 
7
// This software is released under a three-clause BSD license:
 
8
//  * Redistributions of source code must retain the above copyright
 
9
//    notice, this list of conditions and the following disclaimer.
 
10
//  * Redistributions in binary form must reproduce the above copyright
 
11
//    notice, this list of conditions and the following disclaimer in the
 
12
//    documentation and/or other materials provided with the distribution.
 
13
//  * Neither the name of any author or any participating institution 
 
14
//    may be used to endorse or promote products derived from this software 
 
15
//    without specific prior written permission.
 
16
// For a full list of authors, refer to the file AUTHORS. 
 
17
// --------------------------------------------------------------------------
 
18
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 
19
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
20
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
21
// ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING 
 
22
// INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
 
23
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
 
24
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
 
25
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
 
26
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
 
27
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
 
28
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
29
// 
 
30
// --------------------------------------------------------------------------
 
31
// $Maintainer: Stephan Aiche$
 
32
// $Authors: Stephan Aiche$
 
33
// --------------------------------------------------------------------------
 
34
 
 
35
#include <OpenMS/CONCEPT/ClassTest.h>
 
36
 
 
37
///////////////////////////
 
38
#include <OpenMS/ANALYSIS/QUANTITATION/ItraqFourPlexQuantitationMethod.h>
 
39
///////////////////////////
 
40
 
 
41
using namespace OpenMS;
 
42
using namespace std;
 
43
 
 
44
START_TEST(ItraqFourPlexQuantitationMethod, "$Id: ItraqFourPlexQuantitationMethod_test.C 11266 2013-05-21 08:12:56Z aiche $")
 
45
 
 
46
/////////////////////////////////////////////////////////////
 
47
/////////////////////////////////////////////////////////////
 
48
 
 
49
ItraqFourPlexQuantitationMethod* ptr = 0;
 
50
ItraqFourPlexQuantitationMethod* null_ptr = 0;
 
51
START_SECTION(ItraqFourPlexQuantitationMethod())
 
52
{
 
53
        ptr = new ItraqFourPlexQuantitationMethod();
 
54
        TEST_NOT_EQUAL(ptr, null_ptr)
 
55
}
 
56
END_SECTION
 
57
 
 
58
START_SECTION(~ItraqFourPlexQuantitationMethod())
 
59
{
 
60
        delete ptr;
 
61
}
 
62
END_SECTION
 
63
 
 
64
START_SECTION((const String& getName() const ))
 
65
{
 
66
  ItraqFourPlexQuantitationMethod quant_meth;
 
67
  TEST_STRING_EQUAL(quant_meth.getName(), "itraq4plex") 
 
68
}
 
69
END_SECTION
 
70
    
 
71
START_SECTION((ItraqFourPlexQuantitationMethod(const ItraqFourPlexQuantitationMethod &other)))
 
72
{
 
73
  ItraqFourPlexQuantitationMethod qm;
 
74
  Param p = qm.getParameters();
 
75
  p.setValue("channel_114_description", "new_description");
 
76
  p.setValue("reference_channel", 116);
 
77
  qm.setParameters(p);
 
78
  
 
79
  ItraqFourPlexQuantitationMethod qm2(qm);
 
80
  IsobaricQuantitationMethod::IsobaricChannelList channel_list = qm2.getChannelInformation();
 
81
  TEST_STRING_EQUAL(channel_list[0].description, "new_description")
 
82
  TEST_EQUAL(qm2.getReferenceChannel(), 2)    
 
83
}
 
84
END_SECTION
 
85
 
 
86
START_SECTION((ItraqFourPlexQuantitationMethod& operator=(const ItraqFourPlexQuantitationMethod &rhs)))
 
87
{
 
88
  ItraqFourPlexQuantitationMethod qm;
 
89
  Param p = qm.getParameters();
 
90
  p.setValue("channel_114_description", "new_description");
 
91
  p.setValue("reference_channel", 116);
 
92
  qm.setParameters(p);
 
93
  
 
94
  ItraqFourPlexQuantitationMethod qm2;
 
95
  qm2 = qm;
 
96
  IsobaricQuantitationMethod::IsobaricChannelList channel_list = qm2.getChannelInformation();
 
97
  TEST_STRING_EQUAL(channel_list[0].description, "new_description")
 
98
  TEST_EQUAL(qm2.getReferenceChannel(), 2)
 
99
}
 
100
END_SECTION
 
101
 
 
102
 
 
103
START_SECTION((const IsobaricChannelList& getChannelInformation() const ))
 
104
{
 
105
  ItraqFourPlexQuantitationMethod quant_meth;
 
106
  IsobaricQuantitationMethod::IsobaricChannelList channel_list = quant_meth.getChannelInformation();
 
107
  
 
108
  TEST_EQUAL(channel_list.size(), 4)
 
109
  ABORT_IF(channel_list.size() != 4)
 
110
  
 
111
  // descriptions are empty by default
 
112
  TEST_STRING_EQUAL(channel_list[0].description, "")
 
113
  TEST_STRING_EQUAL(channel_list[1].description, "")
 
114
  TEST_STRING_EQUAL(channel_list[2].description, "")
 
115
  TEST_STRING_EQUAL(channel_list[3].description, "")
 
116
    
 
117
  // check masses&co
 
118
  TEST_EQUAL(channel_list[0].name, 114)
 
119
  TEST_EQUAL(channel_list[0].id, 0)
 
120
  TEST_EQUAL(channel_list[0].center, 114.1112)
 
121
 
 
122
  TEST_EQUAL(channel_list[1].name, 115)
 
123
  TEST_EQUAL(channel_list[1].id, 1)
 
124
  TEST_EQUAL(channel_list[1].center, 115.1082)
 
125
 
 
126
  TEST_EQUAL(channel_list[2].name, 116)
 
127
  TEST_EQUAL(channel_list[2].id, 2)
 
128
  TEST_EQUAL(channel_list[2].center, 116.1116)
 
129
 
 
130
  TEST_EQUAL(channel_list[3].name, 117)
 
131
  TEST_EQUAL(channel_list[3].id, 3)
 
132
  TEST_EQUAL(channel_list[3].center, 117.1149)
 
133
}
 
134
END_SECTION
 
135
 
 
136
START_SECTION((Size getNumberOfChannels() const ))
 
137
{
 
138
  ItraqFourPlexQuantitationMethod quant_meth;
 
139
  TEST_EQUAL(quant_meth.getNumberOfChannels(), 4)
 
140
}
 
141
END_SECTION
 
142
 
 
143
START_SECTION((virtual Matrix<double> getIsotopeCorrectionMatrix() const ))
 
144
{
 
145
  ItraqFourPlexQuantitationMethod quant_meth;
 
146
  
 
147
  // we only check the default matrix here
 
148
  Matrix<double> m = quant_meth.getIsotopeCorrectionMatrix();
 
149
  TEST_EQUAL(m.rows(), 4)
 
150
  TEST_EQUAL(m.cols(), 4)
 
151
    
 
152
  ABORT_IF(m.rows() != 4)
 
153
  ABORT_IF(m.cols() != 4)
 
154
 
 
155
  /**  
 
156
    0.929   0.02      0      0 
 
157
    0.059  0.923   0.03  0.001 
 
158
    0.002  0.056  0.924   0.04 
 
159
        0  0.001  0.045  0.923
 
160
  */
 
161
  double real_m[4][4] = {{0.929, 0.02, 0, 0},
 
162
    {0.059, 0.923, 0.03, 0.001},
 
163
    {0.002, 0.056, 0.924, 0.04},
 
164
    {0, 0.001, 0.045, 0.923}};
 
165
  
 
166
  for(Matrix<double>::SizeType i = 0; i < m.rows(); ++i)
 
167
  {
 
168
    for(Matrix<double>::SizeType j = 0; j < m.cols(); ++j)
 
169
    {
 
170
      TEST_REAL_SIMILAR(m(i,j), real_m[i][j])
 
171
    }
 
172
  }
 
173
}
 
174
END_SECTION
 
175
 
 
176
START_SECTION((virtual Size getReferenceChannel() const ))
 
177
{
 
178
  ItraqFourPlexQuantitationMethod quant_meth;
 
179
  TEST_EQUAL(quant_meth.getReferenceChannel(), 0)
 
180
    
 
181
  Param p;
 
182
  p.setValue("reference_channel",115);
 
183
  quant_meth.setParameters(p);
 
184
  
 
185
  TEST_EQUAL(quant_meth.getReferenceChannel(), 1)
 
186
}
 
187
END_SECTION
 
188
  
 
189
/////////////////////////////////////////////////////////////
 
190
/////////////////////////////////////////////////////////////
 
191
END_TEST