Browse code

Fix bug in score when more cvParams than expected are read - close #136

Laurent authored on 26/05/2018 20:44:04
Showing 2 changed files

... ...
@@ -3,6 +3,8 @@ CHANGES IN VERSION 2.15.1
3 3
  o Fix typo (see https://github.com/sneumann/mzR/pull/162)
4 4
  o New .hasSpectra and .hasChromatograms private function (see
5 5
    https://github.com/lgatto/MSnbase/issues/343)
6
+ o Fix bug in score when more cvParams than expected are read - see
7
+   https://github.com/sneumann/mzR/issues/136 <2018-05-26 Sat>
6 8
 
7 9
 CHANGES IN VERSION 2.15.0
8 10
 -------------------------
... ...
@@ -35,7 +37,7 @@ CHANGES IN VERSION 2.13.3
35 37
  o Link against Rhdf5lib, allows to read mz5 also on Windows
36 38
  o Use Rhdf5lib 1.1.4 with c++ headers in /include
37 39
  o fix BiocStyle related issue in Vignette on Windows
38
- 
40
+
39 41
 CHANGES IN VERSION 2.13.2
40 42
 --------------------------
41 43
  o Add chromatogramHeader method to read header information for chromatograms
... ...
@@ -47,12 +49,12 @@ CHANGES IN VERSION 2.13.1
47 49
    the header function (see MSnbase issue #278).
48 50
  o openMsFile automatically determine the backend to use based on file extension
49 51
    and content.
50
- 
52
+
51 53
 CHANGES IN VERSION 2.11.11
52 54
 --------------------------
53 55
  o Fix problem in writeMSData: ensure precursor data is saved even if precursor
54 56
    scan is not available (see MSnbase issue #245).
55
- 
57
+
56 58
 CHANGES IN VERSION 2.11.10
57 59
 --------------------------
58 60
  o Fix problem that can cause a SEGFAULT in writeMSData/copyWriteMSData when MS
... ...
@@ -70,33 +72,33 @@ CHANGES IN VERSION 2.11.8
70 72
  o Report the spectrum ID in the header data.frame (column spectrumId).
71 73
  o Fix in copyWriteMSData and writeMSData ensuring that MSn data is correctly
72 74
  o Import pwiz r11174 fix for mzML without <componentList> (see #113).
73
- 
75
+
74 76
 CHANGES IN VERSION 2.11.7
75 77
 -------------------------
76 78
  o Nothing yet.
77 79
  o Import fix by Brian Pratt (pwiz r11174) for mzML without <componentList>
78
-   Another way to fix #113 
80
+   Another way to fix #113
79 81
  o Removing mz5 support from manual page, as currently unsupported.
80
- 
82
+
81 83
 CHANGES IN VERSION 2.11.6
82 84
 -------------------------
83 85
  o runInfo returns the run start time stamp from files providing this
84 86
    information (mzML files).
85
- 
87
+
86 88
 CHANGES IN VERSION 2.11.5
87 89
 -------------------------
88 90
  o writeMSData and copyWriteMSData functions enabling to export MS data to
89 91
    mzML or mzXML files.
90
- 
92
+
91 93
 CHANGES IN VERSION 2.11.4
92 94
 -------------------------
93 95
  o Use full TMT file pattern to select a single file
94
- 
96
+
95 97
 CHANGES IN VERSION 2.11.3
96 98
 -------------------------
97 99
  o Read ion injection time from mzML files and add it to the data.frame returned
98 100
    by the header function.
99
- 
101
+
100 102
 CHANGES IN VERSION 2.11.2
101 103
 -------------------------
102 104
  o New getScanHeaderInfo and getAllScanHeaderInfo implementations for the pwiz
... ...
@@ -109,7 +111,7 @@ CHANGES IN VERSION 2.11.1
109 111
 CHANGES IN VERSION 2.11.0
110 112
 -------------------------
111 113
  o Bioc devel 3.6
112
- 
114
+
113 115
 CHANGES IN VERSION 2.10.0
114 116
 -------------------------
115 117
  o Bioc release 3.5
... ...
@@ -120,7 +122,7 @@ CHANGES IN VERSION 2.9.11
120 122
 
121 123
 CHANGES IN VERSION 2.9.10
122 124
 -------------------------
123
- o Remove register keyword causing WARNING. 
125
+ o Remove register keyword causing WARNING.
124 126
 
125 127
 CHANGES IN VERSION 2.9.9
126 128
 ------------------------
... ...
@@ -137,25 +139,25 @@ CHANGES IN VERSION 2.9.7
137 139
 CHANGES IN VERSION 2.9.6
138 140
 ------------------------
139 141
  o Compile on macOS, but hdf5 path hard-coded
140
- 
142
+
141 143
 CHANGES IN VERSION 2.9.5
142 144
 ------------------------
143 145
  o Add missing boost/config/platform/macos.hpp <2017-01-25 Wed>
144
- 
146
+
145 147
 CHANGES IN VERSION 2.9.4
146 148
 ------------------------
147 149
  o New chromatogram accessors (for pwiz backend only) - see issue #73
148 150
    <2017-01-23 Mon>
149
- 
151
+
150 152
 CHANGES IN VERSION 2.9.3
151 153
 ------------------------
152 154
  o bump to new Rcpp 0.12.8 version <2017-01-05 Thu>
153
- 
155
+
154 156
 CHANGES IN VERSION 2.9.2
155 157
 ------------------------
156 158
  o cleanup CFLAGS and LIBS for libnetcdf
157 159
  o add file missing for oaxaca (Apple clang 3.5svn / 600.0.57)
158
- 
160
+
159 161
 CHANGES IN VERSION 2.9.1
160 162
 ------------------------
161 163
  o Delete RAMPAdapter pointer in pwiz backend (by jotsetung)
... ...
@@ -167,7 +169,7 @@ CHANGES IN VERSION 2.9.1
167 169
 CHANGES IN VERSION 2.9.0
168 170
 ------------------------
169 171
  o Bioc devel 3.5
170
- 
172
+
171 173
 CHANGES IN VERSION 2.8.0
172 174
 ------------------------
173 175
  o Bioc release 3.4
... ...
@@ -175,40 +177,40 @@ CHANGES IN VERSION 2.8.0
175 177
 CHANGES IN VERSION 2.7.13
176 178
 -------------------------
177 179
  o Fix waring on OSX (see issue #60)
178
- 
180
+
179 181
 CHANGES IN VERSION 2.7.12
180 182
 -------------------------
181 183
  o Fixing last warning on MacOS
182
- 
184
+
183 185
 CHANGES IN VERSION 2.7.11
184 186
 -------------------------
185 187
  o Fix failing example and test due to updated msdata::protemics data
186
- 
188
+
187 189
 CHANGES IN VERSION 2.7.10
188 190
 -------------------------
189 191
  o compiling and loading on Windows (hopefully)
190
- 
192
+
191 193
 CHANGES IN VERSION 2.7.9
192 194
 ------------------------
193
- o Updating Makevars.win 
194
- 
195
+ o Updating Makevars.win
196
+
195 197
 CHANGES IN VERSION 2.7.8
196 198
 ------------------------
197 199
  o compile pwiz when installing on Windows <2016-09-26 Mon>
198
- 
200
+
199 201
 CHANGES IN VERSION 2.7.7
200 202
 ------------------------
201 203
  o add netcdf static lib; potential incompatibility <2016-09-22 Thu>
202
- 
204
+
203 205
 CHANGES IN VERSION 2.7.6
204 206
 ------------------------
205 207
  o new isolationWindow accessor <2016-09-23 Fri>
206
- 
208
+
207 209
 CHANGES IN VERSION 2.7.5
208 210
 ------------------------
209 211
  o Apply Martin's free/delete patch - see
210 212
    https://github.com/sneumann/mzR/issues/52 <2016-09-22 Thu>
211
- 
213
+
212 214
 CHANGES IN VERSION 2.7.4
213 215
 ------------------------
214 216
  o upgrade pwiz
... ...
@@ -22,7 +22,7 @@ Rcpp::List RcppIdent::getIDInfo(  )
22 22
 
23 23
     for (size_t i = 0; i < as.size(); i++)
24 24
     {
25
-        software[i] = as[i]->name + " " + as[i]->version + " " + (as[i]->contactRolePtr.get()!=0?as[i]->contactRolePtr->contactPtr->name:"") ;
25
+	software[i] = as[i]->name + " " + as[i]->version + " " + (as[i]->contactRolePtr.get()!=0?as[i]->contactRolePtr->contactPtr->name:"") ;
26 26
     }
27 27
 
28 28
     vector<SpectrumIdentificationProtocolPtr> sip = mzid->analysisProtocolCollection.spectrumIdentificationProtocol;
... ...
@@ -30,12 +30,12 @@ Rcpp::List RcppIdent::getIDInfo(  )
30 30
     string parentTolerance = "";
31 31
     if(!sip[0]->fragmentTolerance.empty())
32 32
     {
33
-        fragmentTolerance = sip[0]->fragmentTolerance.cvParams[0].value + " " + sip[0]->fragmentTolerance.cvParam(MS_search_tolerance_plus_value).unitsName();
33
+	fragmentTolerance = sip[0]->fragmentTolerance.cvParams[0].value + " " + sip[0]->fragmentTolerance.cvParam(MS_search_tolerance_plus_value).unitsName();
34 34
     }
35 35
 
36 36
     if(!sip[0]->parentTolerance.empty())
37 37
     {
38
-        parentTolerance = sip[0]->parentTolerance.cvParams[0].value + " " + sip[0]->parentTolerance.cvParam(MS_search_tolerance_plus_value).unitsName();
38
+	parentTolerance = sip[0]->parentTolerance.cvParams[0].value + " " + sip[0]->parentTolerance.cvParam(MS_search_tolerance_plus_value).unitsName();
39 39
     }
40 40
 
41 41
     vector<SearchModificationPtr> sm = sip[0]->modificationParams;
... ...
@@ -43,7 +43,7 @@ Rcpp::List RcppIdent::getIDInfo(  )
43 43
     Rcpp::StringVector mod(sm.size());
44 44
     for(size_t i = 0; i < sm.size(); i++)
45 45
     {
46
-        mod[i] = cvTermInfo(sm[i]->cvParams[0].cvid).name;
46
+	mod[i] = cvTermInfo(sm[i]->cvParams[0].cvid).name;
47 47
     }
48 48
 
49 49
     vector<EnzymePtr> enz = sip[0]->enzymes.enzymes;
... ...
@@ -56,38 +56,38 @@ Rcpp::List RcppIdent::getIDInfo(  )
56 56
 
57 57
     for (size_t i = 0; i < enz.size(); i++)
58 58
     {
59
-        name[i] = cvTermInfo(cleavageAgent(*enz[i].get())).name;
60
-        nTermGain[i] = enz[i]->nTermGain;
61
-        cTermGain[i] = enz[i]->cTermGain;
62
-        minDistance[i] = enz[i]->minDistance;
63
-        missedCleavages[i] = enz[i]->missedCleavages;
59
+	name[i] = cvTermInfo(cleavageAgent(*enz[i].get())).name;
60
+	nTermGain[i] = enz[i]->nTermGain;
61
+	cTermGain[i] = enz[i]->cTermGain;
62
+	minDistance[i] = enz[i]->minDistance;
63
+	missedCleavages[i] = enz[i]->missedCleavages;
64 64
     }
65 65
 
66 66
     enzymes = Rcpp::List::create(
67
-                  Rcpp::_["name"]  = name,
68
-                  Rcpp::_["nTermGain"]  = nTermGain,
69
-                  Rcpp::_["cTermGain"]  = cTermGain,
70
-                  Rcpp::_["minDistance"]  = minDistance,
71
-                  Rcpp::_["missedCleavages"]  = missedCleavages
72
-              );
67
+		  Rcpp::_["name"]  = name,
68
+		  Rcpp::_["nTermGain"]  = nTermGain,
69
+		  Rcpp::_["cTermGain"]  = cTermGain,
70
+		  Rcpp::_["minDistance"]  = minDistance,
71
+		  Rcpp::_["missedCleavages"]  = missedCleavages
72
+	      );
73 73
 
74 74
     vector<SpectraDataPtr> sd = mzid->dataCollection.inputs.spectraData;
75 75
     Rcpp::StringVector spectra(sd.size());
76 76
     for (size_t i = 0; i < sd.size(); i++)
77 77
     {
78
-        spectra[i] = sd[i]->location;
78
+	spectra[i] = sd[i]->location;
79 79
     }
80 80
 
81 81
     return Rcpp::List::create(
82
-               Rcpp::_["FileProvider"]	= provider,
83
-               Rcpp::_["CreationDate"]	= date,
84
-               Rcpp::_["software"]	= software,
85
-               Rcpp::_["ModificationSearched"]	= mod,
86
-               Rcpp::_["FragmentTolerance"]	= fragmentTolerance,
87
-               Rcpp::_["ParentTolerance"]	= parentTolerance,
88
-               Rcpp::_["enzymes"]	= enzymes,
89
-               Rcpp::_["SpectraSource"]	= spectra
90
-           );
82
+	       Rcpp::_["FileProvider"]	= provider,
83
+	       Rcpp::_["CreationDate"]	= date,
84
+	       Rcpp::_["software"]	= software,
85
+	       Rcpp::_["ModificationSearched"]	= mod,
86
+	       Rcpp::_["FragmentTolerance"]	= fragmentTolerance,
87
+	       Rcpp::_["ParentTolerance"]	= parentTolerance,
88
+	       Rcpp::_["enzymes"]	= enzymes,
89
+	       Rcpp::_["SpectraSource"]	= spectra
90
+	   );
91 91
 
92 92
 }
93 93
 
... ...
@@ -115,70 +115,70 @@ Rcpp::DataFrame RcppIdent::getPsmInfo(  )
115 115
 
116 116
     for (size_t i = 0; i < spectrumIdResult.size(); i++)
117 117
     {
118
-        for(size_t j = 0; j < spectrumIdResult[i]->spectrumIdentificationItem.size(); j++)
119
-        {
120
-            for(size_t k = 0; k < spectrumIdResult[i]->spectrumIdentificationItem[j]->peptideEvidencePtr.size(); k++)
121
-            {
122
-
123
-                spectrumID.push_back(spectrumIdResult[i]->spectrumID);
124
-                chargeState.push_back(spectrumIdResult[i]->spectrumIdentificationItem[j]->chargeState);
125
-                rank.push_back(spectrumIdResult[i]->spectrumIdentificationItem[j]->rank);
126
-                passThreshold.push_back(spectrumIdResult[i]->spectrumIdentificationItem[j]->passThreshold);
127
-                experimentalMassToCharge.push_back(spectrumIdResult[i]->spectrumIdentificationItem[j]->experimentalMassToCharge);
128
-                calculatedMassToCharge.push_back(spectrumIdResult[i]->spectrumIdentificationItem[j]->calculatedMassToCharge);
129
-                seq.push_back(spectrumIdResult[i]->spectrumIdentificationItem[j]->peptidePtr->peptideSequence);
130
-                modification.push_back(spectrumIdResult[i]->spectrumIdentificationItem[j]->peptidePtr->modification.size());
131
-                isDecoy.push_back(spectrumIdResult[i]->spectrumIdentificationItem[j]->peptideEvidencePtr[k]->isDecoy);
132
-                pre.push_back(string(1, spectrumIdResult[i]->spectrumIdentificationItem[j]->peptideEvidencePtr[k]->pre));
133
-                post.push_back(string(1, spectrumIdResult[i]->spectrumIdentificationItem[j]->peptideEvidencePtr[k]->post));
134
-                start.push_back(spectrumIdResult[i]->spectrumIdentificationItem[j]->peptideEvidencePtr[k]->start);
135
-                end.push_back(spectrumIdResult[i]->spectrumIdentificationItem[j]->peptideEvidencePtr[k]->end);
136
-                if(spectrumIdResult[i]->spectrumIdentificationItem[j]->peptideEvidencePtr[k]->dbSequencePtr.get()!=0)
137
-                {
138
-                    DBSequenceID.push_back(spectrumIdResult[i]->spectrumIdentificationItem[j]->peptideEvidencePtr[k]->dbSequencePtr->accession);
139
-                    DBSequenceLen.push_back(spectrumIdResult[i]->spectrumIdentificationItem[j]->peptideEvidencePtr[k]->dbSequencePtr->length);
140
-                    DBseq.push_back(spectrumIdResult[i]->spectrumIdentificationItem[j]->peptideEvidencePtr[k]->dbSequencePtr->seq);
141
-                    if(spectrumIdResult[i]->spectrumIdentificationItem[j]->peptideEvidencePtr[k]->dbSequencePtr->cvParams.size() > 0)
142
-                    {
143
-                        DBdesc.push_back(spectrumIdResult[i]->spectrumIdentificationItem[j]->peptideEvidencePtr[k]->dbSequencePtr->cvParams[0].value);
144
-                    }
145
-                    else
146
-                    {
147
-                        DBdesc.push_back("");
148
-                    }
149
-                }
150
-                else
151
-                {
152
-                    DBSequenceID.push_back("");
153
-                    DBseq.push_back("");
154
-                    DBdesc.push_back("");
155
-                }
156
-
157
-            }
158
-        }
118
+	for(size_t j = 0; j < spectrumIdResult[i]->spectrumIdentificationItem.size(); j++)
119
+	{
120
+	    for(size_t k = 0; k < spectrumIdResult[i]->spectrumIdentificationItem[j]->peptideEvidencePtr.size(); k++)
121
+	    {
122
+
123
+		spectrumID.push_back(spectrumIdResult[i]->spectrumID);
124
+		chargeState.push_back(spectrumIdResult[i]->spectrumIdentificationItem[j]->chargeState);
125
+		rank.push_back(spectrumIdResult[i]->spectrumIdentificationItem[j]->rank);
126
+		passThreshold.push_back(spectrumIdResult[i]->spectrumIdentificationItem[j]->passThreshold);
127
+		experimentalMassToCharge.push_back(spectrumIdResult[i]->spectrumIdentificationItem[j]->experimentalMassToCharge);
128
+		calculatedMassToCharge.push_back(spectrumIdResult[i]->spectrumIdentificationItem[j]->calculatedMassToCharge);
129
+		seq.push_back(spectrumIdResult[i]->spectrumIdentificationItem[j]->peptidePtr->peptideSequence);
130
+		modification.push_back(spectrumIdResult[i]->spectrumIdentificationItem[j]->peptidePtr->modification.size());
131
+		isDecoy.push_back(spectrumIdResult[i]->spectrumIdentificationItem[j]->peptideEvidencePtr[k]->isDecoy);
132
+		pre.push_back(string(1, spectrumIdResult[i]->spectrumIdentificationItem[j]->peptideEvidencePtr[k]->pre));
133
+		post.push_back(string(1, spectrumIdResult[i]->spectrumIdentificationItem[j]->peptideEvidencePtr[k]->post));
134
+		start.push_back(spectrumIdResult[i]->spectrumIdentificationItem[j]->peptideEvidencePtr[k]->start);
135
+		end.push_back(spectrumIdResult[i]->spectrumIdentificationItem[j]->peptideEvidencePtr[k]->end);
136
+		if(spectrumIdResult[i]->spectrumIdentificationItem[j]->peptideEvidencePtr[k]->dbSequencePtr.get()!=0)
137
+		{
138
+		    DBSequenceID.push_back(spectrumIdResult[i]->spectrumIdentificationItem[j]->peptideEvidencePtr[k]->dbSequencePtr->accession);
139
+		    DBSequenceLen.push_back(spectrumIdResult[i]->spectrumIdentificationItem[j]->peptideEvidencePtr[k]->dbSequencePtr->length);
140
+		    DBseq.push_back(spectrumIdResult[i]->spectrumIdentificationItem[j]->peptideEvidencePtr[k]->dbSequencePtr->seq);
141
+		    if(spectrumIdResult[i]->spectrumIdentificationItem[j]->peptideEvidencePtr[k]->dbSequencePtr->cvParams.size() > 0)
142
+		    {
143
+			DBdesc.push_back(spectrumIdResult[i]->spectrumIdentificationItem[j]->peptideEvidencePtr[k]->dbSequencePtr->cvParams[0].value);
144
+		    }
145
+		    else
146
+		    {
147
+			DBdesc.push_back("");
148
+		    }
149
+		}
150
+		else
151
+		{
152
+		    DBSequenceID.push_back("");
153
+		    DBseq.push_back("");
154
+		    DBdesc.push_back("");
155
+		}
156
+
157
+	    }
158
+	}
159 159
     }
160 160
 
161 161
 
162 162
 
163 163
     return Rcpp::DataFrame::create(
164
-               Rcpp::_["spectrumID"]	= spectrumID,
165
-               Rcpp::_["chargeState"]	= chargeState,
166
-               Rcpp::_["rank"]	= rank,
167
-               Rcpp::_["passThreshold"]	= passThreshold,
168
-               Rcpp::_["experimentalMassToCharge"]	= experimentalMassToCharge,
169
-               Rcpp::_["calculatedMassToCharge"]	= calculatedMassToCharge,
170
-               Rcpp::_["sequence"]	= seq,
171
-               Rcpp::_["modNum"]	= modification,
172
-               Rcpp::_["isDecoy"]	= isDecoy,
173
-               Rcpp::_["post"]	= post,
174
-               Rcpp::_["pre"]	= pre,
175
-               Rcpp::_["start"]	= start,
176
-               Rcpp::_["end"]	= end,
177
-               Rcpp::_["DatabaseAccess"]	= DBSequenceID,
178
-               Rcpp::_["DBseqLength"]	= DBSequenceLen,
179
-               Rcpp::_["DatabaseSeq"]	= DBseq,
180
-               Rcpp::_["DatabaseDescription"]	= DBdesc
181
-           );
164
+	       Rcpp::_["spectrumID"]	= spectrumID,
165
+	       Rcpp::_["chargeState"]	= chargeState,
166
+	       Rcpp::_["rank"]	= rank,
167
+	       Rcpp::_["passThreshold"]	= passThreshold,
168
+	       Rcpp::_["experimentalMassToCharge"]	= experimentalMassToCharge,
169
+	       Rcpp::_["calculatedMassToCharge"]	= calculatedMassToCharge,
170
+	       Rcpp::_["sequence"]	= seq,
171
+	       Rcpp::_["modNum"]	= modification,
172
+	       Rcpp::_["isDecoy"]	= isDecoy,
173
+	       Rcpp::_["post"]	= post,
174
+	       Rcpp::_["pre"]	= pre,
175
+	       Rcpp::_["start"]	= start,
176
+	       Rcpp::_["end"]	= end,
177
+	       Rcpp::_["DatabaseAccess"]	= DBSequenceID,
178
+	       Rcpp::_["DBseqLength"]	= DBSequenceLen,
179
+	       Rcpp::_["DatabaseSeq"]	= DBseq,
180
+	       Rcpp::_["DatabaseDescription"]	= DBdesc
181
+	   );
182 182
 }
183 183
 
184 184
 Rcpp::DataFrame RcppIdent::getModInfo(  )
... ...
@@ -193,28 +193,28 @@ Rcpp::DataFrame RcppIdent::getModInfo(  )
193 193
 
194 194
     for (size_t i = 0; i < spectrumIdResult.size(); i++)
195 195
     {
196
-        for(size_t k = 0; k < spectrumIdResult[i]->spectrumIdentificationItem.size() ; k++)
197
-        {
198
-            if(spectrumIdResult[i]->spectrumIdentificationItem[k]->peptidePtr->modification.size()>0)
199
-            {
200
-                for(size_t j = 0 ; j < spectrumIdResult[i]->spectrumIdentificationItem[k]->peptidePtr->modification.size(); j++)
201
-                {
202
-                    spectrumID.push_back(spectrumIdResult[i]->spectrumID);
203
-                    seq.push_back(spectrumIdResult[i]->spectrumIdentificationItem[k]->peptidePtr->peptideSequence);
204
-                    name.push_back(cvTermInfo(spectrumIdResult[i]->spectrumIdentificationItem[k]->peptidePtr->modification[j]->cvParams[0].cvid).name);
205
-                    mass.push_back(spectrumIdResult[i]->spectrumIdentificationItem[k]->peptidePtr->modification[j]->monoisotopicMassDelta);
206
-                    loc.push_back(spectrumIdResult[i]->spectrumIdentificationItem[k]->peptidePtr->modification[j]->location);
207
-                }
208
-            }
209
-        }
196
+	for(size_t k = 0; k < spectrumIdResult[i]->spectrumIdentificationItem.size() ; k++)
197
+	{
198
+	    if(spectrumIdResult[i]->spectrumIdentificationItem[k]->peptidePtr->modification.size()>0)
199
+	    {
200
+		for(size_t j = 0 ; j < spectrumIdResult[i]->spectrumIdentificationItem[k]->peptidePtr->modification.size(); j++)
201
+		{
202
+		    spectrumID.push_back(spectrumIdResult[i]->spectrumID);
203
+		    seq.push_back(spectrumIdResult[i]->spectrumIdentificationItem[k]->peptidePtr->peptideSequence);
204
+		    name.push_back(cvTermInfo(spectrumIdResult[i]->spectrumIdentificationItem[k]->peptidePtr->modification[j]->cvParams[0].cvid).name);
205
+		    mass.push_back(spectrumIdResult[i]->spectrumIdentificationItem[k]->peptidePtr->modification[j]->monoisotopicMassDelta);
206
+		    loc.push_back(spectrumIdResult[i]->spectrumIdentificationItem[k]->peptidePtr->modification[j]->location);
207
+		}
208
+	    }
209
+	}
210 210
     }
211 211
 
212 212
     return Rcpp::DataFrame::create(
213
-               Rcpp::_["spectrumID"]	= spectrumID,
214
-               Rcpp::_["sequence"]	= seq,
215
-               Rcpp::_["name"]	= name,
216
-               Rcpp::_["mass"]	= mass,
217
-               Rcpp::_["location"]	= loc);
213
+	       Rcpp::_["spectrumID"]	= spectrumID,
214
+	       Rcpp::_["sequence"]	= seq,
215
+	       Rcpp::_["name"]	= name,
216
+	       Rcpp::_["mass"]	= mass,
217
+	       Rcpp::_["location"]	= loc);
218 218
 
