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

« back to all changes in this revision

Viewing changes to source/TEST/ProteinIdentification_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: Chris Bielow $
 
25
// $Authors: Nico Pfeifer, Chris Bielow $
 
26
// --------------------------------------------------------------------------
 
27
 
 
28
#include <OpenMS/CONCEPT/ClassTest.h>
 
29
 
 
30
///////////////////////////
 
31
 
 
32
#include <string>
 
33
 
 
34
#include <OpenMS/FORMAT/MascotXMLFile.h>
 
35
#include <OpenMS/FORMAT/IdXMLFile.h>
 
36
#include <OpenMS/METADATA/ProteinIdentification.h>
 
37
#include <OpenMS/DATASTRUCTURES/String.h>
 
38
#include <OpenMS/DATASTRUCTURES/DateTime.h>
 
39
 
 
40
///////////////////////////
 
41
 
 
42
START_TEST(ProteinIdentification, "$Id: ProteinIdentification_test.C 8210 2011-03-28 13:19:52Z aiche $")
 
43
 
 
44
/////////////////////////////////////////////////////////////
 
45
/////////////////////////////////////////////////////////////
 
46
 
 
47
using namespace OpenMS;
 
48
using namespace std;
 
49
 
 
50
float protein_significance_threshold = 63.2f;
 
51
std::vector<ProteinHit> protein_hits;
 
52
ProteinHit protein_hit;
 
53
ProteinIdentification protein_identification;
 
54
MascotXMLFile xml_file;
 
55
 
 
56
protein_hits.push_back(protein_hit);
 
57
 
 
58
ProteinIdentification* ptr = 0;
 
59
ProteinIdentification* nullPointer = 0;
 
60
START_SECTION((ProteinIdentification()))
 
61
        ptr = new ProteinIdentification();
 
62
        TEST_NOT_EQUAL(ptr, nullPointer)
 
63
END_SECTION
 
64
 
 
65
START_SECTION((virtual ~ProteinIdentification()))
 
66
        ProteinIdentification hits;
 
67
        delete ptr;
 
68
END_SECTION
 
69
 
 
70
START_SECTION((ProteinIdentification(const ProteinIdentification &source)))
 
71
        ProteinIdentification hits;
 
72
        hits.setDateTime(DateTime::now());
 
73
        hits.setSignificanceThreshold(protein_significance_threshold);
 
74
        hits.insertHit(protein_hit);
 
75
        hits.setMetaValue("label",17);
 
76
        hits.setIdentifier("id");
 
77
        hits.setScoreType("score_type");
 
78
        hits.setHigherScoreBetter(false);
 
79
        hits.setSearchEngine("Mascot");
 
80
        hits.setSearchEngineVersion("2.1");
 
81
        ProteinIdentification::SearchParameters param;
 
82
        param.db = "RefSeq";
 
83
        ProteinIdentification::ProteinGroup g;
 
84
        g.probability = 0.99;
 
85
        g.accessions.push_back("protein0");
 
86
        g.accessions.push_back("protein3");
 
87
        hits.insertProteinGroup(g);
 
88
        hits.insertProteinGroup(g);
 
89
        hits.setSearchParameters(param);
 
90
        
 
91
        ProteinIdentification hits2(hits);
 
92
 
 
93
        TEST_EQUAL(hits.getDateTime() == hits2.getDateTime(), true)
 
94
        TEST_EQUAL(hits.getSignificanceThreshold(), hits2.getSignificanceThreshold())
 
95
        TEST_EQUAL(hits.getHits().size() == 1, true)
 
96
        TEST_EQUAL(hits.getHits()[0].getSequence(), String("")) 
 
97
        TEST_EQUAL(hits.getHits()[0] == protein_hit, true)      
 
98
        TEST_EQUAL(hits.getProteinGroups().size() == 2, true)
 
99
        TEST_EQUAL(hits.getProteinGroups()[0]==g, true) 
 
100
        TEST_EQUAL(hits.getProteinGroups()[1]==g, true) 
 
101
        TEST_EQUAL((UInt)hits.getMetaValue("label"),17)
 
102
        TEST_EQUAL(hits.getIdentifier(),"id")
 
