...
|
...
|
@@ -164,247 +164,268 @@ Rcpp::List RcppPwiz::getInstrumentInfo ( )
|
164
|
164
|
return instrumentInfo;
|
165
|
165
|
}
|
166
|
166
|
|
167
|
|
-
|
168
|
|
-Rcpp::DataFrame RcppPwiz::getScanHeaderInfo (Rcpp::IntegerVector whichScan)
|
169
|
|
-{
|
170
|
|
- if (msd != NULL)
|
171
|
|
- {
|
172
|
|
- SpectrumListPtr slp = msd->run.spectrumListPtr;
|
173
|
|
- int N = slp->size();
|
174
|
|
-
|
175
|
|
- int N_scans = whichScan.size();
|
176
|
|
-
|
177
|
|
- ScanHeaderStruct scanHeader;
|
178
|
|
- RAMPAdapter * adapter = new RAMPAdapter(filename);
|
179
|
|
- Rcpp::IntegerVector seqNum(N_scans); // number in sequence observed file (1-based)
|
180
|
|
- Rcpp::IntegerVector acquisitionNum(N_scans); // scan number as declared in File (may be gaps)
|
181
|
|
- Rcpp::IntegerVector msLevel(N_scans);
|
182
|
|
- Rcpp::IntegerVector polarity(N_scans);
|
183
|
|
- Rcpp::IntegerVector peaksCount(N_scans);
|
184
|
|
- Rcpp::NumericVector totIonCurrent(N_scans);
|
185
|
|
- Rcpp::NumericVector retentionTime(N_scans); /* in seconds */
|
186
|
|
- Rcpp::NumericVector basePeakMZ(N_scans);
|
187
|
|
- Rcpp::NumericVector basePeakIntensity(N_scans);
|
188
|
|
- Rcpp::NumericVector collisionEnergy(N_scans);
|
189
|
|
- Rcpp::NumericVector ionisationEnergy(N_scans);
|
190
|
|
- Rcpp::NumericVector lowMZ(N_scans);
|
191
|
|
- Rcpp::NumericVector highMZ(N_scans);
|
192
|
|
- Rcpp::IntegerVector precursorScanNum(N_scans); /* only if MS level > 1 */
|
193
|
|
- Rcpp::NumericVector precursorMZ(N_scans); /* only if MS level > 1 */
|
194
|
|
- Rcpp::IntegerVector precursorCharge(N_scans); /* only if MS level > 1 */
|
195
|
|
- Rcpp::NumericVector precursorIntensity(N_scans); /* only if MS level > 1 */
|
196
|
|
- //char scanType[SCANTYPE_LENGTH];
|
197
|
|
- //char activationMethod[SCANTYPE_LENGTH];
|
198
|
|
- //char possibleCharges[SCANTYPE_LENGTH];
|
199
|
|
- //int numPossibleCharges;
|
200
|
|
- //bool possibleChargesArray[CHARGEARRAY_LENGTH]; /* NOTE: does NOT include "precursorCharge" information; only from "possibleCharges" */
|
201
|
|
- Rcpp::IntegerVector mergedScan(N_scans); /* only if MS level > 1 */
|
202
|
|
- Rcpp::IntegerVector mergedResultScanNum(N_scans); /* scan number of the resultant merged scan */
|
203
|
|
- Rcpp::IntegerVector mergedResultStartScanNum(N_scans); /* smallest scan number of the scanOrigin for merged scan */
|
204
|
|
- Rcpp::IntegerVector mergedResultEndScanNum(N_scans); /* largest scan number of the scanOrigin for merged scan */
|
205
|
|
- Rcpp::NumericVector ionInjectionTime(N_scans); /* The time spent filling an ion trapping device*/
|
206
|
|
- Rcpp::StringVector filterString(N_scans);
|
207
|
|
- Rcpp::StringVector spectrumId(N_scans);
|
208
|
|
- Rcpp::LogicalVector centroided(N_scans);
|
209
|
|
- Rcpp::NumericVector ionMobilityDriftTime(N_scans);
|
210
|
|
- Rcpp::NumericVector isolationWindowTargetMZ(N_scans);
|
211
|
|
- Rcpp::NumericVector isolationWindowLowerOffset(N_scans);
|
212
|
|
- Rcpp::NumericVector isolationWindowUpperOffset(N_scans);
|
213
|
|
- Rcpp::NumericVector scanWindowLowerLimit(N_scans);
|
214
|
|
- Rcpp::NumericVector scanWindowUpperLimit(N_scans);
|
215
|
|
-
|
216
|
|
- for (int i = 0; i < N_scans; i++)
|
217
|
|
- {
|
218
|
|
- int current_scan = whichScan[i];
|
219
|
|
- adapter->getScanHeader(current_scan - 1, scanHeader, false);
|
220
|
|
- seqNum[i] = scanHeader.seqNum;
|
221
|
|
- acquisitionNum[i] = scanHeader.acquisitionNum;
|
222
|
|
- msLevel[i] = scanHeader.msLevel;
|
223
|
|
-
|
224
|
|
- SpectrumPtr sp = slp->spectrum(current_scan-1, false); // Is TRUE neccessary here ?
|
225
|
|
- Scan dummy;
|
226
|
|
- Scan& scan = sp->scanList.scans.empty() ? dummy : sp->scanList.scans[0];
|
227
|
|
- CVParam param = sp->cvParamChild(MS_scan_polarity);
|
228
|
|
- polarity[i] = (param.cvid==MS_negative_scan ? 0 : (param.cvid==MS_positive_scan ? +1 : -1 ) );
|
229
|
|
- // ionInjectionTime[i] = scan.cvParam(MS_ion_injection_time).valueAs<double>();
|
230
|
|
- ionInjectionTime[i] = (scan.cvParam(MS_ion_injection_time).timeInSeconds() * 1000);
|
231
|
|
- filterString[i] = scan.cvParam(MS_filter_string).value.empty() ? NA_STRING : Rcpp::String(scan.cvParam(MS_filter_string).value);
|
232
|
|
- ionMobilityDriftTime[i] = scan.cvParam(MS_ion_mobility_drift_time).value.empty() ? NA_REAL : (scan.cvParam(MS_ion_mobility_drift_time).timeInSeconds() * 1000);
|
233
|
|
-
|
234
|
|
- if (!scan.scanWindows.empty()) {
|
235
|
|
- scanWindowLowerLimit[i] = scan.scanWindows[0].cvParam(MS_scan_window_lower_limit).valueAs<double>();
|
236
|
|
- scanWindowUpperLimit[i] = scan.scanWindows[0].cvParam(MS_scan_window_upper_limit).valueAs<double>();
|
237
|
|
- } else {
|
238
|
|
- scanWindowLowerLimit[i] = NA_REAL;
|
239
|
|
- scanWindowUpperLimit[i] = NA_REAL;
|
240
|
|
- }
|
241
|
|
-
|
242
|
|
- if (!sp->precursors.empty()) {
|
243
|
|
- IsolationWindow iwin = sp->precursors[0].isolationWindow;
|
244
|
|
- if (!iwin.empty()) {
|
245
|
|
- isolationWindowTargetMZ[i] = iwin.cvParam(MS_isolation_window_target_m_z).value.empty() ? NA_REAL : iwin.cvParam(MS_isolation_window_target_m_z).valueAs<double>();
|
246
|
|
- isolationWindowLowerOffset[i] = iwin.cvParam(MS_isolation_window_lower_offset).value.empty() ? NA_REAL : iwin.cvParam(MS_isolation_window_lower_offset).valueAs<double>();
|
247
|
|
- isolationWindowUpperOffset[i] = iwin.cvParam(MS_isolation_window_upper_offset).value.empty() ? NA_REAL : iwin.cvParam(MS_isolation_window_upper_offset).valueAs<double>();
|
248
|
|
- } else {
|
249
|
|
- isolationWindowTargetMZ[i] = NA_REAL;
|
250
|
|
- isolationWindowLowerOffset[i] = NA_REAL;
|
251
|
|
- isolationWindowUpperOffset[i] = NA_REAL;
|
252
|
|
- }
|
|
167
|
+Rcpp::DataFrame RcppPwiz::getScanHeaderInfo (Rcpp::IntegerVector whichScan) {
|
|
168
|
+ if (msd != NULL) {
|
|
169
|
+ SpectrumListPtr slp = msd->run.spectrumListPtr;
|
|
170
|
+ int N = slp->size();
|
|
171
|
+ int N_scans = whichScan.size();
|
|
172
|
+ CVID nativeIdFormat = id::getDefaultNativeIDFormat(*msd);
|
|
173
|
+ Rcpp::IntegerVector seqNum(N_scans); // number in sequence observed file (1-based)
|
|
174
|
+ Rcpp::IntegerVector acquisitionNum(N_scans); // scan number as declared in File (may be gaps)
|
|
175
|
+ Rcpp::IntegerVector msLevel(N_scans);
|
|
176
|
+ Rcpp::IntegerVector polarity(N_scans);
|
|
177
|
+ Rcpp::IntegerVector peaksCount(N_scans);
|
|
178
|
+ Rcpp::NumericVector totIonCurrent(N_scans);
|
|
179
|
+ Rcpp::NumericVector retentionTime(N_scans); /* in seconds */
|
|
180
|
+ Rcpp::NumericVector basePeakMZ(N_scans);
|
|
181
|
+ Rcpp::NumericVector basePeakIntensity(N_scans);
|
|
182
|
+ Rcpp::NumericVector collisionEnergy(N_scans);
|
|
183
|
+ Rcpp::NumericVector ionisationEnergy(N_scans);
|
|
184
|
+ Rcpp::NumericVector lowMZ(N_scans);
|
|
185
|
+ Rcpp::NumericVector highMZ(N_scans);
|
|
186
|
+ Rcpp::IntegerVector precursorScanNum(N_scans); /* only if MS level > 1 */
|
|
187
|
+ Rcpp::NumericVector precursorMZ(N_scans); /* only if MS level > 1 */
|
|
188
|
+ Rcpp::IntegerVector precursorCharge(N_scans); /* only if MS level > 1 */
|
|
189
|
+ Rcpp::NumericVector precursorIntensity(N_scans); /* only if MS level > 1 */
|
|
190
|
+ Rcpp::IntegerVector mergedScan(N_scans); /* only if MS level > 1 */
|
|
191
|
+ Rcpp::IntegerVector mergedResultScanNum(N_scans); /* scan number of the resultant merged scan */
|
|
192
|
+ Rcpp::IntegerVector mergedResultStartScanNum(N_scans); /* smallest scan number of the scanOrigin for merged scan */
|
|
193
|
+ Rcpp::IntegerVector mergedResultEndScanNum(N_scans); /* largest scan number of the scanOrigin for merged scan */
|
|
194
|
+ Rcpp::NumericVector ionInjectionTime(N_scans); /* The time spent filling an ion trapping device*/
|
|
195
|
+ Rcpp::StringVector filterString(N_scans);
|
|
196
|
+ Rcpp::StringVector spectrumId(N_scans);
|
|
197
|
+ Rcpp::LogicalVector centroided(N_scans);
|
|
198
|
+ Rcpp::NumericVector ionMobilityDriftTime(N_scans);
|
|
199
|
+ Rcpp::NumericVector isolationWindowTargetMZ(N_scans);
|
|
200
|
+ Rcpp::NumericVector isolationWindowLowerOffset(N_scans);
|
|
201
|
+ Rcpp::NumericVector isolationWindowUpperOffset(N_scans);
|
|
202
|
+ Rcpp::NumericVector scanWindowLowerLimit(N_scans);
|
|
203
|
+ Rcpp::NumericVector scanWindowUpperLimit(N_scans);
|
|
204
|
+
|
|
205
|
+ for (int i = 0; i < N_scans; i++) {
|
|
206
|
+ int current_scan = whichScan[i];
|
|
207
|
+ SpectrumPtr sp = slp->spectrum(current_scan - 1, false);
|
|
208
|
+ Scan dummy;
|
|
209
|
+ Scan& scan = sp->scanList.scans.empty() ? dummy : sp->scanList.scans[0];
|
|
210
|
+ // seqNum
|
|
211
|
+ seqNum[i] = current_scan;
|
|
212
|
+ // acquisitionNum
|
|
213
|
+ string id = sp->id;
|
|
214
|
+ string scanNumber = id::translateNativeIDToScanNumber(nativeIdFormat, id);
|
|
215
|
+ if (scanNumber.empty()) {
|
|
216
|
+ acquisitionNum[i] = current_scan;
|
|
217
|
+ } else {
|
|
218
|
+ acquisitionNum[i] = lexical_cast<int>(scanNumber);
|
|
219
|
+ }
|
|
220
|
+ // spectrumId
|
|
221
|
+ spectrumId[i] = sp->id;
|
|
222
|
+ // msLevel
|
|
223
|
+ msLevel[i] = sp->cvParam(MS_ms_level).valueAs<int>();
|
|
224
|
+ // peaksCount
|
|
225
|
+ peaksCount[i] = static_cast<int>(sp->defaultArrayLength);
|
|
226
|
+ // totIonCurrent
|
|
227
|
+ totIonCurrent[i] = sp->cvParam(MS_total_ion_current).valueAs<double>();
|
|
228
|
+ // basePeakMZ
|
|
229
|
+ basePeakMZ[i] = sp->cvParam(MS_base_peak_m_z).valueAs<double>();
|
|
230
|
+ // basePeakIntensity
|
|
231
|
+ basePeakIntensity[i] = sp->cvParam(MS_base_peak_intensity).valueAs<double>();
|
|
232
|
+ // ionisationEnerty
|
|
233
|
+ ionisationEnergy[i] = sp->cvParam(MS_ionization_energy_OBSOLETE).valueAs<double>();
|
|
234
|
+ // lowMZ
|
|
235
|
+ lowMZ[i] = sp->cvParam(MS_lowest_observed_m_z).valueAs<double>();
|
|
236
|
+ // highMZ
|
|
237
|
+ highMZ[i] = sp->cvParam(MS_highest_observed_m_z).valueAs<double>();
|
|
238
|
+ // polarity
|
|
239
|
+ CVParam param = sp->cvParamChild(MS_scan_polarity);
|
|
240
|
+ polarity[i] = (param.cvid==MS_negative_scan ? 0 : (param.cvid==MS_positive_scan ? +1 : -1 ) );
|
|
241
|
+ // centroided
|
|
242
|
+ param = sp->cvParamChild(MS_spectrum_representation);
|
|
243
|
+ centroided[i] = (param.cvid==MS_centroid_spectrum ? TRUE : (param.cvid==MS_profile_spectrum ? FALSE : NA_LOGICAL));
|
|
244
|
+ // retentionTime
|
|
245
|
+ retentionTime[i] = scan.cvParam(MS_scan_start_time).timeInSeconds();
|
|
246
|
+ // ionInjectionTime
|
|
247
|
+ ionInjectionTime[i] = (scan.cvParam(MS_ion_injection_time).timeInSeconds() * 1000);
|
|
248
|
+ // filterString
|
|
249
|
+ filterString[i] = scan.cvParam(MS_filter_string).value.empty() ? NA_STRING : Rcpp::String(scan.cvParam(MS_filter_string).value);
|
|
250
|
+ // ionMobilityDriftTime
|
|
251
|
+ ionMobilityDriftTime[i] = scan.cvParam(MS_ion_mobility_drift_time).value.empty() ? NA_REAL : (scan.cvParam(MS_ion_mobility_drift_time).timeInSeconds() * 1000);
|
|
252
|
+ // scanWindowLowerLimit and scanWindowUpperLimit
|
|
253
|
+ if (!scan.scanWindows.empty()) {
|
|
254
|
+ scanWindowLowerLimit[i] = scan.scanWindows[0].cvParam(MS_scan_window_lower_limit).valueAs<double>();
|
|
255
|
+ scanWindowUpperLimit[i] = scan.scanWindows[0].cvParam(MS_scan_window_upper_limit).valueAs<double>();
|
|
256
|
+ } else {
|
|
257
|
+ scanWindowLowerLimit[i] = NA_REAL;
|
|
258
|
+ scanWindowUpperLimit[i] = NA_REAL;
|
|
259
|
+ }
|
|
260
|
+ // mergedScan - also not supported by RAMPAdapter
|
|
261
|
+ mergedScan[i] = NA_INTEGER;
|
|
262
|
+ mergedResultScanNum[i] = NA_INTEGER;
|
|
263
|
+ mergedResultStartScanNum[i] = NA_INTEGER;
|
|
264
|
+ mergedResultEndScanNum[i] = NA_INTEGER;
|
|
265
|
+ if (!sp->precursors.empty()) {
|
|
266
|
+ const Precursor& precursor = sp->precursors[0];
|
|
267
|
+ // collisionEnergy
|
|
268
|
+ collisionEnergy[i] = precursor.activation.cvParam(MS_collision_energy).valueAs<double>();
|
|
269
|
+ // precursorScanNum
|
|
270
|
+ size_t precursorIndex = slp->find(precursor.spectrumID);
|
|
271
|
+ if (precursorIndex < slp->size()) {
|
|
272
|
+ const SpectrumIdentity& precursorSpectrum = slp->spectrumIdentity(precursorIndex);
|
|
273
|
+ string precursorScanNumber = id::translateNativeIDToScanNumber(nativeIdFormat, precursorSpectrum.id);
|
|
274
|
+ if (precursorScanNumber.empty()) {
|
|
275
|
+ precursorScanNum[i] = precursorIndex + 1;
|
253
|
276
|
} else {
|
254
|
|
- isolationWindowTargetMZ[i] = NA_REAL;
|
255
|
|
- isolationWindowLowerOffset[i] = NA_REAL;
|
256
|
|
- isolationWindowUpperOffset[i] = NA_REAL;
|
|
277
|
+ precursorScanNum[i] = lexical_cast<int>(precursorScanNumber);
|
257
|
278
|
}
|
258
|
|
- peaksCount[i] = scanHeader.peaksCount;
|
259
|
|
- totIonCurrent[i] = scanHeader.totIonCurrent;
|
260
|
|
- retentionTime[i] = scanHeader.retentionTime;
|
261
|
|
- basePeakMZ[i] = scanHeader.basePeakMZ;
|
262
|
|
- basePeakIntensity[i] = scanHeader.basePeakIntensity;
|
263
|
|
- collisionEnergy[i] = scanHeader.collisionEnergy;
|
264
|
|
- ionisationEnergy[i] = scanHeader.ionisationEnergy;
|
265
|
|
- lowMZ[i] = scanHeader.lowMZ;
|
266
|
|
- highMZ[i] = scanHeader.highMZ;
|
267
|
|
- precursorScanNum[i] = scanHeader.precursorScanNum;
|
268
|
|
- precursorMZ[i] = scanHeader.precursorMZ;
|
269
|
|
- precursorCharge[i] = scanHeader.precursorCharge;
|
270
|
|
- precursorIntensity[i] = scanHeader.precursorIntensity;
|
271
|
|
- mergedScan[i] = scanHeader.mergedScan;
|
272
|
|
- mergedResultScanNum[i] = scanHeader.mergedResultScanNum;
|
273
|
|
- mergedResultStartScanNum[i] = scanHeader.mergedResultStartScanNum;
|
274
|
|
- mergedResultEndScanNum[i] = scanHeader.mergedResultEndScanNum;
|
275
|
|
- spectrumId[i] = sp->id;
|
276
|
|
- CVParam prm = sp->cvParamChild(MS_spectrum_representation);
|
277
|
|
- centroided[i] = (prm.cvid==MS_centroid_spectrum ? TRUE : (prm.cvid==MS_profile_spectrum ? FALSE : NA_LOGICAL));
|
|
279
|
+ } else {
|
|
280
|
+ precursorScanNum[i] = NA_INTEGER;
|
278
|
281
|
}
|
279
|
|
- // delete adapter issue #64
|
280
|
|
- delete adapter;
|
281
|
|
- adapter = NULL;
|
282
|
|
-
|
283
|
|
- Rcpp::List header(31);
|
284
|
|
- std::vector<std::string> names;
|
285
|
|
- int i = 0;
|
286
|
|
- names.push_back("seqNum");
|
287
|
|
- header[i++] = Rcpp::wrap(seqNum);
|
288
|
|
- names.push_back("acquisitionNum");
|
289
|
|
- header[i++] = Rcpp::wrap(acquisitionNum);
|
290
|
|
- names.push_back("msLevel");
|
291
|
|
- header[i++] = Rcpp::wrap(msLevel);
|
292
|
|
- names.push_back("polarity");
|
293
|
|
- header[i++] = Rcpp::wrap(polarity);
|
294
|
|
- names.push_back("peaksCount");
|
295
|
|
- header[i++] = Rcpp::wrap(peaksCount);
|
296
|
|
- names.push_back("totIonCurrent");
|
297
|
|
- header[i++] = Rcpp::wrap(totIonCurrent);
|
298
|
|
- names.push_back("retentionTime");
|
299
|
|
- header[i++] = Rcpp::wrap(retentionTime);
|
300
|
|
- names.push_back("basePeakMZ");
|
301
|
|
- header[i++] = Rcpp::wrap(basePeakMZ);
|
302
|
|
- names.push_back("basePeakIntensity");
|
303
|
|
- header[i++] = Rcpp::wrap(basePeakIntensity);
|
304
|
|
- names.push_back("collisionEnergy");
|
305
|
|
- header[i++] = Rcpp::wrap(collisionEnergy);
|
306
|
|
- names.push_back("ionisationEnergy");
|
307
|
|
- header[i++] = Rcpp::wrap(ionisationEnergy);
|
308
|
|
- names.push_back("lowMZ");
|
309
|
|
- header[i++] = Rcpp::wrap(lowMZ);
|
310
|
|
- names.push_back("highMZ");
|
311
|
|
- header[i++] = Rcpp::wrap(highMZ);
|
312
|
|
- names.push_back("precursorScanNum");
|
313
|
|
- header[i++] = Rcpp::wrap(precursorScanNum);
|
314
|
|
- names.push_back("precursorMZ");
|
315
|
|
- header[i++] = Rcpp::wrap(precursorMZ);
|
316
|
|
- names.push_back("precursorCharge");
|
317
|
|
- header[i++] = Rcpp::wrap(precursorCharge);
|
318
|
|
- names.push_back("precursorIntensity");
|
319
|
|
- header[i++] = Rcpp::wrap(precursorIntensity);
|
320
|
|
- names.push_back("mergedScan");
|
321
|
|
- header[i++] = Rcpp::wrap(mergedScan);
|
322
|
|
- names.push_back("mergedResultScanNum");
|
323
|
|
- header[i++] = Rcpp::wrap(mergedResultScanNum);
|
324
|
|
- names.push_back("mergedResultStartScanNum");
|
325
|
|
- header[i++] = Rcpp::wrap(mergedResultStartScanNum);
|
326
|
|
- names.push_back("mergedResultEndScanNum");
|
327
|
|
- header[i++] = Rcpp::wrap(mergedResultEndScanNum);
|
328
|
|
- names.push_back("injectionTime");
|
329
|
|
- header[i++] = Rcpp::wrap(ionInjectionTime);
|
330
|
|
- names.push_back("filterString");
|
331
|
|
- header[i++] = Rcpp::wrap(filterString);
|
332
|
|
- names.push_back("spectrumId");
|
333
|
|
- header[i++] = Rcpp::wrap(spectrumId);
|
334
|
|
- names.push_back("centroided");
|
335
|
|
- header[i++] = Rcpp::wrap(centroided);
|
336
|
|
- names.push_back("ionMobilityDriftTime");
|
337
|
|
- header[i++] = Rcpp::wrap(ionMobilityDriftTime);
|
338
|
|
- names.push_back("isolationWindowTargetMZ");
|
339
|
|
- header[i++] = Rcpp::wrap(isolationWindowTargetMZ);
|
340
|
|
- names.push_back("isolationWindowLowerOffset");
|
341
|
|
- header[i++] = Rcpp::wrap(isolationWindowLowerOffset);
|
342
|
|
- names.push_back("isolationWindowUpperOffset");
|
343
|
|
- header[i++] = Rcpp::wrap(isolationWindowUpperOffset);
|
344
|
|
- names.push_back("scanWindowLowerLimit");
|
345
|
|
- header[i++] = Rcpp::wrap(scanWindowLowerLimit);
|
346
|
|
- names.push_back("scanWindowUpperLimit");
|
347
|
|
- header[i++] = Rcpp::wrap(scanWindowUpperLimit);
|
348
|
|
- header.attr("names") = names;
|
349
|
|
-
|
350
|
|
- return header;
|
|
282
|
+ // precursorMZ, precursorCharge, precursorIntensity
|
|
283
|
+ if (!precursor.selectedIons.empty()) {
|
|
284
|
+ precursorMZ[i] = precursor.selectedIons[0].cvParam(MS_selected_ion_m_z).value.empty() ? precursor.selectedIons[0].cvParam(MS_m_z).valueAs<double>() : precursor.selectedIons[0].cvParam(MS_selected_ion_m_z).valueAs<double>();
|
|
285
|
+ precursorCharge[i] = precursor.selectedIons[0].cvParam(MS_charge_state).valueAs<int>();
|
|
286
|
+ precursorIntensity[i] = precursor.selectedIons[0].cvParam(MS_peak_intensity).valueAs<double>();
|
|
287
|
+ }
|
|
288
|
+ // isolationWindowTargetMZ, ...
|
|
289
|
+ IsolationWindow iwin = sp->precursors[0].isolationWindow;
|
|
290
|
+ if (!iwin.empty()) {
|
|
291
|
+ isolationWindowTargetMZ[i] = iwin.cvParam(MS_isolation_window_target_m_z).value.empty() ? NA_REAL : iwin.cvParam(MS_isolation_window_target_m_z).valueAs<double>();
|
|
292
|
+ isolationWindowLowerOffset[i] = iwin.cvParam(MS_isolation_window_lower_offset).value.empty() ? NA_REAL : iwin.cvParam(MS_isolation_window_lower_offset).valueAs<double>();
|
|
293
|
+ isolationWindowUpperOffset[i] = iwin.cvParam(MS_isolation_window_upper_offset).value.empty() ? NA_REAL : iwin.cvParam(MS_isolation_window_upper_offset).valueAs<double>();
|
|
294
|
+ } else {
|
|
295
|
+ isolationWindowTargetMZ[i] = NA_REAL;
|
|
296
|
+ isolationWindowLowerOffset[i] = NA_REAL;
|
|
297
|
+ isolationWindowUpperOffset[i] = NA_REAL;
|
|
298
|
+ }
|
|
299
|
+ } else {
|
|
300
|
+ collisionEnergy[i] = NA_REAL;
|
|
301
|
+ precursorScanNum[i] = NA_INTEGER;
|
|
302
|
+ precursorMZ[i] = NA_REAL;
|
|
303
|
+ precursorCharge[i] = NA_INTEGER;
|
|
304
|
+ precursorIntensity[i] = NA_REAL;
|
|
305
|
+ mergedScan[i] = NA_INTEGER;
|
|
306
|
+ mergedResultScanNum[i] = NA_INTEGER;
|
|
307
|
+ mergedResultStartScanNum[i] = NA_INTEGER;
|
|
308
|
+ mergedResultEndScanNum[i] = NA_INTEGER;
|
|
309
|
+ isolationWindowTargetMZ[i] = NA_REAL;
|
|
310
|
+ isolationWindowLowerOffset[i] = NA_REAL;
|
|
311
|
+ isolationWindowUpperOffset[i] = NA_REAL;
|
|
312
|
+ }
|
351
|
313
|
}
|
|
314
|
+
|
|
315
|
+ Rcpp::List header(31);
|
|
316
|
+ std::vector<std::string> names;
|
|
317
|
+ int i = 0;
|
|
318
|
+ names.push_back("seqNum");
|
|
319
|
+ header[i++] = Rcpp::wrap(seqNum);
|
|
320
|
+ names.push_back("acquisitionNum");
|
|
321
|
+ header[i++] = Rcpp::wrap(acquisitionNum);
|
|
322
|
+ names.push_back("msLevel");
|
|
323
|
+ header[i++] = Rcpp::wrap(msLevel);
|
|
324
|
+ names.push_back("polarity");
|
|
325
|
+ header[i++] = Rcpp::wrap(polarity);
|
|
326
|
+ names.push_back("peaksCount");
|
|
327
|
+ header[i++] = Rcpp::wrap(peaksCount);
|
|
328
|
+ names.push_back("totIonCurrent");
|
|
329
|
+ header[i++] = Rcpp::wrap(totIonCurrent);
|
|
330
|
+ names.push_back("retentionTime");
|
|
331
|
+ header[i++] = Rcpp::wrap(retentionTime);
|
|
332
|
+ names.push_back("basePeakMZ");
|
|
333
|
+ header[i++] = Rcpp::wrap(basePeakMZ);
|
|
334
|
+ names.push_back("basePeakIntensity");
|
|
335
|
+ header[i++] = Rcpp::wrap(basePeakIntensity);
|
|
336
|
+ names.push_back("collisionEnergy");
|
|
337
|
+ header[i++] = Rcpp::wrap(collisionEnergy);
|
|
338
|
+ names.push_back("ionisationEnergy");
|
|
339
|
+ header[i++] = Rcpp::wrap(ionisationEnergy);
|
|
340
|
+ names.push_back("lowMZ");
|
|
341
|
+ header[i++] = Rcpp::wrap(lowMZ);
|
|
342
|
+ names.push_back("highMZ");
|
|
343
|
+ header[i++] = Rcpp::wrap(highMZ);
|
|
344
|
+ names.push_back("precursorScanNum");
|
|
345
|
+ header[i++] = Rcpp::wrap(precursorScanNum);
|
|
346
|
+ names.push_back("precursorMZ");
|
|
347
|
+ header[i++] = Rcpp::wrap(precursorMZ);
|
|
348
|
+ names.push_back("precursorCharge");
|
|
349
|
+ header[i++] = Rcpp::wrap(precursorCharge);
|
|
350
|
+ names.push_back("precursorIntensity");
|
|
351
|
+ header[i++] = Rcpp::wrap(precursorIntensity);
|
|
352
|
+ names.push_back("mergedScan");
|
|
353
|
+ header[i++] = Rcpp::wrap(mergedScan);
|
|
354
|
+ names.push_back("mergedResultScanNum");
|
|
355
|
+ header[i++] = Rcpp::wrap(mergedResultScanNum);
|
|
356
|
+ names.push_back("mergedResultStartScanNum");
|
|
357
|
+ header[i++] = Rcpp::wrap(mergedResultStartScanNum);
|
|
358
|
+ names.push_back("mergedResultEndScanNum");
|
|
359
|
+ header[i++] = Rcpp::wrap(mergedResultEndScanNum);
|
|
360
|
+ names.push_back("injectionTime");
|
|
361
|
+ header[i++] = Rcpp::wrap(ionInjectionTime);
|
|
362
|
+ names.push_back("filterString");
|
|
363
|
+ header[i++] = Rcpp::wrap(filterString);
|
|
364
|
+ names.push_back("spectrumId");
|
|
365
|
+ header[i++] = Rcpp::wrap(spectrumId);
|
|
366
|
+ names.push_back("centroided");
|
|
367
|
+ header[i++] = Rcpp::wrap(centroided);
|
|
368
|
+ names.push_back("ionMobilityDriftTime");
|
|
369
|
+ header[i++] = Rcpp::wrap(ionMobilityDriftTime);
|
|
370
|
+ names.push_back("isolationWindowTargetMZ");
|
|
371
|
+ header[i++] = Rcpp::wrap(isolationWindowTargetMZ);
|
|
372
|
+ names.push_back("isolationWindowLowerOffset");
|
|
373
|
+ header[i++] = Rcpp::wrap(isolationWindowLowerOffset);
|
|
374
|
+ names.push_back("isolationWindowUpperOffset");
|
|
375
|
+ header[i++] = Rcpp::wrap(isolationWindowUpperOffset);
|
|
376
|
+ names.push_back("scanWindowLowerLimit");
|
|
377
|
+ header[i++] = Rcpp::wrap(scanWindowLowerLimit);
|
|
378
|
+ names.push_back("scanWindowUpperLimit");
|
|
379
|
+ header[i++] = Rcpp::wrap(scanWindowUpperLimit);
|
|
380
|
+ header.attr("names") = names;
|
|
381
|
+
|
|
382
|
+ return header;
|
|
383
|
+ }
|
352
|
384
|
Rf_warningcall(R_NilValue, "pwiz not yet initialized.");
|
353
|
385
|
return Rcpp::DataFrame::create( );
|
354
|
386
|
}
|
355
|
387
|
|
356
|
|
-Rcpp::DataFrame RcppPwiz::getAllScanHeaderInfo ( )
|
357
|
|
-{
|
358
|
|
- if (msd != NULL)
|
359
|
|
- {
|
360
|
|
- if (!isInCacheAllScanHeaderInfo)
|
361
|
|
- {
|
362
|
|
- SpectrumListPtr slp = msd->run.spectrumListPtr;
|
363
|
|
- int N = slp->size();
|
364
|
|
-
|
365
|
|
- allScanHeaderInfo = getScanHeaderInfo(Rcpp::seq(1, N));
|
366
|
|
- isInCacheAllScanHeaderInfo = TRUE;
|
367
|
|
- }
|
368
|
|
- return allScanHeaderInfo ;
|
|
388
|
+Rcpp::DataFrame RcppPwiz::getAllScanHeaderInfo ( ) {
|
|
389
|
+ if (msd != NULL) {
|
|
390
|
+ if (!isInCacheAllScanHeaderInfo) {
|
|
391
|
+ SpectrumListPtr slp = msd->run.spectrumListPtr;
|
|
392
|
+ int N = slp->size();
|
|
393
|
+
|
|
394
|
+ allScanHeaderInfo = getSpectrumHeader(Rcpp::seq(1, N));
|
|
395
|
+ isInCacheAllScanHeaderInfo = TRUE;
|
369
|
396
|
}
|
|
397
|
+ return allScanHeaderInfo ;
|
|
398
|
+ }
|
370
|
399
|
Rf_warningcall(R_NilValue, "pwiz not yet initialized.");
|
371
|
400
|
return Rcpp::DataFrame::create( );
|
372
|
401
|
}
|
373
|
402
|
|
374
|
|
-Rcpp::List RcppPwiz::getPeakList ( int whichScan )
|
375
|
|
-{
|
376
|
|
- if (msd != NULL)
|
377
|
|
- {
|
378
|
|
- SpectrumListPtr slp = msd->run.spectrumListPtr;
|
379
|
|
-
|
380
|
|
- if ((whichScan <= 0) || (whichScan > slp->size()))
|
381
|
|
- {
|
382
|
|
- Rprintf("Index whichScan out of bounds [1 ... %d].\n", slp->size());
|
383
|
|
- return Rcpp::List::create( );
|
384
|
|
- }
|
385
|
|
-
|
386
|
|
- SpectrumPtr s = slp->spectrum(whichScan - 1, true);
|
387
|
|
- vector<MZIntensityPair> pairs;
|
388
|
|
- s->getMZIntensityPairs(pairs);
|
389
|
|
-
|
390
|
|
- Rcpp::NumericMatrix peaks(pairs.size(), 2);
|
391
|
|
-
|
392
|
|
- if(pairs.size()!=0)
|
393
|
|
- {
|
394
|
|
- for (int i = 0; i < pairs.size(); i++)
|
395
|
|
- {
|
396
|
|
- MZIntensityPair p = pairs.at(i);
|
397
|
|
- peaks(i,0) = p.mz;
|
398
|
|
- peaks(i,1) = p.intensity;
|
399
|
|
- }
|
|
403
|
+Rcpp::List RcppPwiz::getPeakList (int whichScan) {
|
|
404
|
+ if (msd != NULL) {
|
|
405
|
+ SpectrumListPtr slp = msd->run.spectrumListPtr;
|
|
406
|
+ if ((whichScan <= 0) || (whichScan > slp->size())) {
|
|
407
|
+ Rprintf("Index whichScan out of bounds [1 ... %d].\n", slp->size());
|
|
408
|
+ return Rcpp::List::create( );
|
|
409
|
+ }
|
|
410
|
+ SpectrumPtr s = slp->spectrum(whichScan - 1, true);
|
|
411
|
+ vector<MZIntensityPair> pairs;
|
|
412
|
+ s->getMZIntensityPairs(pairs);
|
400
|
413
|
|
401
|
|
- }
|
|
414
|
+ Rcpp::NumericMatrix peaks(pairs.size(), 2);
|
402
|
415
|
|
403
|
|
- return Rcpp::List::create(
|
404
|
|
- Rcpp::_["peaksCount"] = pairs.size(),
|
405
|
|
- Rcpp::_["peaks"] = peaks
|
406
|
|
- ) ;
|
|
416
|
+ if(pairs.size()!=0) {
|
|
417
|
+ for (int i = 0; i < pairs.size(); i++) {
|
|
418
|
+ MZIntensityPair p = pairs.at(i);
|
|
419
|
+ peaks(i,0) = p.mz;
|
|
420
|
+ peaks(i,1) = p.intensity;
|
|
421
|
+ }
|
407
|
422
|
}
|
|
423
|
+
|
|
424
|
+ return Rcpp::List::create(
|
|
425
|
+ Rcpp::_["peaksCount"] = pairs.size(),
|
|
426
|
+ Rcpp::_["peaks"] = peaks
|
|
427
|
+ ) ;
|
|
428
|
+ }
|
408
|
429
|
Rf_warningcall(R_NilValue, "pwiz not yet initialized.");
|
409
|
430
|
return Rcpp::List::create( );
|
410
|
431
|
}
|