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

« back to all changes in this revision

Viewing changes to source/TEST/MascotXMLFile_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: Nico Pfeifer $
 
25
// $Authors: Nico Pfeifer, Chris Bielow $
 
26
// --------------------------------------------------------------------------
 
27
 
 
28
#include <OpenMS/CONCEPT/ClassTest.h>
 
29
 
 
30
///////////////////////////
 
31
 
 
32
#include <OpenMS/DATASTRUCTURES/String.h>
 
33
#include <OpenMS/FORMAT/MascotXMLFile.h>
 
34
#include <OpenMS/METADATA/ContactPerson.h>
 
35
#include <OpenMS/METADATA/ProteinIdentification.h>
 
36
#include <OpenMS/METADATA/PeptideIdentification.h>
 
37
 
 
38
#include <vector>
 
39
 
 
40
///////////////////////////
 
41
 
 
42
START_TEST(MascotXMLFile, "$Id: MascotXMLFile_test.C 8375 2011-06-24 21:40:51Z cbielow $")
 
43
 
 
44
/////////////////////////////////////////////////////////////
 
45
/////////////////////////////////////////////////////////////
 
46
 
 
47
using namespace OpenMS;
 
48
using namespace std;
 
49
 
 
50
MascotXMLFile xml_file;
 
51
MascotXMLFile* ptr;
 
52
ProteinIdentification protein_identification;
 
53
vector<PeptideIdentification> peptide_identifications; 
 
54
vector<PeptideIdentification> peptide_identifications2; 
 
55
DateTime date;
 
56
PeptideHit peptide_hit;
 
57
vector<String> references;
 
58
 
 
59
date.set("2006-03-09 11:31:52");
 
60
 
 
61
MascotXMLFile* nullPointer = 0;
 
62
START_SECTION((MascotXMLFile()))
 
63
        ptr = new MascotXMLFile();
 
64
        TEST_NOT_EQUAL(ptr, nullPointer)
 
65
END_SECTION
 
66
 
 
67
START_SECTION((void load(const String &filename, ProteinIdentification &protein_identification, std::vector< PeptideIdentification > &id_data)))
 
68
 
 
69
        xml_file.load(OPENMS_GET_TEST_DATA_PATH("MascotXMLFile_test_1.mascotXML"),
 
70
                                                        protein_identification, 
 
71
                                                peptide_identifications);
 
72
                                                
 
73
        ProteinIdentification::SearchParameters search_parameters = protein_identification.getSearchParameters();
 
74
        TEST_EQUAL(search_parameters.missed_cleavages, 1);
 
75
        TEST_EQUAL(search_parameters.taxonomy, ". . Eukaryota (eucaryotes)");
 
76
        TEST_EQUAL(search_parameters.mass_type, ProteinIdentification::AVERAGE);
 
77
        TEST_EQUAL(search_parameters.enzyme, ProteinIdentification::TRYPSIN);
 
78
        TEST_EQUAL(search_parameters.db, "MSDB_chordata");
 
79
        TEST_EQUAL(search_parameters.db_version, "MSDB_chordata_20070910.fasta");
 
80
        TEST_EQUAL(search_parameters.peak_mass_tolerance, 0.2);
 
81
        TEST_EQUAL(search_parameters.precursor_tolerance, 1.4);
 
82
        TEST_EQUAL(search_parameters.charges, "1+, 2+ and 3+");
 
83
        TEST_EQUAL(search_parameters.fixed_modifications[0], "Carboxymethyl (C)");
 
84
        TEST_EQUAL(search_parameters.fixed_modifications[1], "Deamidated (NQ)");
 
85
        TEST_EQUAL(search_parameters.fixed_modifications[2], "Guanidinyl (K)");
 
86
        TEST_EQUAL(search_parameters.variable_modifications[0], "Acetyl (Protein N-term)");
 
87
        TEST_EQUAL(search_parameters.variable_modifications[1], "Biotin (K)");
 
88
        TEST_EQUAL(search_parameters.variable_modifications[2], "Carbamyl (K)");
 
89
        TEST_EQUAL(peptide_identifications.size(), 3)
 
90
        TOLERANCE_ABSOLUTE(0.0001)
 
91
        TEST_REAL_SIMILAR(peptide_identifications[0].getMetaValue("MZ"), 789.83)
 
92
        TEST_REAL_SIMILAR(peptide_identifications[1].getMetaValue("MZ"), 135.29)
 