103
        TEST_EQUAL(hits.getScoreType(),"score_type")
 
104
        TEST_EQUAL(hits.isHigherScoreBetter(),false)
 
105
        TEST_EQUAL(hits.getSearchEngine(), "Mascot")
 
106
        TEST_EQUAL(hits.getSearchEngineVersion(), "2.1")
 
107
        TEST_EQUAL(hits.getSearchParameters()==param, true)
 
108
END_SECTION
 
109
 
 
110
 
 
111
START_SECTION((ProteinIdentification& operator=(const ProteinIdentification& source)))
 
112
        ProteinIdentification hits;
 
113
        hits.setDateTime(DateTime::now());
 
114
        hits.setSignificanceThreshold(protein_significance_threshold);
 
115
        hits.insertHit(protein_hit);
 
116
        hits.setIdentifier("id");
 
117
        hits.setScoreType("score_type");
 
118
        hits.setHigherScoreBetter(false);
 
119
        hits.setSearchEngine("Mascot");
 
120
        hits.setSearchEngineVersion("2.1");
 
121
        ProteinIdentification::ProteinGroup g;
 
122
        g.probability = 0.99;
 
123
        g.accessions.push_back("protein0");
 
124
        g.accessions.push_back("protein3");
 
125
        hits.insertProteinGroup(g);
 
126
        ProteinIdentification::SearchParameters param;
 
127
        param.db = "RefSeq";
 
128
        hits.setSearchParameters(param);
 
129
                
 
130
        ProteinIdentification hits2;
 
131
        hits2 = hits;
 
132
        
 
133
        TEST_EQUAL(hits.getDateTime() == hits2.getDateTime(), true)
 
134
        TEST_EQUAL(hits.getSignificanceThreshold(), hits2.getSignificanceThreshold())
 
135
        TEST_EQUAL(hits2.getHits().size() == 1, true)
 
136
        TEST_EQUAL(*(hits2.getHits().begin()) == protein_hit, true)
 
137
        TEST_EQUAL(hits2.getProteinGroups().size() == 1, true)
 
138
        TEST_EQUAL(hits2.getProteinGroups()[0]==g, true)        
 
139
        TEST_EQUAL(hits2.getIdentifier(),"id")
 
140
        TEST_EQUAL(hits2.getScoreType(),"score_type")
 
141
        TEST_EQUAL(hits2.isHigherScoreBetter(),false)
 
142
        TEST_EQUAL(hits2.getSearchEngine(), "Mascot")
 
143
        TEST_EQUAL(hits2.getSearchEngineVersion(), "2.1")
 
144
        TEST_EQUAL(hits2.getSearchParameters()==param, true)
 
145
END_SECTION
 
146
 
 
147
START_SECTION((bool operator == (const ProteinIdentification& rhs) const))
 
148
        ProteinIdentification search1;
 
149
        ProteinIdentification search2;
 
150
        TEST_EQUAL(search1 == search2, true)
 
151
        
 
152
        search1.setDateTime(DateTime::now());
 
153
        TEST_EQUAL(search1 == search2, false)   
 
154
        search1 = search2;
 
155
                
 
156
        search1.setSignificanceThreshold(protein_significance_threshold);
 
157
        TEST_EQUAL(search1 == search2, false)   
 
158
        search1 = search2;
 
159
 
 
160
        search2.setIdentifier("id");
 
161
        TEST_EQUAL(search1 == search2, false)   
 
162
        search1 = search2;
 
163
 
 
164
        search2.setScoreType("score_type");
 
165
        TEST_EQUAL(search1 == search2, false)   
 
166
        search1 = search2;
 
167
 
 
168
        search2.setHigherScoreBetter(false);
 
169
        TEST_EQUAL(search1 == search2, false)   
 
170
        search1 = search2;
 
171
 
 
172
        search2.setSearchEngine("Mascot");
 
173
        TEST_EQUAL(search1 == search2, false)   
 
174
        search1 = search2;
 
175
        
 
176
        search2.setSearchEngineVersion("2.1");
 
177
        TEST_EQUAL(search1 == search2, false)   
 
178
        search1 = search2;
 
179
        
 
180
        ProteinIdentification::SearchParameters param;
 
181
        param.db = "RefSeq";
 
