public SpectrumDisplayInfo(SpectrumInfo spectrumInfo, string replicateName, MsDataFileUri filePath, int fileOrder, double?retentionTime, bool isBest) { _spectrumInfo = spectrumInfo; ReplicateName = replicateName; FilePath = filePath; FileOrder = fileOrder; RetentionTime = retentionTime; IsBest = isBest; }
private static DbRefSpectra MakeRefSpectrum(SpectrumInfo spectrum, string peptideSeq, string modifiedPeptideSeq, double precMz, int precChg) { var refSpectra = new DbRefSpectra { PeptideSeq = peptideSeq, PrecursorMZ = precMz, PrecursorCharge = precChg, PeptideModSeq = modifiedPeptideSeq }; MakeRefSpectrum(spectrum, refSpectra); return(refSpectra); }
private static void MakeRefSpectrum(SpectrumInfo spectrum, DbRefSpectra refSpectra) { short copies = (short)spectrum.SpectrumHeaderInfo.GetRankValue(LibrarySpec.PEP_RANK_COPIES); var peaksInfo = spectrum.SpectrumPeaksInfo; refSpectra.Copies = copies; refSpectra.NumPeaks = (ushort)peaksInfo.Peaks.Length; refSpectra.Peaks = new DbRefSpectraPeaks { RefSpectra = refSpectra, PeakIntensity = IntensitiesToBytes(peaksInfo.Peaks), PeakMZ = MZsToBytes(peaksInfo.Peaks) }; ModsFromModifiedSequence(refSpectra); }
private static string GenerateThermoScanFilter(SpectrumInfo spectrumInfo) { string activationMethod; float collisionEnergy; if (spectrumInfo is SpectrumInfoMzXML mzXmlSpectrum) { activationMethod = mzXmlSpectrum.ActivationMethod; collisionEnergy = mzXmlSpectrum.CollisionEnergy; if (!string.IsNullOrWhiteSpace(mzXmlSpectrum.FilterLine)) { return(mzXmlSpectrum.FilterLine); } } else { activationMethod = "xxx"; collisionEnergy = 0; } var centroidOrProfile = spectrumInfo.Centroided ? "c" : "p"; // ReSharper disable once ConvertIfStatementToSwitchExpression // ReSharper disable once ConvertIfStatementToSwitchStatement if (spectrumInfo.MSLevel == 1) { return(string.Format("{0} {1} Full ms [{2}-{3}]", spectrumInfo.Polarity, centroidOrProfile, spectrumInfo.MzRangeStart, spectrumInfo.MzRangeEnd)); } if (spectrumInfo.MSLevel > 1) { return(string.Format("{0} {1} Full ms{2} {3}@{4}{5:F2} [{6}-{7}]", spectrumInfo.Polarity, centroidOrProfile, spectrumInfo.MSLevel, spectrumInfo.ParentIonMZ, activationMethod, collisionEnergy, spectrumInfo.MzRangeStart, spectrumInfo.MzRangeEnd)); } return("Invalid value for MSLevel: " + spectrumInfo.MSLevel); }
public SpectrumDisplayInfo(SpectrumInfo spectrumInfo) { _spectrumInfo = spectrumInfo; IsBest = true; }
/// <summary> /// This function trigges when an interpretation is double clicked. /// It prepares the annotation and spectrum viewer panels. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void triggerSpectrumViewer(object sender, EventArgs e) { // Get the current row DataGridViewRow row = spectraGrid.CurrentRow; if (row != null) { // Get the result and variant objects associated with this row Object[] tags = row.Tag as Object[]; SpectrumInfo spectrum = tags[0] as SpectrumInfo; VariantInfo variant = tags[1] as VariantInfo; if (spectrum != null && currentSpectraGridSelection != row) { try { // Resolve the spectrum source var source = Path.GetFileNameWithoutExtension(spectrum.id.source.name); var paths = Properties.Settings.Default.SourcePath.Split(";".ToCharArray()); var matches = Util.FindFileInSearchPath(source, new string[] { "mzXML", "mzML", "mgf", "RAW" }, paths.ToArray(), true); if (matches.Length == 0) { MessageBox.Show("Can't find source. Set the source folder path."); } else { // Convert the interpretation for seems compatibility var interpetation = variant.ToSimpleString(); interpetation = interpetation.Replace('(', '['); interpetation = interpetation.Replace(')', ']'); splitContainer4.Panel2.Hide(); splitContainer1.Panel2.Hide(); splitContainer5.Panel1.Hide(); splitContainer5.Panel2.Hide(); Application.DoEvents(); UniqueSpectrumID uniqueSpectrumID; // Create a spectrum viewer and add its components if (spectrum.nativeID != null && spectrum.nativeID.Length > 0) { currentSpectrumViewer = new SpectrumViewer(matches[0], spectrum.nativeID, interpetation); uniqueSpectrumID = new UniqueSpectrumID(source, spectrum.nativeID, spectrum.id.charge); } else { currentSpectrumViewer = new SpectrumViewer(matches[0], spectrum.id.index, interpetation); uniqueSpectrumID = new UniqueSpectrumID(source, spectrum.id.index, spectrum.id.charge); } splitContainer4.Panel2.Controls.Clear(); splitContainer4.Panel2.Controls.Add(currentSpectrumViewer.annotationPanel); splitContainer5.Panel1.Controls.Clear(); splitContainer5.Panel1.Controls.Add(currentSpectrumViewer.spectrumPanel); splitContainer5.Panel2.Controls.Clear(); splitContainer5.Panel2.Controls.Add(currentSpectrumViewer.fragmentationPanel); splitContainer5.Panel2.AutoScroll = true; splitContainer1.Panel2.Controls.Add(splitContainer5); splitContainer1.Panel2.Show(); splitContainer4.Panel2.Show(); splitContainer5.Panel1.Show(); splitContainer5.Panel2.Show(); Application.DoEvents(); // If we have a seconday result associated with this spectrum, // set the mechanism in spectrum viewer to see it. if (alternativeInterpretations != null) { if (alternativeInterpretations.Contains(uniqueSpectrumID)) { VariantInfo alt = alternativeInterpretations[uniqueSpectrumID]; interpetation = alt.ToSimpleString(); interpetation = interpetation.Replace('(', '['); interpetation = interpetation.Replace(')', ']'); currentSpectrumViewer.setSecondarySequence(interpetation); } } currentSpectraGridSelection = row; } } catch (Exception exp) { MessageBox.Show(exp.StackTrace); MessageBox.Show("Failed to show spectrum. Check raw data path."); } } } }
private static void ValidateScanInfo(IReadOnlyDictionary <int, string> expectedScanInfo, SpectrumInfo spectrumInfo) { string scanSummary; switch (spectrumInfo) { case SpectrumInfoMzXML mzXmlSpectrum: { string filterLine; // Only files created with ReAdW will have filter line text if (string.IsNullOrWhiteSpace(mzXmlSpectrum.FilterLine)) { filterLine = string.Empty; } else { filterLine = mzXmlSpectrum.FilterLine.Substring(0, 12) + "..."; } scanSummary = string.Format( "{0,3} {1} {2,5} {3:F2} {4,3:0} {5,4:0} {6:0.0E+0} {7,8:F3} {8:0.0E+0} {9,8:F2} {10,-6} {11} {12,-5} {13} {14}", spectrumInfo.ScanNumber, spectrumInfo.MSLevel, spectrumInfo.PeaksCount, spectrumInfo.RetentionTimeMin, spectrumInfo.MzRangeStart, spectrumInfo.MzRangeEnd, spectrumInfo.TotalIonCurrent, spectrumInfo.BasePeakMZ, spectrumInfo.BasePeakIntensity, spectrumInfo.ParentIonMZ, mzXmlSpectrum.ActivationMethod, spectrumInfo.Polarity, spectrumInfo.Centroided, mzXmlSpectrum.SpectrumType, filterLine); break; } case SpectrumInfoMzData mzDataSpectrum: var collisionEnergyUnits = mzDataSpectrum.CollisionEnergyUnits.Equals("Percent", StringComparison.OrdinalIgnoreCase) ? "%" : " " + mzDataSpectrum.CollisionEnergyUnits; scanSummary = string.Format( "{0,3} {1} {2,5} {3,5:F2} {4,3:0} {5,4:0} {6:0.0E+0} {7,8:F3} {8:0.0E+0} {9,8:F2} {10,-6} {11} {12,-6} {13,-10} {14} {15,4:F0}{16} {17,4}", spectrumInfo.ScanNumber, spectrumInfo.MSLevel, spectrumInfo.PeaksCount, spectrumInfo.RetentionTimeMin, spectrumInfo.MzRangeStart, spectrumInfo.MzRangeEnd, spectrumInfo.TotalIonCurrent, spectrumInfo.BasePeakMZ, spectrumInfo.BasePeakIntensity, spectrumInfo.ParentIonMZ, mzDataSpectrum.CollisionMethod, spectrumInfo.Polarity, spectrumInfo.Centroided, mzDataSpectrum.SpectrumType, mzDataSpectrum.ScanMode, mzDataSpectrum.CollisionEnergy, collisionEnergyUnits, mzDataSpectrum.ParentIonSpectrumID); break; case SpectrumInfoMsMsText msmsSpectrum: scanSummary = string.Format( "{0,3} {1} {2,5} {3:F2} {4,3:0} {5,4:0} {6:0.0E+0} {7,8:F3} {8:0.0E+0} {9,8:F2} {10:F2}", spectrumInfo.ScanNumber, spectrumInfo.MSLevel, spectrumInfo.PeaksCount, spectrumInfo.RetentionTimeMin, spectrumInfo.MzRangeStart, spectrumInfo.MzRangeEnd, spectrumInfo.TotalIonCurrent, spectrumInfo.BasePeakMZ, spectrumInfo.BasePeakIntensity, spectrumInfo.ParentIonMZ, msmsSpectrum.ParentIonMH); break; default: scanSummary = "Unrecognized spectrum type"; break; } Console.WriteLine(scanSummary); if (expectedScanInfo.TryGetValue(spectrumInfo.ScanNumber, out var expectedScanSummary) && !string.IsNullOrWhiteSpace(expectedScanSummary)) { Assert.AreEqual(string.Format("{0,3} {1}", spectrumInfo.ScanNumber, expectedScanSummary), scanSummary, "Scan summary mismatch, scan " + spectrumInfo.ScanNumber); } }
public override void ParseObject(AssetsReader reader) { spectrumInfo = new SpectrumInfo(reader); spectrumData = reader.ReadArrayOf((r) => new Spectrum(r)); }
public bool NextSpectrum() { if (_runningAsync) { _currentInfo = _pendingInfoList.Take(); if (_exception != null) Helpers.WrapAndThrowException(_exception); } else { lock (_dataFileLock) { int i = _currentInfo != null ? _currentInfo.Index : -1; _currentInfo = ReadSpectrum(ref i); } } return !_currentInfo.IsLast; }
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 static void MakeRefSpectrum(SpectrumInfo spectrum, DbRefSpectra refSpectra) { short copies = (short)spectrum.SpectrumHeaderInfo.GetRankValue(LibrarySpec.PEP_RANK_COPIES); var peaksInfo = spectrum.SpectrumPeaksInfo; refSpectra.Copies = copies; refSpectra.NumPeaks = (ushort) peaksInfo.Peaks.Length; refSpectra.Peaks = new DbRefSpectraPeaks { RefSpectra = refSpectra, PeakIntensity = IntensitiesToBytes(peaksInfo.Peaks), PeakMZ = MZsToBytes(peaksInfo.Peaks) }; ModsFromModifiedSequence(refSpectra); }
private static DbRefSpectra MakeRefSpectrum(SpectrumInfo spectrum, string peptideSeq, string modifiedPeptideSeq, double precMz, int precChg) { var refSpectra = new DbRefSpectra { PeptideSeq = peptideSeq, PrecursorMZ = precMz, PrecursorCharge = precChg, PeptideModSeq = modifiedPeptideSeq }; MakeRefSpectrum(spectrum, refSpectra); return refSpectra; }