93
        TEST_REAL_SIMILAR(peptide_identifications[2].getMetaValue("MZ"), 982.58)
 
94
        TOLERANCE_ABSOLUTE(0.00001)     
 
95
        TEST_EQUAL(protein_identification.getHits().size(), 2)
 
96
        TEST_EQUAL(protein_identification.getHits()[0].getAccession(), "AAN17824")
 
97
        TEST_EQUAL(protein_identification.getHits()[1].getAccession(), "GN1736")
 
98
        TEST_REAL_SIMILAR(protein_identification.getHits()[0].getScore(), 619)
 
99
        TEST_REAL_SIMILAR(protein_identification.getHits()[1].getScore(), 293)
 
100
        TEST_EQUAL(protein_identification.getScoreType(), "Mascot")
 
101
        TEST_EQUAL(protein_identification.getDateTime().get(), "2006-03-09 11:31:52")
 
102
        
 
103
        TEST_REAL_SIMILAR(peptide_identifications[0].getSignificanceThreshold(), 31.8621)
 
104
        TEST_EQUAL(peptide_identifications[0].getHits().size(), 2)
 
105
        
 
106
        peptide_hit = peptide_identifications[0].getHits()[0];
 
107
        references = peptide_hit.getProteinAccessions();
 
108
        TEST_EQUAL(references.size(), 2)
 
109
        TEST_EQUAL(references[0], "AAN17824")
 
110
        TEST_EQUAL(references[1], "GN1736")
 
111
        peptide_hit = peptide_identifications[0].getHits()[1];
 
112
        references = peptide_hit.getProteinAccessions();
 
113
        TEST_EQUAL(references.size(), 1)
 
114
        TEST_EQUAL(references[0], "AAN17824")
 
115
        peptide_hit = peptide_identifications[1].getHits()[0];
 
116
        references = peptide_hit.getProteinAccessions();
 
117
        TEST_EQUAL(references.size(), 1)
 
118
        TEST_EQUAL(references[0], "GN1736")
 
119
        
 
120
        TEST_EQUAL(peptide_identifications[1].getHits().size(), 1)
 
121
        TEST_REAL_SIMILAR(peptide_identifications[0].getHits()[0].getScore(), 33.85)
 
122
        TEST_REAL_SIMILAR(peptide_identifications[0].getHits()[1].getScore(), 33.12)
 
123
        TEST_REAL_SIMILAR(peptide_identifications[1].getHits()[0].getScore(), 43.9)
 
124
        TEST_EQUAL(peptide_identifications[0].getScoreType(), "Mascot")
 
125
        TEST_EQUAL(peptide_identifications[1].getScoreType(), "Mascot")
 
126
        TEST_EQUAL(protein_identification.getDateTime() == date, true)  
 
127
        TEST_EQUAL(peptide_identifications[0].getHits()[0].getSequence(), "LHASGITVTEIPVTATN(MOD:00565)FK(MOD:00445)")
 
128
        TEST_EQUAL(peptide_identifications[0].getHits()[1].getSequence(), "MRSLGYVAVISAVATDTDK(MOD:00445)")
 
129
        TEST_EQUAL(peptide_identifications[1].getHits()[0].getSequence(), "HSK(MOD:00445)LSAK(MOD:00445)")
 
130
  
 
131
  /// for new MascotXML 2.1 as used by Mascot Server 2.3
 
132
        xml_file.load(OPENMS_GET_TEST_DATA_PATH("MascotXMLFile_test_2.mascotXML"),
 
133
                                                        protein_identification, 
 
134
                                                peptide_identifications);
 
135
  // TODO more tests...
 
136
  
 
137
END_SECTION
 
138
 
 
139
START_SECTION((void load(const String &filename, ProteinIdentification &protein_identification, std::vector< PeptideIdentification > &id_data, std::map< String, std::vector< AASequence > > &peptides)))
 
140
        std::map<String, vector<AASequence> > modified_peptides;
 
141
        AASequence aa_sequence_1;
 
142
        AASequence aa_sequence_2;
 
143
        AASequence aa_sequence_3;
 
144
        vector<AASequence> temp;
 
145
        
 
146
        aa_sequence_1.setStringSequence("LHASGITVTEIPVTATNFK");
 
147
        aa_sequence_1.setModification(16, "Deamidated");
 
148
        aa_sequence_2.setStringSequence("MRSLGYVAVISAVATDTDK");
 
149
        aa_sequence_2.setModification(2, "Phospho");
 