182
        search2.setSearchParameters(param);
 
183
        TEST_EQUAL(search1 == search2, false)   
 
184
        search1 = search2;
 
185
 
 
186
        ProteinIdentification::ProteinGroup g;
 
187
        g.probability = 0.99;
 
188
        g.accessions.push_back("protein0");
 
189
        g.accessions.push_back("protein3");
 
190
        search2.insertProteinGroup(g);
 
191
        TEST_EQUAL(search1 == search2, false)   
 
192
        search1 = search2;
 
193
 
 
194
END_SECTION
 
195
 
 
196
START_SECTION((bool operator != (const ProteinIdentification& rhs) const))
 
197
        ProteinIdentification search1;
 
198
        ProteinIdentification search2;
 
199
        TEST_EQUAL(search1 != search2, false)
 
200
        
 
201
        search1.setDateTime(DateTime::now());
 
202
        TEST_EQUAL(search1 != search2, true)    
 
203
 
 
204
        //rest does not need to be tested, as it is tested in the operator== test implicitly!
 
205
END_SECTION
 
206
 
 
207
START_SECTION((const DateTime& getDateTime() const))
 
208
        ProteinIdentification hits;
 
209
        DateTime date = DateTime::now();
 
210
        hits.setDateTime(date);
 
211
        const DateTime& date_time = hits.getDateTime();
 
212
        TEST_EQUAL(date_time == date, true)
 
213
END_SECTION
 
214
 
 
215
START_SECTION((DoubleReal getSignificanceThreshold() const))
 
216
        ProteinIdentification hits;
 
217
        hits.setSignificanceThreshold(protein_significance_threshold);
 
218
        TEST_EQUAL(hits.getSignificanceThreshold(), protein_significance_threshold)     
 
219
END_SECTION
 
220
 
 
221
START_SECTION((const std::vector<ProteinHit>& getHits() const))
 
222
        ProteinIdentification hits;
 
223
        hits.insertHit(protein_hit);
 
224
        TEST_EQUAL(hits.getHits().size() == 1, true)
 
225
        TEST_EQUAL(*(hits.getHits().begin()) == protein_hit, true)      
 
226
END_SECTION
 
227
 
 
228
START_SECTION((std::vector<ProteinHit>& getHits()))
 
229
        ProteinIdentification hits;
 
230
        hits.insertHit(protein_hit);
 
231
        TEST_EQUAL(hits.getHits().size() == 1, true)
 
232
        TEST_EQUAL(*(hits.getHits().begin()) == protein_hit, true)      
 
233
END_SECTION
 
234
 
 
235
START_SECTION((void insertHit(const ProteinHit& input)))
 
236
        ProteinIdentification hits;
 
237
        hits.insertHit(protein_hit);
 
238
        TEST_EQUAL(hits.getHits().size() == 1, true)
 
239
        TEST_EQUAL(*(hits.getHits().begin()) == protein_hit, true)
 
240
END_SECTION
 
241
 
 
242
START_SECTION((void setDateTime(const DateTime& date)))
 
243
        ProteinIdentification hits;
 
244
        DateTime date = DateTime::now();
 
245
        hits.setDateTime(date);
 
246
        TEST_EQUAL(hits.getDateTime() == date, true)
 
247
END_SECTION
 
248
 
 
249
START_SECTION((void setSignificanceThreshold(DoubleReal value)))
 
250
        ProteinIdentification hits;
 
251
        hits.setSignificanceThreshold(protein_significance_threshold);
 
252
        TEST_EQUAL(hits.getSignificanceThreshold(), protein_significance_threshold)
 
253
END_SECTION
 
254
 
 
255
START_SECTION((void setHits(const std::vector< ProteinHit > &hits)))
 
256
        ProteinHit hit_1;
 
257
        ProteinHit hit_2;
 
258
        ProteinHit hit_3;
 
259
        vector<ProteinHit> hits;
 
260
        ProteinIdentification id;
 
261
        
 
262
        hit_1.setScore(23);
 
263
        hit_2.setScore(11);
 
264
        hit_3.setScore(45);
 
265
        hit_1.setAccession("SECONDPROTEIN");
 
266
        hit_2.setAccession("THIRDPROTEIN");
 
