public QuantificationChromotograph Build(IIdentifiedSpectrum mphit, IRawFile reader) { QuantificationChromotograph result = new QuantificationChromotograph(); var envelopes = builder.Build(mphit); int startScan = mphit.Query.FileScan.FirstScan; double mzTolerance = PrecursorUtils.ppm2mz(envelopes[0][0], ppmTolerance); bool bFirst = true; int firstScanNumber = reader.GetFirstSpectrumNumber(); int lastScanNumber = reader.GetLastSpectrumNumber(); //backward for (int scan = startScan; scan >= firstScanNumber; scan--) { if (1 == reader.GetMsLevel(scan)) { QuantificationScan qscan = reader.GetPeakList(scan).GetQuantificationScan(envelopes, mzTolerance); if (!validate(qscan)) { break; } if (bFirst) { qscan.IsIdentified = true; bFirst = false; } result.Insert(0, qscan); } } //forward for (int scan = startScan + 1; scan <= lastScanNumber; scan++) { if (1 == reader.GetMsLevel(scan)) { QuantificationScan qscan = reader.GetPeakList(scan).GetQuantificationScan(envelopes, mzTolerance); if (!validate(qscan)) { break; } result.Add(qscan); } } if (result.Count > 0) { result.IdentifiedSpectra.Add(mphit); } return(result); }
public static QuantificationScan GetQuantificationScan(this PeakList <Peak> observed, List <Envelope> theoretical, double mzTolerance) { QuantificationScan result = new QuantificationScan(); result.Envelopes = new List <QuantificationEnvelope>(); foreach (var mz in theoretical) { var pkl = observed.FindEnvelopeDirectly(mz, mzTolerance, () => new Peak()); result.Envelopes.Add(new QuantificationEnvelope(mz.ToArray(), pkl.ToArray())); } return(result); }