219 219
 }
220 220
 
... ...
@@ -231,92 +231,81 @@ Rcpp::DataFrame RcppIdent::getSubInfo(  )
231 231
     for (size_t i = 0; i < spectrumIdResult.size(); i++)
232 232
     {
233 233
 
234
-        if(spectrumIdResult[i]->spectrumIdentificationItem[0]->peptidePtr->substitutionModification.size() > 0)
235
-        {
236
-            for(size_t j = 0 ; j < spectrumIdResult[i]->spectrumIdentificationItem[0]->peptidePtr->substitutionModification.size(); j++)
237
-            {
238
-                spectrumID.push_back(spectrumIdResult[i]->spectrumID);
239
-                seq.push_back(spectrumIdResult[i]->spectrumIdentificationItem[0]->peptidePtr->peptideSequence);
240
-                originalResidue.push_back(spectrumIdResult[i]->spectrumIdentificationItem[0]->peptidePtr->substitutionModification[j]->originalResidue);
241
-                replacementResidue.push_back(spectrumIdResult[i]->spectrumIdentificationItem[0]->peptidePtr->substitutionModification[j]->replacementResidue);
242
-                loc.push_back(spectrumIdResult[i]->spectrumIdentificationItem[0]->peptidePtr->substitutionModification[j]->location);
243
-            }
244
-        }
234
+	if(spectrumIdResult[i]->spectrumIdentificationItem[0]->peptidePtr->substitutionModification.size() > 0)
235
+	{
236
+	    for(size_t j = 0 ; j < spectrumIdResult[i]->spectrumIdentificationItem[0]->peptidePtr->substitutionModification.size(); j++)
237
+	    {
238
+		spectrumID.push_back(spectrumIdResult[i]->spectrumID);
239
+		seq.push_back(spectrumIdResult[i]->spectrumIdentificationItem[0]->peptidePtr->peptideSequence);
240
+		originalResidue.push_back(spectrumIdResult[i]->spectrumIdentificationItem[0]->peptidePtr->substitutionModification[j]->originalResidue);
241
+		replacementResidue.push_back(spectrumIdResult[i]->spectrumIdentificationItem[0]->peptidePtr->substitutionModification[j]->replacementResidue);
242
+		loc.push_back(spectrumIdResult[i]->spectrumIdentificationItem[0]->peptidePtr->substitutionModification[j]->location);
243
+	    }
244
+	}
245 245
     }