267
        hit_3.setAccession("FIRSTPROTEIN");
 
268
        hits.push_back(hit_1);
 
269
        hits.push_back(hit_2);
 
270
        hits.push_back(hit_3);
 
271
        id.setHits(hits);
 
272
        TEST_EQUAL(id.getHits()[2].getAccession(), "FIRSTPROTEIN")
 
273
        TEST_EQUAL(id.getHits()[0].getAccession(), "SECONDPROTEIN")
 
274
        TEST_EQUAL(id.getHits()[1].getAccession(), "THIRDPROTEIN")
 
275
END_SECTION
 
276
 
 
277
START_SECTION((const String& getScoreType() const))
 
278
        ProteinIdentification hits;
 
279
        TEST_EQUAL(hits.getScoreType(),"")
 
280
END_SECTION
 
281
 
 
282
START_SECTION((void setScoreType(const String& type)))
 
283
        ProteinIdentification hits;
 
284
        hits.setScoreType("bla");
 
285
        TEST_EQUAL(hits.getScoreType(),"bla")
 
286
END_SECTION
 
287
 
 
288
START_SECTION((bool isHigherScoreBetter() const))
 
289
        ProteinIdentification hits;
 
290
        TEST_EQUAL(hits.isHigherScoreBetter(),true)
 
291
END_SECTION
 
292
 
 
293
START_SECTION((void setHigherScoreBetter(bool higher_is_better)))
 
294
        ProteinIdentification hits;
 
295
        hits.setHigherScoreBetter(false);
 
296
        TEST_EQUAL(hits.isHigherScoreBetter(),false)
 
297
END_SECTION
 
298
 
 
299
START_SECTION((const String& getIdentifier() const))
 
300
        ProteinIdentification hits;
 
301
        TEST_EQUAL(hits.getIdentifier(),"")
 
302
END_SECTION
 
303
 
 
304
START_SECTION((void setIdentifier(const String& id)))
 
305
        ProteinIdentification hits;
 
306
        hits.setIdentifier("bla");
 
307
        TEST_EQUAL(hits.getIdentifier(),"bla")
 
308
END_SECTION
 
309
 
 
310
START_SECTION((const String& getSearchEngine() const))
 
311
        ProteinIdentification hits;
 
312
        TEST_EQUAL(hits.getSearchEngine(),"")
 
313
END_SECTION
 
314
 
 
315
START_SECTION((void setSearchEngine(const String &search_engine)))
 
316
        ProteinIdentification hits;
 
317
        hits.setIdentifier("bla");
 
318
        TEST_EQUAL(hits.getIdentifier(),"bla")
 
319
END_SECTION
 
320
 
 
321
START_SECTION((const String& getSearchEngineVersion() const))
 
322
        ProteinIdentification hits;
 
323
        TEST_EQUAL(hits.getSearchEngineVersion(),"")
 
324
END_SECTION
 
325
 
 
326
START_SECTION((void setSearchEngineVersion(const String &search_engine_version)))
 
327
        ProteinIdentification hits;
 
328
        hits.setSearchEngineVersion("bla");
 
329
        TEST_EQUAL(hits.getSearchEngineVersion(),"bla")
 
330
END_SECTION
 
331
 
 
332
START_SECTION((const SearchParameters& getSearchParameters() const))
 
333
        ProteinIdentification hits;
 
334
        TEST_EQUAL(hits.getSearchParameters()==ProteinIdentification::SearchParameters(),true)
 
335
END_SECTION
 
336
 
 
337
START_SECTION((void setSearchParameters(const SearchParameters &search_parameters)))
 
338
        ProteinIdentification hits;
 
339
        ProteinIdentification::SearchParameters param;
 
340
        param.db="Mascot";
 
341
        hits.setSearchParameters(param);
 
342
        TEST_EQUAL(hits.getSearchParameters()==ProteinIdentification::SearchParameters(),false)
 
343
END_SECTION
 
344
 
 
345
START_SECTION((void sort()))
 
