ProteoWizard
ProteomeDataTest.cpp
Go to the documentation of this file.
1//
2// $Id$
3//
4//
5// Original author: Matt Chambers <matt.chambers .@. vanderbilt.edu>
6//
7// Copyright 2009 Vanderbilt University - Nashville, TN 37232
8//
9// Licensed under the Apache License, Version 2.0 (the "License");
10// you may not use this file except in compliance with the License.
11// You may obtain a copy of the License at
12//
13// http://www.apache.org/licenses/LICENSE-2.0
14//
15// Unless required by applicable law or agreed to in writing, software
16// distributed under the License is distributed on an "AS IS" BASIS,
17// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18// See the License for the specific language governing permissions and
19// limitations under the License.
20//
21
22
23#include "ProteomeData.hpp"
26
27using namespace pwiz::util;
28using namespace pwiz::proteome;
29
30
32{
33 // fill in ProteinListSimple
34
35 shared_ptr<ProteinListSimple> proteinListSimple(new ProteinListSimple);
36
37 unit_assert(proteinListSimple->empty());
38
39 Protein emptyProtein("", 0, "", "");
40 unit_assert(emptyProtein.empty());
41
42 ProteinPtr protein0(new Protein("IPI-1701", 0, "The final frontier!", ""));
43 ProteinPtr protein1(new Protein("SPROT|42", 1, "Life, the universe, and everything.", ""));
44
45 unit_assert(!protein0->empty());
46
47 proteinListSimple->proteins.push_back(protein0);
48 proteinListSimple->proteins.push_back(protein1);
49
50 // let a ProteomeData object hold onto it as a ProteinListPtr
51
52 ProteomeData data;
53 data.proteinListPtr = proteinListSimple;
54
55 // test ProteinList interface
56
57 // verify index()
58 const ProteinList& proteinList = *data.proteinListPtr;
59 unit_assert(proteinList.size() == 2);
60 unit_assert(proteinList.find("IPI-1701") == 0);
61 unit_assert(proteinList.find("SPROT|42") == 1);
62
63 // verify findKeyword
64 IndexList result = proteinList.findKeyword("final");
65 unit_assert(result.size()==1 && result[0]==0);
66
67 result = proteinList.findKeyword("the", false);
68 unit_assert(result.size()==2 && result[0]==0 && result[1]==1);
69
70 result = proteinList.findKeyword("the");
71 unit_assert(result.size()==1 && result[0]==1);
72
73 result = proteinList.findKeyword("42");
74 unit_assert(result.empty());
75
76 // verify protein 0
77 ProteinPtr protein = proteinList.protein(0);
78 unit_assert(protein->index == protein0->index);
79 unit_assert(protein->id == protein0->id);
80
81 // verify spectrum 1
82 protein = proteinList.protein(1);
83 unit_assert(protein->index == protein1->index);
84 unit_assert(protein->id == protein1->id);
85}
86
87
88int main(int argc, char* argv[])
89{
90 TEST_PROLOG(argc, argv)
91
92 try
93 {
95 }
96 catch (exception& e)
97 {
98 TEST_FAILED(e.what())
99 }
100 catch (...)
101 {
102 TEST_FAILED("Caught unknown exception.")
103 }
104
106}
int main(int argc, char *argv[])
void testProteinListSimple()
virtual ProteinPtr protein(size_t index, bool getSequence=true) const =0
virtual IndexList findKeyword(const std::string &keyword, bool caseSensitive=true) const
virtual size_t find(const std::string &id) const
virtual size_t size() const =0
boost::shared_ptr< Protein > ProteinPtr
#define unit_assert(x)
Definition unit.hpp:85
#define TEST_EPILOG
Definition unit.hpp:183
#define TEST_FAILED(x)
Definition unit.hpp:177
#define TEST_PROLOG(argc, argv)
Definition unit.hpp:175