private string GetLabel(LibraryRankedSpectrumInfo.RankedMI rmi) { // Show the m/z values in the labels, if multiple should be visible, and // they have different display values. bool showMzInLabel = ShowMz && rmi.MatchedIons.Where(IsVisibleIon) .Select(mfi => GetDisplayMz(mfi.PredictedMz)) .Distinct() .Count() > 1; StringBuilder sb = new StringBuilder(); foreach (var mfi in rmi.MatchedIons.Where(IsVisibleIon)) { if (sb.Length > 0) { sb.AppendLine(); } sb.Append(GetLabel(mfi, sb.Length == 0 ? rmi.Rank : 0, showMzInLabel)); } // If predicted m/z should be displayed, but hasn't been yet, then display now. if (ShowMz && !showMzInLabel) { sb.AppendLine().Append(GetDisplayMz(rmi.MatchedIons.First().PredictedMz)); } // If showing observed m/z, and it is different from the predicted m/z, then display it last. if (ShowObservedMz) { sb.AppendLine().Append(GetDisplayMz(rmi.ObservedMz)); } return(sb.ToString()); }
private bool IsVisibleIon(LibraryRankedSpectrumInfo.RankedMI rmi) { bool singleIon = (rmi.MatchedIons.Count == 1); if (ShowDuplicates && singleIon) { return(false); } return(rmi.MatchedIons.Any(IsVisibleIon)); }
private bool IsVisibleIon(LibraryRankedSpectrumInfo.RankedMI rmi) { bool singleIon = (rmi.Ordinal2 == 0); if (ShowDuplicates && singleIon) { return(false); } return(IsVisibleIon(rmi.IonType, rmi.Ordinal, rmi.Charge) || IsVisibleIon(rmi.IonType2, rmi.Ordinal2, rmi.Charge2)); }
private string GetLabel(LibraryRankedSpectrumInfo.RankedMI rmi) { string[] parts = new string[2]; int i = 0; bool visible1 = IsVisibleIon(rmi.IonType, rmi.Ordinal, rmi.Charge); bool visible2 = IsVisibleIon(rmi.IonType2, rmi.Ordinal2, rmi.Charge2); // Show the m/z values in the labels, if they should both be visible, and // they have different display values. bool showMzInLabel = ShowMz && visible1 && visible2 && GetDisplayMz(rmi.PredictedMz) != GetDisplayMz(rmi.PredictedMz2); if (visible1) { parts[i++] = GetLabel(rmi.IonType, rmi.Ordinal, rmi.Losses, rmi.Charge, rmi.PredictedMz, rmi.Rank, showMzInLabel); } if (visible2) { parts[i] = GetLabel(rmi.IonType2, rmi.Ordinal2, rmi.Losses2, rmi.Charge2, rmi.PredictedMz2, 0, showMzInLabel); } StringBuilder sb = new StringBuilder(); foreach (string part in parts) { if (part == null) { continue; } if (sb.Length > 0) { if (showMzInLabel) { sb.AppendLine(); } else { sb.Append(", "); // Not L10N } } sb.Append(part); } // If predicted m/z should be displayed, but hasn't been yet, then display now. if (ShowMz && !showMzInLabel) { sb.AppendLine().Append(GetDisplayMz(rmi.PredictedMz)); } // If showing observed m/z, and it is different from the predicted m/z, then display it last. if (ShowObservedMz) { sb.AppendLine().Append(GetDisplayMz(rmi.ObservedMz)); } return(sb.ToString()); }
public static TransitionQuantInfo GetLibTransitionQuantInfo(Transition transition, TransitionLosses losses, TypedMass massH, IDictionary <double, LibraryRankedSpectrumInfo.RankedMI> ranks) { LibraryRankedSpectrumInfo.RankedMI rmi = null; if (ranks != null) { ranks.TryGetValue(SequenceMassCalc.GetMZ(massH, transition.Adduct), out rmi); } TransitionLibInfo transitionLibInfo = null; if (rmi != null) { transitionLibInfo = new TransitionLibInfo(rmi.Rank, rmi.Intensity); } return(new TransitionQuantInfo(null, transitionLibInfo, rmi == null || rmi.Quantitative)); }