346
        {
 
347
        ProteinIdentification id;
 
348
        ProteinHit hit;
 
349
        hit.setScore(23);
 
350
        hit.setAccession("SECONDPROTEIN");
 
351
        id.insertHit(hit);
 
352
        hit.setScore(45);
 
353
        hit.setAccession("FIRSTPROTEIN");
 
354
        id.insertHit(hit);
 
355
        hit.setScore(7);
 
356
        hit.setAccession("THIRDPROTEIN");
 
357
        id.insertHit(hit);
 
358
        
 
359
        //higher score is better
 
360
        id.sort();
 
361
 
 
362
        TEST_EQUAL(id.getHits()[0].getAccession(), "FIRSTPROTEIN")
 
363
        TEST_EQUAL(id.getHits()[1].getAccession(), "SECONDPROTEIN")
 
364
        TEST_EQUAL(id.getHits()[2].getAccession(), "THIRDPROTEIN")
 
365
        TEST_EQUAL(id.getHits()[0].getScore(), 45)      
 
366
        TEST_EQUAL(id.getHits()[1].getScore(), 23)
 
367
        TEST_EQUAL(id.getHits()[2].getScore(), 7)
 
368
 
 
369
        //lower score is better
 
370
        id.setHigherScoreBetter(false);
 
371
        id.sort();
 
372
 
 
373
        TEST_EQUAL(id.getHits()[0].getAccession(), "THIRDPROTEIN")
 
374
        TEST_EQUAL(id.getHits()[1].getAccession(), "SECONDPROTEIN")
 
375
        TEST_EQUAL(id.getHits()[2].getAccession(), "FIRSTPROTEIN")
 
376
        TEST_EQUAL(id.getHits()[0].getScore(), 7)       
 
377
        TEST_EQUAL(id.getHits()[1].getScore(), 23)
 
378
        TEST_EQUAL(id.getHits()[2].getScore(), 45)
 
379
        }
 
380
        
 
381
        
 
382
        {
 
383
        ProteinIdentification id;
 
384
        ProteinHit hit;
 
385
        hit.setScore(45);
 
386
        hit.setAccession("SECONDPROTEIN");
 
387
        id.insertHit(hit);
 
388
        hit.setScore(7);
 
389
        hit.setAccession("FOURTHPROTEIN");
 
390
        id.insertHit(hit);
 
391
        hit.setScore(23);
 
392
        hit.setAccession("THIRDPROTEIN");
 
393
        id.insertHit(hit);
 
394
        hit.setScore(99);
 
395
        hit.setAccession("FIRSTPROTEIN");
 
396
        id.insertHit(hit);
 
397
        
 
398
        ProteinIdentification::ProteinGroup g1, g2;
 
399
        g1.probability = 0.99;
 
400
        g1.accessions.push_back("FIRSTPROTEIN");
 
401
        g1.accessions.push_back("FOURTHPROTEIN");
 
402
        id.insertProteinGroup(g1);
 
403
        g2.probability = 0.96;
 
404
        g2.accessions.push_back("FIRSTPROTEIN");
 
405
        g2.accessions.push_back("SECONDPROTEIN");
 
406
        g2.accessions.push_back("THIRDPROTEIN");
 
407
        id.insertProteinGroup(g2);
 
408
        
 
409
        //higher score is better
 
410
        id.sort();
 
411
 
 
412
        TEST_EQUAL(id.getHits()[0].getAccession(), "FIRSTPROTEIN")
 
413
        TEST_EQUAL(id.getHits()[1].getAccession(), "SECONDPROTEIN")
 
414
        TEST_EQUAL(id.getHits()[2].getAccession(), "THIRDPROTEIN")
 
415
        TEST_EQUAL(id.getHits()[0].getScore(), 99)      
 
416
        TEST_EQUAL(id.getHits()[1].getScore(), 45)
 
417
        TEST_EQUAL(id.getHits()[2].getScore(), 23)
 
418
 
 
419
        TEST_EQUAL(id.getProteinGroups().size(), 2);
 
420
        TEST_EQUAL(id.getProteinGroups()[0]== g1, true);        
 
421
        TEST_EQUAL(id.getProteinGroups()[1]== g2, true);
 
422
 
 
423
        }
 
424
        
 
425
END_SECTION
 
426
 
 
427
START_SECTION((void assignRanks()))
 
428
        ProteinIdentification id;
 
429
        ProteinHit hit;
 
