private bool SpectrumMatches(SpectrumDisplayInfo spectrumDisplayInfo, SpectrumIdentifier spectrumIdentifier) { if (!string.Equals(spectrumDisplayInfo.FilePath.ToString(), spectrumIdentifier.SourceFile.ToString(), StringComparison.OrdinalIgnoreCase)) { return(false); } if (!spectrumDisplayInfo.RetentionTime.HasValue) { return(false); } return(Equals((float)spectrumDisplayInfo.RetentionTime, (float)spectrumIdentifier.RetentionTime)); }
private IList <SpectrumDisplayInfo> GetSpectra(TransitionGroupDocNode nodeGroup, Target lookupSequence, ExplicitMods lookupMods) { var settings = DocumentUI.Settings; var charge = nodeGroup.PrecursorAdduct; var spectra = settings.GetBestSpectra(lookupSequence, charge, lookupMods).Select(s => new SpectrumDisplayInfo(s)).ToList(); // Showing redundant spectra is only supported for full-scan filtering when // the document has results files imported. if ((!settings.TransitionSettings.FullScan.IsEnabled && !settings.PeptideSettings.Libraries.HasMidasLibrary) || !settings.HasResults) { return(spectra); } try { var spectraRedundant = new List <SpectrumDisplayInfo>(); var dictReplicateNameFiles = new Dictionary <string, HashSet <string> >(); foreach (var spectrumInfo in settings.GetRedundantSpectra(nodeGroup.Peptide, lookupSequence, charge, nodeGroup.TransitionGroup.LabelType, lookupMods)) { var matchingFile = settings.MeasuredResults.FindMatchingMSDataFile(MsDataFileUri.Parse(spectrumInfo.FilePath)); if (matchingFile == null) { continue; } string replicateName = matchingFile.Chromatograms.Name; spectraRedundant.Add(new SpectrumDisplayInfo(spectrumInfo, replicateName, matchingFile.FilePath, matchingFile.FileOrder, spectrumInfo.RetentionTime, false)); // Include the best spectrum twice, once displayed in the normal // way and once displayed with its replicate and retetion time. if (spectrumInfo.IsBest) { string libName = spectrumInfo.LibName; var labelType = spectrumInfo.LabelType; int iBest = spectra.IndexOf(s => Equals(s.LibName, libName) && Equals(s.LabelType, labelType)); if (iBest != -1) { spectra[iBest] = new SpectrumDisplayInfo(spectra[iBest].SpectrumInfo, replicateName, matchingFile.FilePath, 0, spectrumInfo.RetentionTime, true); } } HashSet <string> setFiles; if (!dictReplicateNameFiles.TryGetValue(replicateName, out setFiles)) { setFiles = new HashSet <string>(); dictReplicateNameFiles.Add(replicateName, setFiles); } setFiles.Add(spectrumInfo.FilePath); } // Determine if replicate name is sufficient to uniquely identify the file foreach (var spectrumInfo in spectraRedundant) { string replicateName = spectrumInfo.ReplicateName; if (replicateName != null && dictReplicateNameFiles[replicateName].Count < 2) { spectrumInfo.IsReplicateUnique = true; } } spectraRedundant.Sort(); spectra.AddRange(spectraRedundant); return(spectra); } catch (Exception) { return(spectra); } }
public SelectedSpectrumEventArgs(SpectrumDisplayInfo spectrum, bool isUserAction) { Spectrum = spectrum; IsUserAction = isUserAction; }