150
        aa_sequence_3.setStringSequence("HSKLSAK");
 
151
        aa_sequence_3.setModification(4, "Phospho");
 
152
        temp.push_back(aa_sequence_1);
 
153
        temp.push_back(aa_sequence_2);
 
154
        modified_peptides.insert(make_pair("789.83", temp));
 
155
        temp.clear();
 
156
        temp.push_back(aa_sequence_3);
 
157
        modified_peptides.insert(make_pair("135.29", temp));
 
158
                
 
159
        xml_file.load(OPENMS_GET_TEST_DATA_PATH("MascotXMLFile_test_1.mascotXML"),
 
160
                                                                protein_identification, 
 
161
                                                        peptide_identifications,
 
162
                                                        modified_peptides);
 
163
        
 
164
        TEST_EQUAL(peptide_identifications.size(), 3)
 
165
        TOLERANCE_ABSOLUTE(0.0001)
 
166
        TEST_REAL_SIMILAR(peptide_identifications[0].getMetaValue("MZ"), 789.83)
 
167
        TEST_REAL_SIMILAR(peptide_identifications[1].getMetaValue("MZ"), 135.29)
 
168
        TEST_REAL_SIMILAR(peptide_identifications[2].getMetaValue("MZ"), 982.58)
 
169
        TOLERANCE_ABSOLUTE(0.00001)     
 
170
        TEST_EQUAL(protein_identification.getHits().size(), 2)
 
171
        TEST_EQUAL(protein_identification.getHits()[0].getAccession(), "AAN17824")
 
172
        TEST_EQUAL(protein_identification.getHits()[1].getAccession(), "GN1736")
 
173
        TEST_REAL_SIMILAR(protein_identification.getHits()[0].getScore(), 619)
 
174
        TEST_REAL_SIMILAR(protein_identification.getHits()[1].getScore(), 293)
 
175
        TEST_EQUAL(protein_identification.getScoreType(), "Mascot")
 
176
        TEST_EQUAL(protein_identification.getDateTime().get(), "2006-03-09 11:31:52")
 
177
        
 
178
        TEST_REAL_SIMILAR(peptide_identifications[0].getSignificanceThreshold(), 31.8621)
 
179
        TEST_EQUAL(peptide_identifications[0].getHits().size(), 2)
 
180
        
 
181
        peptide_hit = peptide_identifications[0].getHits()[0];
 
182
        references = peptide_hit.getProteinAccessions();
 
183
        TEST_EQUAL(references.size(), 2)
 
184
        TEST_EQUAL(references[0], "AAN17824")
 
185
        TEST_EQUAL(references[1], "GN1736")
 
186
        peptide_hit = peptide_identifications[0].getHits()[1];
 
187
        references = peptide_hit.getProteinAccessions();
 
188
        TEST_EQUAL(references.size(), 1)
 
189
        TEST_EQUAL(references[0], "AAN17824")
 
190
        peptide_hit = peptide_identifications[1].getHits()[0];
 
191
        references = peptide_hit.getProteinAccessions();
 
192
        TEST_EQUAL(references.size(), 1)
 
193
        TEST_EQUAL(references[0], "GN1736")
 
194
        
 
195
        TEST_EQUAL(peptide_identifications[1].getHits().size(), 1)
 
196
        TEST_REAL_SIMILAR(peptide_identifications[0].getHits()[0].getScore(), 33.85)
 
197
        TEST_REAL_SIMILAR(peptide_identifications[0].getHits()[1].getScore(), 33.12)
 
198
        TEST_REAL_SIMILAR(peptide_identifications[1].getHits()[0].getScore(), 43.9)
 
199
        TEST_EQUAL(peptide_identifications[0].getScoreType(), "Mascot")
 
200
        TEST_EQUAL(peptide_identifications[1].getScoreType(), "Mascot")
 
201
        TEST_EQUAL(protein_identification.getDateTime() == date, true)  
 
202
        TEST_EQUAL(peptide_identifications[0].getHits()[0].getSequence(), aa_sequence_1)
 
203
        TEST_EQUAL(peptide_identifications[0].getHits()[1].getSequence(), aa_sequence_2)
 
204
        TEST_EQUAL(peptide_identifications[1].getHits()[0].getSequence(), aa_sequence_3)
 
205
END_SECTION
 
206
 
 
207
/////////////////////////////////////////////////////////////
 
208
/////////////////////////////////////////////////////////////
 
209
END_TEST