430
        hit.setScore(23);
 
431
        hit.setAccession("SECONDPROTEIN");
 
432
        id.insertHit(hit);
 
433
        hit.setScore(45);
 
434
        hit.setAccession("FIRSTPROTEIN");
 
435
        id.insertHit(hit);
 
436
        hit.setScore(7);
 
437
        hit.setAccession("THIRDPROTEIN");
 
438
        id.insertHit(hit);
 
439
 
 
440
        id.assignRanks();
 
441
 
 
442
        TEST_EQUAL(id.getHits()[0].getAccession(), "FIRSTPROTEIN")
 
443
        TEST_EQUAL(id.getHits()[1].getAccession(), "SECONDPROTEIN")
 
444
        TEST_EQUAL(id.getHits()[2].getAccession(), "THIRDPROTEIN")
 
445
        TEST_EQUAL(id.getHits()[0].getRank(), 1)        
 
446
        TEST_EQUAL(id.getHits()[1].getRank(), 2)
 
447
        TEST_EQUAL(id.getHits()[2].getRank(), 3)
 
448
END_SECTION
 
449
 
 
450
START_SECTION((Size computeCoverage(const std::vector< PeptideIdentification > &pep_ids)))
 
451
        ProteinIdentification id;
 
452
        
 
453
  // prep hit
 
454
  ProteinHit hit;
 
455
        hit.setAccession("P1");
 
456
  hit.setSequence("MKQSTIALALLPLLFTPVTKARTPEMPVLENRAAQGDITAPGGARRLTGDQTAALRDSLS"
 
457
                  "DKPAKNIILLIGDGMGDSEITAARNYAEGAGGFFKGIDALPLTGQYTHYALNKKTGKPDY"
 
458
                  "VTDSAASATAWSTGVKTYNGALGVDIHEKDHPTILEMAKAAGLATGNVSTAELQDATPAA");
 
459
  id.insertHit(hit);
 
460
        hit.setAccession("P2");
 
461
  hit.setSequence("PEMPVLENRAAQGDITAPPGGARRLTGDQTAALRDSLS");
 
462
  id.insertHit(hit);
 
463
 
 
464
  // prep peptides
 
465
  std::vector<PeptideIdentification> pep_ids;
 
466
  PeptideIdentification pid;
 
467
  PeptideHit phit(0,0,1,"");
 
468
  phit.setProteinAccessions(StringList::create("P1"));
 
469
  phit.setSequence("MKQSTIALALLPLLFTPVTKARTPEMPVLENRAAQGDITAPGGARRLTGDQTAALRDSLS");
 
470
  pid.insertHit( phit );
 
471
  phit.setSequence("DKPAKNIILLIGDGMGDSEITAARNYAEGAGGFFKGIDALPLTGQYTHYALNKKTGKPDY");
 
472
  pid.insertHit( phit );
 
473
  phit.setSequence("MKQSTIALALLPLLFTPVTKARTPEMPVLENRAAQGDITAPGGARRLTGDQTAALRDSLS");  // should not count
 
474
  pid.insertHit( phit );
 
475
  pep_ids.push_back(pid);
 
476
 
 
477
  PeptideIdentification pid2;
 
478
  PeptideHit phit2(0,0,1,"");
 
479
  phit2.setProteinAccessions(StringList::create("P1"));
 
480
  phit2.setSequence("MKQSTIALALLPLLFTPVTKARTPEMPVLENRAAQGDITAPGGARRLTGDQTAALRDSLS");
 
481
  pid2.insertHit( phit2 ); // should not count
 
482
  pep_ids.push_back(pid2);
 
483
 
 
484
  id.computeCoverage(pep_ids);
 
485
 
 
486
  TEST_REAL_SIMILAR(id.getHits()[0].getCoverage(), 200.0/3.0);
 
487
  TEST_REAL_SIMILAR(id.getHits()[1].getCoverage(), 0.0);
 
488
 
 
489
  phit2.setSequence("VTDSAASATAWSTGVKTYNGALGVDIHEKDHPTILEMAKAAGLATGNVSTAELQDATPAA");
 
490
  pid2.insertHit( phit2 ); 
 
491
  pep_ids.push_back(pid2);
 