246 246
 
247 247
     return Rcpp::DataFrame::create(
248
-               Rcpp::_["spectrumID"]	= spectrumID,
249
-               Rcpp::_["sequence"]	= seq,
250
-               Rcpp::_["originalResidue"]	= originalResidue,
251
-               Rcpp::_["replacementResidue"]	= replacementResidue,
252
-               Rcpp::_["location"]	= loc
253
-           );
248
+	       Rcpp::_["spectrumID"]	= spectrumID,
249
+	       Rcpp::_["sequence"]	= seq,
250
+	       Rcpp::_["originalResidue"]	= originalResidue,
251
+	       Rcpp::_["replacementResidue"]	= replacementResidue,
252
+	       Rcpp::_["location"]	= loc
253
+	   );
254 254
 
255 255
 }
256 256
 
257
-Rcpp::DataFrame RcppIdent::getScore(  )
258
-{
259
-    vector<SpectrumIdentificationResultPtr> spectrumIdResult = mzid->analysisCollection.spectrumIdentification[0]->spectrumIdentificationListPtr->spectrumIdentificationResult;
260
-    vector<string> spectrumID;
261
-    vector<string> names;
262
-    int count = 0;
263
-
264
-    for(size_t i = 0; i < spectrumIdResult[0]->spectrumIdentificationItem[0]->cvParams.size(); i++)
265
-    {
266
-        if(!spectrumIdResult[0]->spectrumIdentificationItem[0]->cvParams[i].value.empty())
267
-        {
268
-            count++;
269
-            names.push_back(cvTermInfo(spectrumIdResult[0]->spectrumIdentificationItem[0]->cvParams[i].cvid).name);
270
-        }
257
+Rcpp::DataFrame RcppIdent::getScore(  ) {
258
+  vector<SpectrumIdentificationResultPtr> spectrumIdResult = mzid->analysisCollection.spectrumIdentification[0]->spectrumIdentificationListPtr->spectrumIdentificationResult;
259
+  vector<string> spectrumID;
260
+  vector<string> names;
261
+  int count = 0;
262
+  int nCvParams = 0;
263
+
264
+  for (size_t i = 0; i < spectrumIdResult[0]->spectrumIdentificationItem[0]->cvParams.size(); i++) {
265
+    if (!spectrumIdResult[0]->spectrumIdentificationItem[0]->cvParams[i].value.empty()) {
266
+      count++;
267
+      nCvParams++;
268
+      names.push_back(cvTermInfo(spectrumIdResult[0]->spectrumIdentificationItem[0]->cvParams[i].cvid).name);
271 269
     }
272
-    if(count == 0)
273
-    {
274
-        Rcpp::Rcout << "No scoring information available" << std::endl;
275
-        return Rcpp::DataFrame::create();
270
+  }
271
+  if(count == 0) {
272
+    Rcpp::Rcout << "No scoring information available" << std::endl;
273
+    return Rcpp::DataFrame::create();
274
+  } else {
275
+    vector<vector<double> > score(count);
276
+    for (size_t i = 0; i < spectrumIdResult.size(); i++) {
277
+      for (size_t k = 0; k < spectrumIdResult[i]->spectrumIdentificationItem.size(); k++) {
278
+	for (size_t n = 0; n < spectrumIdResult[i]->spectrumIdentificationItem[k]->peptideEvidencePtr.size(); n++) {
279
+	  spectrumID.push_back(spectrumIdResult[i]->spectrumID);
280
+	  count = 0;
281
+
282
+	  // The original loop iterated to j <
283
+	  // spectrumIdResult[i]->spectrumIdentificationItem[k]->cvParams.size()
284
+	  // which failed when some SpectrumIdentificationItem
285
+	  // suddently have additional cvParams, such as in Mascot
286
+	  // results - see https://github.com/sneumann/mzR/issues/136
287
+	  for (size_t j = 0; j < nCvParams; j++) {
288
+	    if (!spectrumIdResult[i]->spectrumIdentificationItem[k]->cvParams[j].value.empty()) {
289
+	      score[count].push_back(lexical_cast<double>(spectrumIdResult[i]->spectrumIdentificationItem[k]->cvParams[j].value));
290
+	      count++;
291
+	    }
292
+	  }
293
+	}
294
+      }
276 295
     }
277
-    else
278
-    {
279
-        vector<vector<double> > score(count);
280
-
281
-        for (size_t i = 0; i < spectrumIdResult.size(); i++)
282
-        {
283
-
284
-            for(size_t k = 0; k < spectrumIdResult[i]->spectrumIdentificationItem.size(); k++)
285
-            {
286
-                for(size_t n = 0; n < spectrumIdResult[i]->spectrumIdentificationItem[k]->peptideEvidencePtr.size(); n++)
287
-                {
288
-                    spectrumID.push_back(spectrumIdResult[i]->spectrumID);
289
-                    count = 0;
290
-                    for(size_t j = 0; j < spectrumIdResult[i]->spectrumIdentificationItem[k]->cvParams.size(); j++)
291
-                    {
292
-                        if(!spectrumIdResult[i]->spectrumIdentificationItem[k]->cvParams[j].value.empty())
293
-                        {
294
-                            score[count].push_back(lexical_cast<double>(spectrumIdResult[i]->spectrumIdentificationItem[k]->cvParams[j].value));
295
-                            count++;
296
-                        }
297
-
298
-                    }
299
-                }
300
-
301
-            }
302
-        }
303
-
304
-        Rcpp::List res(score.size() + 1);
305
-        
306
-        names.insert(names.begin(), "spectrumID");
307
-        
308
-        res[0] = Rcpp::wrap(spectrumID);
309
-        
310
-        for(size_t i = 0; i < score.size(); i++)
311
-        {
312
-			res[i + 1] = Rcpp::wrap(score[i]);
313
-        }
314
-        
315
-        res.attr("names") = names;
316
-        Rcpp::DataFrame out(res);
317
-
318
-        return out;
296
+
297
+    Rcpp::List res(score.size() + 1);
298
+    names.insert(names.begin(), "spectrumID");
299
+    res[0] = Rcpp::wrap(spectrumID);
300
+    for(size_t i = 0; i < score.size(); i++) {
301
+      res[i + 1] = Rcpp::wrap(score[i]);
319 302
     }
303
+
304
+    res.attr("names") = names;
305
+    Rcpp::DataFrame out(res);
306
+
307
+    return out;
308
+  }
320 309
 }
321 310
 
322 311
 Rcpp::List RcppIdent::getPara(  )
... ...
@@ -327,7 +316,7 @@ Rcpp::List RcppIdent::getPara(  )
327 316
 
328 317
 	names.push_back("searchType");
329 318
 	values.push_back(underscore(cvTermInfo(sip[0]->searchType.cvid).name));
330
-	
319
+
331 320
     for(int i = 0 ; i < sip[0]->additionalSearchParams.cvParams.size(); i++)
332 321
     {
333 322
 		names.push_back(underscore(cvTermInfo(sip[0]->additionalSearchParams.cvParams[i].cvid).name));
... ...
@@ -337,18 +326,18 @@ Rcpp::List RcppIdent::getPara(  )
337 326
     for(int i = 0; i < sip[0]->additionalSearchParams.userParams.size(); i++)
338 327
     {
339 328
 		names.push_back(underscore(sip[0]->additionalSearchParams.userParams[i].name));
340
-        if(sip[0]->additionalSearchParams.userParams[i].value.empty())
341
-        {
329
+	if(sip[0]->additionalSearchParams.userParams[i].value.empty())
330
+	{
342 331
 			values.push_back("true");
343
-        }
344
-        else
345
-        {
332
+	}
333
+	else
334
+	{
346 335
 			values.push_back(sip[0]->additionalSearchParams.userParams[i].value);
347
-        }
336
+	}
348 337
     }
349
-    
338
+
350 339
     Rcpp::List res(names.size());
351
-    
340
+
352 341
     for (size_t i = 0; i < names.size(); i++)
353 342
     {
354 343
 		if (isNumber(values[i]))
... ...
@@ -364,7 +353,7 @@ Rcpp::List RcppIdent::getPara(  )
364 353
 			res[i] = Rcpp::wrap(values[i]);
365 354
 		}
366 355
 	}
367
-    
356
+
368 357
     res.attr("names") = names;
369 358
     return res;
370 359
 }
... ...
@@ -381,21 +370,21 @@ Rcpp::DataFrame RcppIdent::getDB(  )
381 370
     std::vector<long> numResidues;
382 371
     for (size_t i = 0; i < sdb.size(); i++)
383 372
     {
384
-        dbLocation.push_back(sdb[i]->location);
385
-        dbID.push_back(sdb[i]->id);
386
-        dbName.push_back(sdb[i]->name);
387
-        dbVersion.push_back(sdb[i]->version);
388
-        numDatabaseSequences.push_back(sdb[i]->numDatabaseSequences);
389
-        numResidues.push_back(sdb[i]->numResidues);
373
+	dbLocation.push_back(sdb[i]->location);
374
+	dbID.push_back(sdb[i]->id);
375
+	dbName.push_back(sdb[i]->name);
376
+	dbVersion.push_back(sdb[i]->version);
377
+	numDatabaseSequences.push_back(sdb[i]->numDatabaseSequences);
378
+	numResidues.push_back(sdb[i]->numResidues);
390 379
     }
391 380
     Rcpp::DataFrame database = Rcpp::List::create(
392
-                                   Rcpp::_["location"]  = dbLocation,
393
-                                   Rcpp::_["id"]  = dbID,
394
-                                   Rcpp::_["name"]  = dbName,
395
-                                   Rcpp::_["numDatabaseSequences"]  = numDatabaseSequences,
396
-                                   Rcpp::_["numResidues"]  = numResidues,
397
-                                   Rcpp::_["version"]  = dbVersion
398
-                               );
381
+				   Rcpp::_["location"]  = dbLocation,
382
+				   Rcpp::_["id"]  = dbID,
383
+				   Rcpp::_["name"]  = dbName,
384
+				   Rcpp::_["numDatabaseSequences"]  = numDatabaseSequences,
385
+				   Rcpp::_["numResidues"]  = numResidues,
386
+				   Rcpp::_["version"]  = dbVersion
387
+			       );
399 388
 
400 389
     return database;
401 390
 }