public SpectrumKeyTime(SpectrumLiteKey key, DbRetentionTimes time, string filePath) { Key = key; Time = time; FilePath = filePath; }
private void BuildRefSpectra(SrmDocument document, ISession session, DbRefSpectra refSpectra, SpectrumInfo[] spectra, // Yes, this could be IEnumerable, but then Resharper throws bogus warnings about possible multiple enumeration IDictionary <string, long> dictFiles, ICollection <SpectrumKeyTime> redundantSpectraKeys) { bool foundBestSpectrum = false; foreach (SpectrumInfo spectrum in spectra) { if (spectrum.IsBest) { if (foundBestSpectrum) { throw new InvalidDataException( string.Format(Resources.BlibDb_BuildRefSpectra_Multiple_reference_spectra_found_for_peptide__0__in_the_library__1__, refSpectra.PeptideModSeq, FilePath)); } foundBestSpectrum = true; MakeRefSpectrum(spectrum, refSpectra); } // Determine if this spectrum is from a file that is in the document. // If it is not, do not save the retention time for this spectrum, and do not // add it to the redundant library. However, if this is the reference (best) spectrum // we must save its retention time. // NOTE: Spectra not used in the results get used for too much now for this to be useful // var matchingFile = document.Settings.HasResults // ? document.Settings.MeasuredResults.FindMatchingMSDataFile(MsDataFileUri.Parse(spectrum.FilePath)) // : null; // if (!spectrum.IsBest && matchingFile == null) // continue; // If this source file has already been saved, get its database Id. // Otherwise, save it. long spectrumSourceId = GetSpecturmSourceId(session, spectrum.FilePath, dictFiles); // spectrumKey in the SpectrumInfo is an integer for reference(best) spectra, // or object of type SpectrumLiteKey for redundant spectra object key = spectrum.SpectrumKey; var specLiteKey = key as SpectrumLiteKey; var dbRetentionTimes = new DbRetentionTimes { RedundantRefSpectraId = specLiteKey != null ? specLiteKey.RedundantId : 0, RetentionTime = spectrum.RetentionTime, SpectrumSourceId = spectrumSourceId, BestSpectrum = spectrum.IsBest ? 1 : 0, IonMobilityType = 0, IonMobilityValue = 0, }; if (null != spectrum.IonMobilityInfo) { if (spectrum.IonMobilityInfo.IsCollisionalCrossSection) { dbRetentionTimes.IonMobilityType = (int)BiblioSpecLiteLibrary.IonMobilityType.collisionalCrossSection; } else { dbRetentionTimes.IonMobilityType = (int)BiblioSpecLiteLibrary.IonMobilityType.driftTime; } dbRetentionTimes.IonMobilityValue = spectrum.IonMobilityInfo.Value; dbRetentionTimes.IonMobilityHighEnergyDriftTimeOffsetMsec = spectrum.IonMobilityInfo.HighEnergyDriftTimeOffsetMsec; } if (refSpectra.RetentionTimes == null) { refSpectra.RetentionTimes = new List <DbRetentionTimes>(); } refSpectra.RetentionTimes.Add(dbRetentionTimes); if (specLiteKey != null) { redundantSpectraKeys.Add(new SpectrumKeyTime(specLiteKey, dbRetentionTimes, spectrum.FilePath)); } } }
private void BuildRefSpectra(SrmDocument document, ISession session, DbRefSpectra refSpectra, SpectrumInfo[] spectra, // Yes, this could be IEnumerable, but then Resharper throws bogus warnings about possible multiple enumeration IDictionary<string, long> dictFiles, ICollection<SpectrumKeyTime> redundantSpectraKeys) { bool foundBestSpectrum = false; foreach(SpectrumInfo spectrum in spectra) { if(spectrum.IsBest) { if(foundBestSpectrum) { throw new InvalidDataException( string.Format(Resources.BlibDb_BuildRefSpectra_Multiple_reference_spectra_found_for_peptide__0__in_the_library__1__, refSpectra.PeptideModSeq, FilePath)); } foundBestSpectrum = true; MakeRefSpectrum(spectrum, refSpectra); } // Determine if this spectrum is from a file that is in the document. // If it is not, do not save the retention time for this spectrum, and do not // add it to the redundant library. However, if this is the reference (best) spectrum // we must save its retention time. // NOTE: Spectra not used in the results get used for too much now for this to be useful // var matchingFile = document.Settings.HasResults // ? document.Settings.MeasuredResults.FindMatchingMSDataFile(MsDataFileUri.Parse(spectrum.FilePath)) // : null; // if (!spectrum.IsBest && matchingFile == null) // continue; // If this source file has already been saved, get its database Id. // Otherwise, save it. long spectrumSourceId = GetSpecturmSourceId(session, spectrum.FilePath, dictFiles); // spectrumKey in the SpectrumInfo is an integer for reference(best) spectra, // or object of type SpectrumLiteKey for redundant spectra object key = spectrum.SpectrumKey; var specLiteKey = key as SpectrumLiteKey; var dbRetentionTimes = new DbRetentionTimes { RedundantRefSpectraId = specLiteKey != null ? specLiteKey.RedundantId : 0, RetentionTime = spectrum.RetentionTime, SpectrumSourceId = spectrumSourceId, BestSpectrum = spectrum.IsBest ? 1 : 0, IonMobilityType = 0, IonMobilityValue = 0, }; if (null != spectrum.IonMobilityInfo) { if (spectrum.IonMobilityInfo.IsCollisionalCrossSection) { dbRetentionTimes.IonMobilityType = (int) BiblioSpecLiteLibrary.IonMobilityType.collisionalCrossSection; } else { dbRetentionTimes.IonMobilityType = (int) BiblioSpecLiteLibrary.IonMobilityType.driftTime; } dbRetentionTimes.IonMobilityValue = spectrum.IonMobilityInfo.Value; dbRetentionTimes.IonMobilityHighEnergyDriftTimeOffsetMsec = spectrum.IonMobilityInfo.HighEnergyDriftTimeOffsetMsec; } if (refSpectra.RetentionTimes == null) refSpectra.RetentionTimes = new List<DbRetentionTimes>(); refSpectra.RetentionTimes.Add(dbRetentionTimes); if (specLiteKey != null) { redundantSpectraKeys.Add(new SpectrumKeyTime(specLiteKey, dbRetentionTimes, spectrum.FilePath)); } } }