492
 
 
493
  id.computeCoverage(pep_ids);
 
494
 
 
495
  TEST_REAL_SIMILAR(id.getHits()[0].getCoverage(), 100.0);
 
496
  TEST_REAL_SIMILAR(id.getHits()[1].getCoverage(), 0.0);
 
497
 
 
498
  pep_ids.clear();
 
499
  PeptideIdentification pid3;
 
500
  PeptideHit phit3(0,0,1,"");
 
501
  phit3.setProteinAccessions(StringList::create("P2"));
 
502
  phit3.setSequence("PEMPVLENRAAQGDITAPP"); // 1st half
 
503
  pid3.insertHit( phit3 ); 
 
504
  phit3.setSequence("GGARRLTGDQTAALRDSLS"); // 2nd half
 
505
  pid3.insertHit( phit3 ); 
 
506
  phit3.setSequence("RAAQGDITAPPGGARRLTG"); // middle half
 
507
  pid3.insertHit( phit3 ); 
 
508
  
 
509
  pep_ids.push_back(pid3);
 
510
 
 
511
  id.computeCoverage(pep_ids);
 
512
 
 
513
  TEST_REAL_SIMILAR(id.getHits()[0].getCoverage(), 0.0);
 
514
  TEST_REAL_SIMILAR(id.getHits()[1].getCoverage(), 150.0);
 
515
 
 
516
END_SECTION
 
517
 
 
518
START_SECTION(( [ProteinIdentification::ProteinGroup] ProteinGroup() ))
 
519
  ProteinIdentification::ProteinGroup p;
 
520
  
 
521
  TEST_EQUAL(p.probability, 0)
 
522
  TEST_EQUAL(p.accessions.size(), 0)
 
523
 
 
524
END_SECTION
 
525
 
 
526
START_SECTION(( [ProteinIdentification::ProteinGroup] bool operator==(const ProteinGroup rhs) const ))
 
527
  ProteinIdentification::ProteinGroup p, p_c;
 
528
 
 
529
  p.probability = 0.5;
 
530
  TEST_NOT_EQUAL(p==p_c, true)
 
531
 
 
532
  p.probability = 0.0;
 
533
  p.accessions.push_back("bla");
 
534
  TEST_NOT_EQUAL(p==p_c, true)
 
535
 
 
536
  p_c = p;
 
537
 
 
538
  TEST_EQUAL(p==p_c, true)
 
539
 
 
540
END_SECTION
 
541
 
 
542
START_SECTION(( [ProteinIdentification::SearchParameters] SearchParameters() ))
 
543
  ProteinIdentification::SearchParameters sp;
 
544
  
 
545
  TEST_EQUAL( sp.db.size(), 0)
 
546
  TEST_EQUAL( sp.db_version.size(), 0)
 
547
  TEST_EQUAL( sp.taxonomy.size(), 0)
 
548
  TEST_EQUAL( sp.charges.size(), 0)
 
549
  TEST_EQUAL( sp.mass_type, 0)
 
550
  TEST_EQUAL( sp.fixed_modifications.size(), 0)
 
551
  TEST_EQUAL( sp.variable_modifications.size(), 0)
 
552
  TEST_EQUAL( sp.enzyme, ProteinIdentification::UNKNOWN_ENZYME)
 
553
  TEST_EQUAL( sp.missed_cleavages, 0)
 
554
  TEST_EQUAL( sp.peak_mass_tolerance, 0.0)
 
555
  TEST_EQUAL( sp.precursor_tolerance, 0.0)
 
556
 
 
557
 
 
558
END_SECTION
 
559
 
 
560
START_SECTION(( [ProteinIdentification::SearchParameters] bool operator==(const SearchParameters &rhs) const ))
 
561
  ProteinIdentification::SearchParameters sp, sp_n;
 
562
  sp_n.charges = "1,2,3";
 
563
  TEST_EQUAL(sp==sp_n, false)
 
564
END_SECTION
 
565
 
 
566
START_SECTION(( [ProteinIdentification::SearchParameters] bool operator!=(const SearchParameters &rhs) const ))
 
567
  ProteinIdentification::SearchParameters sp, sp_n;
 
568
  sp_n.charges = "1,2,3";
 
569
  TEST_EQUAL(sp!=sp_n, true)
 
570
END_SECTION
 
571
 
 
572
START_SECTION((const vector<ProteinGroup>& getProteinGroups() const))
 
573
        ProteinIdentification id;
 
574
        ProteinIdentification::ProteinGroup g;
 
575
        g.probability = 0.99;
 
576
        g.accessions.push_back("protein0");
 
577
        g.accessions.push_back("protein3");
 
578
        id.insertProteinGroup(g);
 
579
        
 
580
        TEST_EQUAL(id.getProteinGroups().size(), 1);
 
581
        TEST_EQUAL(id.getProteinGroups()[0]==g, true);
 
582
END_SECTION
 
583
 
 
584
START_SECTION((vector<ProteinGroup>& getProteinGroups()))
 
585
        ProteinIdentification id;
 
586
        ProteinIdentification::ProteinGroup g;
 
587
        g.probability = 0.99;
 
588
        g.accessions.push_back("protein0");
 
589
        g.accessions.push_back("protein3");
 
590
        id.insertProteinGroup(g);
 
591
        
 
592
        TEST_EQUAL(id.getProteinGroups().size(), 1);
 
593
        TEST_EQUAL(id.getProteinGroups()[0]==g, true);  
 
594
  TEST_EQUAL(id.getProteinGroups()[0].probability = 0.1, 0.1);
 
595
END_SECTION
 
596
 
 
597
 
 
598
START_SECTION((void insertProteinGroup(const ProteinGroup& group)))
 
599
  NOT_TESTABLE
 
600
        //tested above
 
601
END_SECTION
 
602
 
 
603
 
 
604
START_SECTION((const vector<ProteinGroup>& getIndistinguishableProteins() const))
 
605
        ProteinIdentification id;
 
606
        ProteinIdentification::ProteinGroup g;
 
607
        g.accessions.push_back("protein0");
 
608
        g.accessions.push_back("protein3");
 
609
        id.insertIndistinguishableProteins(g);
 
610
        
 
611
        TEST_EQUAL(id.getIndistinguishableProteins().size(), 1);
 
612
        TEST_EQUAL(id.getIndistinguishableProteins()[0]==g, true);
 
613
END_SECTION
 
614
 
 
615
START_SECTION((vector<ProteinGroup>& getIndistinguishableProteins()))
 
616
        ProteinIdentification id;
 
617
        ProteinIdentification::ProteinGroup g;
 
618
        g.probability = 0.99;
 
619
        g.accessions.push_back("protein0");
 
620
        g.accessions.push_back("protein3");
 
621
        id.insertIndistinguishableProteins(g);
 
622
        
 
623
        TEST_EQUAL(id.getIndistinguishableProteins().size(), 1);
 
624
        TEST_EQUAL(id.getIndistinguishableProteins()[0]==g, true);
 
625
  id.getIndistinguishableProteins()[0].accessions.push_back("protein1");
 
626
        TEST_EQUAL(id.getIndistinguishableProteins()[0].accessions.size(), 3);
 
627
END_SECTION
 
628
 
 
629
 
 
630
START_SECTION((void insertIndistinguishableProteins(const ProteinGroup& group)))
 
631
        NOT_TESTABLE
 
632
        //tested above
 
633
END_SECTION
 
634
 
 
635
 
 
636
START_SECTION((vector<ProteinHit>::iterator findHit(const String& accession)))
 
637
{
 
638
        ProteinIdentification protein;
 
639
        ProteinHit hit;
 
640
        hit.setAccession("test1");
 
641
        protein.insertHit(hit);
 
642
        hit.setAccession("test2");
 
643
        protein.insertHit(hit);
 
644
        TEST_EQUAL(protein.findHit("test1")->getAccession(), "test1");
 
645
        TEST_EQUAL(protein.findHit("test2")->getAccession(), "test2");
 
646
        TEST_EQUAL(protein.findHit("test3") == protein.getHits().end(), true);
 
647
}
 
648
END_SECTION
 
649
 
 
650
 
 
651
 
 
652
/////////////////////////////////////////////////////////////
 
653
/////////////////////////////////////////////////////////////
 
654
 
 
655
END_TEST