public GroupComparisonSelector(PeptideGroupDocNode protein, PeptideDocNode peptide, IsotopeLabelType labelType, int? msLevel, GroupIdentifier groupIdentifier) { Protein = protein; Peptide = peptide; LabelType = labelType; MsLevel = msLevel; GroupIdentifier = groupIdentifier; }
public double GetTotalArea(int replicateIndex, IsotopeLabelType isotopeLabelType) { if (replicateIndex >= _allTotalAreas.Length) { return 0; } ImmutableSortedList<IsotopeLabelType, double> areasByLabelType; lock (_allTotalAreas) { areasByLabelType = _allTotalAreas[replicateIndex]; // ReSharper disable once ConvertIfStatementToNullCoalescingExpression if (null == areasByLabelType) { areasByLabelType = _allTotalAreas[replicateIndex] = ImmutableSortedList.FromValues(CalculateTotalAreas(replicateIndex)); } } double area; areasByLabelType.TryGetValue(isotopeLabelType, out area); return area; }
private void WriteExplicitMods(XmlWriter writer, string sequence, ExplicitMods mods) { if (mods == null || string.IsNullOrEmpty(sequence) && !mods.HasIsotopeLabels) { return; } if (mods.IsVariableStaticMods) { WriteExplicitMods(writer, EL.variable_modifications, EL.variable_modification, null, mods.StaticModifications, sequence); // If no heavy modifications, then don't write an <explicit_modifications> tag if (!mods.HasHeavyModifications) { return; } } writer.WriteStartElement(EL.explicit_modifications); if (!mods.IsVariableStaticMods) { WriteExplicitMods(writer, EL.explicit_static_modifications, EL.explicit_modification, null, mods.StaticModifications, sequence); } foreach (var heavyMods in mods.GetHeavyModifications()) { IsotopeLabelType labelType = heavyMods.LabelType; if (Equals(labelType, IsotopeLabelType.heavy)) { labelType = null; } WriteExplicitMods(writer, EL.explicit_heavy_modifications, EL.explicit_modification, labelType, heavyMods.Modifications, sequence); } writer.WriteEndElement(); }
public static NormalizationMethod FromName(string name) { if (string.IsNullOrEmpty(name)) { return(NONE); } if (name.StartsWith(ratio_prefix)) { string isotopeLabelTypeName = name.Substring(ratio_prefix.Length); var isotopeLabelType = new IsotopeLabelType(isotopeLabelTypeName, 0); return(new NormalizationMethod(name, () => string.Format(GroupComparisonStrings.NormalizationMethod_FromName_Ratio_to__0_, isotopeLabelType.Title)) { IsotopeLabelTypeName = isotopeLabelType.Name }); } foreach (var normalizationMethod in new[] { EQUALIZE_MEDIANS, QUANTILE, GLOBAL_STANDARDS }) { if (Equals(normalizationMethod.Name, name)) { return(normalizationMethod); } } return(NONE); }
public GroupComparisonSelector(PeptideGroupDocNode protein, PeptideDocNode peptide, IsotopeLabelType labelType, int?msLevel, GroupIdentifier groupIdentifier) { Protein = protein; Peptide = peptide; LabelType = labelType; MsLevel = msLevel; GroupIdentifier = groupIdentifier; }
/// <summary> /// For creating at the Molecule level (create molecule and first transition group) or modifying at the transition level /// Null values imply "don't ask user for this" /// </summary> public EditCustomMoleculeDlg(SkylineWindow parent, string title, Identity initialId, IEnumerable <Identity> existingIds, int minCharge, int maxCharge, SrmSettings settings, string defaultName, string defaultFormula, int?defaultCharge, ExplicitTransitionGroupValues explicitAttributes, ExplicitRetentionTimeInfo explicitRetentionTime, IsotopeLabelType defaultIsotopeLabelType, bool enableFormulaEditing = true) { Text = title; _parent = parent; _initialId = initialId; _existingIds = existingIds; _minCharge = minCharge; _maxCharge = maxCharge; _transitionSettings = settings != null ? settings.TransitionSettings : null; _peptideSettings = settings != null ? settings.PeptideSettings : null; InitializeComponent(); NameText = defaultName; var needOptionalValuesBox = explicitRetentionTime != null || explicitAttributes != null; var heightDelta = 0; if (explicitAttributes == null) { ResultExplicitTransitionGroupValues = null; labelCollisionEnergy.Visible = false; textCollisionEnergy.Visible = false; labelSLens.Visible = false; textSLens.Visible = false; labelCompensationVoltage.Visible = false; textCompensationVoltage.Visible = false; labelConeVoltage.Visible = false; textConeVoltage.Visible = false; labelDriftTimeHighEnergyOffsetMsec.Visible = false; textDriftTimeHighEnergyOffsetMsec.Visible = false; labelDriftTimeMsec.Visible = false; textDriftTimeMsec.Visible = false; if (needOptionalValuesBox) { // We blanked out everything but the retention time var vmargin = labelRetentionTime.Location.Y; var newHeight = textRetentionTime.Location.Y + textRetentionTime.Height + vmargin; heightDelta = groupBoxOptionalValues.Height - newHeight; groupBoxOptionalValues.Height = newHeight; } } else { ResultExplicitTransitionGroupValues = new ExplicitTransitionGroupValues(explicitAttributes); } string labelAverage = defaultCharge.HasValue ? Resources.EditCustomMoleculeDlg_EditCustomMoleculeDlg_A_verage_m_z_ : Resources.EditCustomMoleculeDlg_EditCustomMoleculeDlg_A_verage_mass_; string labelMono = defaultCharge.HasValue ? Resources.EditCustomMoleculeDlg_EditCustomMoleculeDlg__Monoisotopic_m_z_ : Resources.EditCustomMoleculeDlg_EditCustomMoleculeDlg__Monoisotopic_mass_; _formulaBox = new FormulaBox(Resources.EditMeasuredIonDlg_EditMeasuredIonDlg_Ion__chemical_formula_, labelAverage, labelMono, defaultCharge) { Formula = defaultFormula, Location = new Point(textName.Left, textName.Bottom + 12) }; Controls.Add(_formulaBox); _formulaBox.TabIndex = 2; _formulaBox.Enabled = enableFormulaEditing; bool needCharge = defaultCharge.HasValue; textCharge.Visible = labelCharge.Visible = needCharge; Charge = defaultCharge ?? 0; if (needOptionalValuesBox && !needCharge) { heightDelta += groupBoxOptionalValues.Location.Y - labelCharge.Location.Y; groupBoxOptionalValues.Location = new Point(groupBoxOptionalValues.Location.X, labelCharge.Location.Y); } if (explicitRetentionTime == null) { // Don't ask user for retetention times RetentionTime = null; RetentionTimeWindow = null; labelRetentionTime.Visible = false; labelRetentionTimeWindow.Visible = false; textRetentionTime.Visible = false; textRetentionTimeWindow.Visible = false; if (needOptionalValuesBox) { var rtHeight = labelCollisionEnergy.Location.Y - labelRetentionTimeWindow.Location.Y; groupBoxOptionalValues.Height -= rtHeight; heightDelta += rtHeight; } } else { RetentionTime = explicitRetentionTime.RetentionTime; RetentionTimeWindow = explicitRetentionTime.RetentionTimeWindow; } if (!needOptionalValuesBox) { groupBoxOptionalValues.Visible = false; heightDelta = groupBoxOptionalValues.Height; } // Initialize label if (settings != null && defaultIsotopeLabelType != null) { _driverLabelType = new PeptideSettingsUI.LabelTypeComboDriver(comboIsotopeLabelType, settings.PeptideSettings.Modifications, null, null, null, null) { SelectedName = defaultIsotopeLabelType.Name }; } else { comboIsotopeLabelType.Visible = false; labelIsotopeLabelType.Visible = false; } Height -= heightDelta; }
private LibraryRankedSpectrumInfo(SpectrumPeaksInfo info, IsotopeLabelType labelType, TransitionGroupDocNode groupDocNode, SrmSettings settings, Target lookupSequence, ExplicitMods lookupMods, IEnumerable <Adduct> charges, IEnumerable <IonType> types, IEnumerable <Adduct> rankCharges, IEnumerable <IonType> rankTypes, double?score, bool useFilter, bool matchAll, int minPeaks) { LabelType = labelType; // Avoid ReSharper multiple enumeration warning var rankChargesArray = rankCharges.ToArray(); var rankTypesArray = rankTypes.ToArray(); TransitionGroup group = groupDocNode.TransitionGroup; bool isProteomic = group.IsProteomic; if (score == null && groupDocNode.HasLibInfo && groupDocNode.LibInfo is BiblioSpecSpectrumHeaderInfo libInfo) { Score = libInfo.Score; } else { Score = score; } if (!useFilter) { if (charges == null) { charges = GetRanked(rankChargesArray, isProteomic ? Transition.DEFAULT_PEPTIDE_CHARGES : Transition.DEFAULT_MOLECULE_CHARGES); } if (types == null) { types = GetRanked(rankTypesArray, isProteomic ? Transition.PEPTIDE_ION_TYPES : Transition.MOLECULE_ION_TYPES); } matchAll = true; } bool limitRanks = groupDocNode.IsCustomIon && // For small molecules, cap the number of ranked ions displayed if we don't have any peak metadata groupDocNode.Transitions.Any(t => string.IsNullOrEmpty(t.FragmentIonName)); RankParams rp = new RankParams { sequence = lookupSequence, precursorAdduct = group.PrecursorAdduct, adducts = charges ?? rankCharges, types = types ?? rankTypes, matchAll = matchAll, rankCharges = rankChargesArray.Select(a => Math.Abs(a.AdductCharge)).ToArray(), rankTypes = rankTypesArray, // Precursor isotopes will not be included in MS/MS, if they will be filtered // from MS1 excludePrecursorIsotopes = settings.TransitionSettings.FullScan.IsEnabledMs, tranSettings = settings.TransitionSettings, rankLimit = limitRanks ? settings.TransitionSettings.Libraries.IonCount : (int?)null }; // Get necessary mass calculators and masses var calcMatchPre = settings.GetPrecursorCalc(labelType, lookupMods); var calcMatch = isProteomic ? settings.GetFragmentCalc(labelType, lookupMods) : settings.GetDefaultFragmentCalc(); var calcPredict = isProteomic ? settings.GetFragmentCalc(group.LabelType, lookupMods) : calcMatch; if (isProteomic && rp.sequence.IsProteomic) { rp.precursorMz = SequenceMassCalc.GetMZ(calcMatchPre.GetPrecursorMass(rp.sequence), rp.precursorAdduct); rp.massPreMatch = calcMatch.GetPrecursorFragmentMass(rp.sequence); rp.massesMatch = calcMatch.GetFragmentIonMasses(rp.sequence); rp.knownFragments = null; } else if (!isProteomic && !rp.sequence.IsProteomic) { string isotopicForumla; rp.precursorMz = SequenceMassCalc.GetMZ(calcMatchPre.GetPrecursorMass(rp.sequence.Molecule, null, rp.precursorAdduct, out isotopicForumla), rp.precursorAdduct); rp.massPreMatch = calcMatch.GetPrecursorFragmentMass(rp.sequence); // rp.massesMatch = calcMatch.GetFragmentIonMasses(rp.molecule); CONSIDER, for some molecule types someday? // For small molecules we can't predict fragmentation, so just use those we have // Older Resharper code inspection implementations insist on warning here // Resharper disable PossibleMultipleEnumeration var existing = groupDocNode.Transitions.Where(tran => tran.Transition.IsNonPrecursorNonReporterCustomIon()).Select(t => t.Transition.CustomIon.GetMass(MassType.Monoisotopic)).ToArray(); rp.massesMatch = new IonTable <TypedMass>(IonType.custom, existing.Length); for (var i = 0; i < existing.Length; i++) { rp.massesMatch[IonType.custom, i] = existing[i]; } // Resharper restore PossibleMultipleEnumeration rp.knownFragments = groupDocNode.Transitions.Where(tran => tran.Transition.IsNonPrecursorNonReporterCustomIon()).Select(t => new KnownFragment { Adduct = t.Transition.Adduct, Name = t.GetFragmentIonName(CultureInfo.CurrentCulture, settings.TransitionSettings.Libraries.IonMatchTolerance), Mz = t.Mz }).ToList(); } else { rp.precursorMz = 0.0; rp.massPreMatch = TypedMass.ZERO_MONO_MASSH; rp.massesMatch = IonTable <TypedMass> .EMPTY; rp.knownFragments = null; } rp.massPrePredict = rp.massPreMatch; rp.massesPredict = rp.massesMatch; if (!ReferenceEquals(calcPredict, calcMatch)) { rp.massPrePredict = calcPredict.GetPrecursorFragmentMass(rp.sequence); if (rp.sequence.IsProteomic) // CONSIDER - eventually we may be able to predict fragments for small molecules? { rp.massesPredict = calcPredict.GetFragmentIonMasses(rp.sequence); } } // Get values of interest from the settings. var tranSettings = settings.TransitionSettings; var predict = tranSettings.Prediction; var filter = tranSettings.Filter; var libraries = tranSettings.Libraries; var instrument = tranSettings.Instrument; // Get potential losses to all fragments in this peptide rp.massType = predict.FragmentMassType; rp.potentialLosses = TransitionGroup.CalcPotentialLosses(rp.sequence, settings.PeptideSettings.Modifications, lookupMods, rp.massType); // Create arrays because ReadOnlyCollection enumerators are too slow // In some cases these collections must be enumerated for every ion // allowed in the library specturm. rp.startFinder = filter.FragmentRangeFirst; rp.endFinder = filter.FragmentRangeLast; // Get library settings Tolerance = libraries.IonMatchTolerance; rp.tolerance = Tolerance; rp.pick = tranSettings.Libraries.Pick; int ionMatchCount = libraries.IonCount; // If no library filtering will happen, return all rankings for view in the UI if (!useFilter || rp.pick == TransitionLibraryPick.none) { if (rp.pick == TransitionLibraryPick.none) { rp.pick = TransitionLibraryPick.all; } ionMatchCount = -1; } // Get instrument settings rp.minMz = instrument.MinMz; rp.maxMz = instrument.MaxMz; // Get the library spectrum mass-intensity pairs IList <SpectrumPeaksInfo.MI> listMI = info.Peaks; // Because sorting and matching observed ions with predicted // ions appear as bottlenecks in a profiler, a minimum number // of peaks may be supplied to allow the use of a 2-phase linear // filter that can significantly reduce the number of peaks // needing the O(n*log(n)) sorting and the O(n*m) matching. int len = listMI.Count; float intensityCutoff = 0; if (minPeaks != -1) { // Start searching for good cut-off at mean intensity. double totalIntensity = info.Intensities.Sum(); FindIntensityCutoff(listMI, 0, (float)(totalIntensity / len) * 2, minPeaks, 1, ref intensityCutoff, ref len); } // Create filtered peak array storing original index for m/z ordering // to avoid needing to sort to return to this order. RankedMI[] arrayRMI = new RankedMI[len]; // Detect when m/z values are out of order, and use the expensive sort // by m/z to correct this. double lastMz = double.MinValue; bool sortMz = false; for (int i = 0, j = 0, lenOrig = listMI.Count; i < lenOrig; i++) { SpectrumPeaksInfo.MI mi = listMI[i]; if (mi.Intensity >= intensityCutoff || intensityCutoff == 0) { arrayRMI[j] = new RankedMI(mi, j); j++; } if (ionMatchCount == -1) { if (mi.Mz < lastMz) { sortMz = true; } lastMz = mi.Mz; } } // The one expensive sort is used to determine rank order // by intensity, or m/z in case of a tie. Array.Sort(arrayRMI, OrderIntensityDesc); RankedMI[] arrayResult = new RankedMI[ionMatchCount != -1 ? ionMatchCount : arrayRMI.Length]; foreach (RankedMI rmi in arrayRMI) { rmi.CalculateRank(rp); // If not filtering for only the highest ionMatchCount ranks if (ionMatchCount == -1) { // Put the ranked record back where it started in the // m/z ordering to avoid a second sort. arrayResult[rmi.IndexMz] = rmi; } // Otherwise, if this ion was ranked, add it to the result array else if (rmi.Rank > 0) { int countRanks = rmi.Rank; arrayResult[countRanks - 1] = rmi; // And stop when the array is full if (countRanks == ionMatchCount) { break; } } } // Is this a theoretical library with no intensity variation? If so it can't be ranked. // If it has any interesting peak annotations, pass those through if (rp.Ranked == 0 && arrayRMI.All(rmi => rmi.Intensity == arrayRMI[0].Intensity)) { // Only do this if we have been asked to limit the ions matched, and there are any annotations if (ionMatchCount != -1 && arrayRMI.Any(rmi => rmi.HasAnnotations)) { // Pass through anything with an annotation as being of probable interest arrayResult = arrayRMI.Where(rmi => rmi.HasAnnotations).ToArray(); ionMatchCount = -1; } } // If not enough ranked ions were found, fill the rest of the results array if (ionMatchCount != -1) { for (int i = rp.Ranked; i < ionMatchCount; i++) { arrayResult[i] = RankedMI.EMPTY; } } // If all ions are to be included, and some were found out of order, then // the expensive full sort by m/z is necesary. else if (sortMz) { Array.Sort(arrayResult, OrderMz); } _spectrum = MakeReadOnly(arrayResult); }
public RelativeRT GetRelativeRT(IsotopeLabelType labelType, string seq, ExplicitMods mods) { if (labelType.IsLight) return RelativeRT.Matching; // Default is matching RelativeRT relativeRT = RelativeRT.Matching; // One unkown modification makes everything unknown // One preceding modification with no unknowns make relative RT preceding // Overlapping overrides matching if (mods != null && mods.IsModified(labelType)) { foreach (var mod in mods.GetModifications(labelType)) { if (mod.Modification.RelativeRT == RelativeRT.Unknown) return RelativeRT.Unknown; if (mod.Modification.RelativeRT == RelativeRT.Preceding) relativeRT = RelativeRT.Preceding; else if (mod.Modification.RelativeRT == RelativeRT.Overlapping && relativeRT == RelativeRT.Matching) relativeRT = RelativeRT.Overlapping; } } else { foreach (var mod in PeptideSettings.Modifications.GetModifications(labelType)) { if (!mod.IsMod(seq)) continue; if (mod.RelativeRT == RelativeRT.Unknown) return RelativeRT.Unknown; if (mod.RelativeRT == RelativeRT.Preceding) relativeRT = RelativeRT.Preceding; else if (mod.RelativeRT == RelativeRT.Overlapping && relativeRT == RelativeRT.Matching) relativeRT = RelativeRT.Overlapping; } } return relativeRT; }
public string GetModifiedSequence(string seq, IsotopeLabelType labelType, ExplicitMods mods, SequenceModFormatType format = SequenceModFormatType.mass_diff, bool useExplicitModsOnly = false) { return GetPrecursorCalc(labelType, mods).GetModifiedSequence(seq, format, useExplicitModsOnly); }
private bool LibrariesContainMeasurablePeptide(Peptide peptide, IsotopeLabelType labelType, IEnumerable<int> precursorCharges, ExplicitMods mods) { string sequenceMod = GetModifiedSequence(peptide.Sequence, labelType, mods); foreach (int charge in precursorCharges) { if (LibrariesContain(sequenceMod, charge)) { // Make sure the peptide for the found spectrum is measurable on // the current instrument. double precursorMass = GetPrecursorMass(labelType, peptide.Sequence, mods); if (IsMeasurable(precursorMass, charge)) return true; } } return false; }
public IList<double> GetModMasses(MassType massType, IsotopeLabelType labelType) { var index = GetModIndex(labelType); // This will throw, if the modification type is not found. return _modifications[index].GetModMasses(massType); }
public ExplicitMods ChangeModifications(IsotopeLabelType labelType, IList<ExplicitMod> prop) { int index = GetModIndex(labelType); if (index == -1) throw new IndexOutOfRangeException(string.Format(Resources.ExplicitMods_ChangeModifications_Modification_type__0__not_found, labelType)); var modifications = _modifications.ToArrayStd(); var typedMods = new TypedExplicitModifications(Peptide, labelType, prop); if (index != 0) typedMods = typedMods.AddModMasses(modifications[0]); modifications[index] = typedMods; return ChangeProp(ImClone(this), im => im._modifications = MakeReadOnly(modifications)); }
public TypedModifications(IsotopeLabelType labelType, IList<StaticMod> modifications) { LabelType = labelType; Modifications = MakeReadOnly(modifications); }
public TypedExplicitModifications(Peptide peptide, IsotopeLabelType labelType, IList<ExplicitMod> modifications) { LabelType = labelType; Modifications = MakeReadOnly(modifications); // Cache modification masses var modMassesMono = CalcModMasses(peptide, Modifications, SrmSettings.MonoisotopicMassCalc); _modMassesMono = MakeReadOnly(modMassesMono); var modMassesAvg = CalcModMasses(peptide, Modifications, SrmSettings.AverageMassCalc); _modMassesAvg = MakeReadOnly(modMassesAvg); }
public static NormalizationMethod FromName(string name) { if (string.IsNullOrEmpty(name)) { return NONE; } if (name.StartsWith(ratio_prefix)) { string isotopeLabelTypeName = name.Substring(ratio_prefix.Length); var isotopeLabelType = new IsotopeLabelType(isotopeLabelTypeName, 0); return new NormalizationMethod(name, () => string.Format(GroupComparisonStrings.NormalizationMethod_FromName_Ratio_to__0_, isotopeLabelType.Title)) { IsotopeLabelTypeName = isotopeLabelType.Name }; } foreach (var normalizationMethod in new[] {EQUALIZE_MEDIANS, QUANTILE, GLOBAL_STANDARDS}) { if (Equals(normalizationMethod.Name, name)) { return normalizationMethod; } } return NONE; }
public bool TryGetRetentionTimes(string sequence, int charge, ExplicitMods mods, MsDataFileUri filePath, out IsotopeLabelType type, out double[] retentionTimes) { var libraries = PeptideSettings.Libraries; foreach (var typedSequence in GetTypedSequences(sequence, mods)) { var key = new LibKey(typedSequence.ModifiedSequence, charge); if (libraries.TryGetRetentionTimes(key, filePath, out retentionTimes)) { type = typedSequence.LabelType; return true; } } type = IsotopeLabelType.light; retentionTimes = null; return false; }
private static SequenceMassCalc GetBaseCalc(IsotopeLabelType labelType, ExplicitMods mods, IList<TypedMassCalc> massCalcs) { if (mods == null) return null; var calcLightImplicit = massCalcs[0].MassCalc; // If the light type is not modified if (!mods.IsModified(IsotopeLabelType.light)) { // If requesting the light calculator or an unmodified heavy, // then no explicit calculator is required. if (labelType.IsLight || !mods.IsModified(labelType)) return null; // Otherwise, use its calculator as the base for a heavy type // to make sure the implicit light modifications are included. return calcLightImplicit; } // If the type requested is not modified, it must be a heavy type // with the light type modified. In this case, return the heavy // calculator as the base, to which the light explicit modifications // may be applied to get modified masses. if (!mods.IsModified(labelType)) return GetMassCalc(labelType, massCalcs); // If the light modifications are variable, and this is a type for // which explicit modifications exist (including the light type itself), // then return the light calculator as base. if (mods.IsVariableStaticMods) return calcLightImplicit; // If both light and this type are modified, then us a base calculator // that contains no modifications at all. return (calcLightImplicit.MassType == MassType.Monoisotopic ? MonoisotopicMassCalc : AverageMassCalc); }
public IList<ExplicitMod> GetStaticBaseMods(IsotopeLabelType labelType) { int index = GetModIndex(labelType); return (index != -1 ? _modifications[index].StaticBaseMods : null); }
public IFragmentMassCalc GetFragmentCalc(IsotopeLabelType labelType, ExplicitMods mods) { var massCalcBase = GetBaseCalc(labelType, mods, _fragmentMassCalcs); if (massCalcBase != null) { // If this type is not explicitly modified, then it must be // heavy with explicit light modifications. if (!mods.IsModified(labelType)) labelType = IsotopeLabelType.light; if (!labelType.IsLight && !mods.HasModifications(labelType)) return null; return new ExplicitSequenceMassCalc(mods, massCalcBase, labelType); } return GetMassCalc(labelType, _fragmentMassCalcs); }
public bool HasModifications(IsotopeLabelType labelType) { return _modifications.Contains(mods => Equals(labelType, mods.LabelType) && mods.Modifications.Count > 0); }
public double GetPrecursorMass(IsotopeLabelType labelType, string seq, ExplicitMods mods) { return GetPrecursorCalc(labelType, mods).GetPrecursorMass(seq); }
public bool IsModified(IsotopeLabelType labelType) { return GetModIndex(labelType) != -1; }
public double GetTotalArea(IsotopeLabelType isotopeLabelType) { return(DataSchema.GetReplicateSummaries().GetTotalArea(Replicate.ReplicateIndex, isotopeLabelType)); }
private int GetModIndex(IsotopeLabelType labelType) { return _modifications.IndexOf(mod => ReferenceEquals(labelType, mod.LabelType)); }
public static string ConcentrationRatioText(IsotopeLabelType numerator, IsotopeLabelType denominator) { return(ConcentrationRatioText(new[] { numerator }, denominator)); }
public static NormalizeOption FromIsotopeLabelType(IsotopeLabelType isotopeLabelType) { return(new Simple(new NormalizationMethod.RatioToLabel(isotopeLabelType))); }
private const string LABEL_ARG = "label"; // Not L10N public RatioToSurrogate(string surrogateName, IsotopeLabelType isotopeLabelType) : base(surrogate_prefix + Uri.EscapeUriString(surrogateName) + '?' + LABEL_ARG + '=' + Uri.EscapeUriString(isotopeLabelType.Name)) { _surrogateName = surrogateName; _isotopeLabelType = isotopeLabelType; }
public PaneKey(IsotopeLabelType isotopeLabelType) : this(Adduct.EMPTY, isotopeLabelType, false) { }
public static RatioPropertyName PeptideRdotpProperty(IsotopeLabelType labelType, IsotopeLabelType standardType) { string key = string.Format("DotProduct{0}To{1}", // Not L10N Helpers.MakeId(labelType.Name, true), Helpers.MakeId(standardType.Name, true)); string headerText = string.Format(Resources.RDotPPropertyAccessor_PeptideProperty_Dot_Product__0__To__1_, labelType.Title, standardType.Title); return(new RatioPropertyName(RDOTP_PREFIX, key, headerText)); }
public void OkDialog() { var helper = new MessageBoxHelper(this); int?minPeptidesPerProtein = null; if (!string.IsNullOrEmpty(textMinPeptides.Text)) { int minVal; if (!helper.ValidateNumberTextBox(textMinPeptides, 0, 10, out minVal)) { return; } minPeptidesPerProtein = minVal; } int?minTransitionsPerPrecursor = null; if (!string.IsNullOrEmpty(textMinTransitions.Text)) { int minVal; if (!helper.ValidateNumberTextBox(textMinTransitions, 0, 100, out minVal)) { return; } minTransitionsPerPrecursor = minVal; } bool removeDuplicatePeptides = cbRemoveDuplicatePeptides.Checked; bool removeRepeatedPeptides = cbRemoveRepeatedPeptides.Checked; bool removeMissingLibrary = cbRemovePeptidesMissingLibrary.Checked; IsotopeLabelType refineLabelType = RefineLabelType; bool addLabelType = cbAdd.Checked; // If adding, make sure there is something to add if (addLabelType && refineLabelType != null && !CanAddLabelType(refineLabelType)) { MessageDlg.Show(this, string.Format(Resources.RefineDlg_OkDialog_The_label_type__0__cannot_be_added_There_are_no_modifications_for_this_type, refineLabelType.Name)); tabControl1.SelectedIndex = 0; comboRefineLabelType.Focus(); return; } double?minPeakFoundRatio = null, maxPeakFoundRatio = null; if (!string.IsNullOrEmpty(textMinPeakFoundRatio.Text)) { double minVal; if (!helper.ValidateDecimalTextBox(textMinPeakFoundRatio, 0, 1, out minVal)) { return; } minPeakFoundRatio = minVal; } if (!string.IsNullOrEmpty(textMaxPeakFoundRatio.Text)) { double maxVal; if (!helper.ValidateDecimalTextBox(textMaxPeakFoundRatio, 0, 1, out maxVal)) { return; } maxPeakFoundRatio = maxVal; } if (minPeakFoundRatio.HasValue && maxPeakFoundRatio.HasValue && minPeakFoundRatio.Value > maxPeakFoundRatio.Value) { helper.ShowTextBoxError(textMaxPeakFoundRatio, Resources.RefineDlg_OkDialog__0__must_be_less_than_min_peak_found_ratio); return; } int?maxPepPeakRank = null; if (!string.IsNullOrEmpty(textMaxPepPeakRank.Text)) { int maxVal; if (!helper.ValidateNumberTextBox(textMaxPepPeakRank, 1, 20, out maxVal)) { return; } maxPepPeakRank = maxVal; } int?maxPeakRank = null; if (!string.IsNullOrEmpty(textMaxPeakRank.Text)) { int maxVal; if (!helper.ValidateNumberTextBox(textMaxPeakRank, 1, 20, out maxVal)) { return; } maxPeakRank = maxVal; } bool removeMissingResults = radioRemoveMissing.Checked; double?rtRegressionThreshold = null; if (!string.IsNullOrEmpty(textRTRegressionThreshold.Text)) { double minVal; if (!helper.ValidateDecimalTextBox(textRTRegressionThreshold, 0, 1, out minVal)) { return; } rtRegressionThreshold = minVal; } double?dotProductThreshold = null; if (!string.IsNullOrEmpty(textMinDotProduct.Text)) { double minVal; if (!helper.ValidateDecimalTextBox(textMinDotProduct, 0, 1, out minVal)) { return; } dotProductThreshold = minVal; } double?idotProductThreshold = null; if (!string.IsNullOrEmpty(textMinIdotProduct.Text)) { double minVal; if (!helper.ValidateDecimalTextBox(textMinIdotProduct, 0, 1, out minVal)) { return; } idotProductThreshold = minVal; } bool useBestResult = comboReplicateUse.SelectedIndex > 0; double?cvCutoff = null; if (!string.IsNullOrEmpty(textCVCutoff.Text)) { double cutoffVal; if (!helper.ValidateDecimalTextBox(textCVCutoff, 0, null, out cutoffVal)) { return; } cvCutoff = cutoffVal; } double?qvalueCutoff = null; if (!string.IsNullOrWhiteSpace(textQVal.Text)) { double qvalue; if (!helper.ValidateDecimalTextBox(textQVal, 0.0, 1.0, out qvalue)) { return; } qvalueCutoff = qvalue; } int?minimumDetections = null; if (numericUpDownDetections.Enabled) { minimumDetections = (int)numericUpDownDetections.Value; } var normIdx = comboNormalizeTo.SelectedIndex; var normMethod = GetNormalizationMethod(normIdx); IsotopeLabelType referenceType = CVRefineLabelType; var transitionsSelection = GetTransitionFromIdx(comboTransitions.SelectedIndex); int?numTransitions = null; if (transitionsSelection == AreaCVTransitions.count) { numTransitions = comboTransitions.SelectedIndex - 1; } var msLevel = AreaCVMsLevel.products; if (comboTransitions.Items.Count > 0) { var selectedMs = comboTransType.SelectedItem.ToString(); msLevel = (AreaCVMsLevel)Enum.Parse(typeof(AreaCVMsLevel), selectedMs, true); } RefinementSettings = new RefinementSettings { MinPeptidesPerProtein = minPeptidesPerProtein, RemoveRepeatedPeptides = removeRepeatedPeptides, RemoveDuplicatePeptides = removeDuplicatePeptides, RemoveMissingLibrary = removeMissingLibrary, MinTransitionsPepPrecursor = minTransitionsPerPrecursor, RefineLabelType = refineLabelType, AddLabelType = addLabelType, MinPeakFoundRatio = minPeakFoundRatio, MaxPeakFoundRatio = maxPeakFoundRatio, MaxPepPeakRank = maxPepPeakRank, MaxPrecursorPeakOnly = cbMaxPrecursorOnly.Checked, MaxPeakRank = maxPeakRank, PreferLargeIons = cbPreferLarger.Checked, RemoveMissingResults = removeMissingResults, RTRegressionThreshold = rtRegressionThreshold, DotProductThreshold = dotProductThreshold, IdotProductThreshold = idotProductThreshold, UseBestResult = useBestResult, AutoPickChildrenAll = (cbAutoPeptides.Checked ? PickLevel.peptides : 0) | (cbAutoPrecursors.Checked ? PickLevel.precursors : 0) | (cbAutoTransitions.Checked ? PickLevel.transitions : 0), CVCutoff = cvCutoff, QValueCutoff = qvalueCutoff, MinimumDetections = minimumDetections, NormalizationMethod = normMethod, NormalizationLabelType = referenceType, Transitions = transitionsSelection, CountTransitions = numTransitions, MSLevel = msLevel }; DialogResult = DialogResult.OK; Close(); }
public bool TryGetLibInfo(string sequence, int charge, ExplicitMods mods, out IsotopeLabelType type, out SpectrumHeaderInfo libInfo) { if (sequence == null) { type = null; libInfo = null; return false; } var libraries = PeptideSettings.Libraries; foreach (var typedSequence in GetTypedSequences(sequence, mods)) { var key = new LibKey(typedSequence.ModifiedSequence, charge); if (libraries.TryGetLibInfo(key, out libInfo)) { type = typedSequence.LabelType; return true; } } type = IsotopeLabelType.light; libInfo = null; return false; }
public void OkDialog() { var helper = new MessageBoxHelper(this); int?minPeptidesPerProtein = null; if (!string.IsNullOrEmpty(textMinPeptides.Text)) { int minVal; if (!helper.ValidateNumberTextBox(tabControl1, 0, textMinPeptides, 0, 10, out minVal)) { return; } minPeptidesPerProtein = minVal; } int?minTransitionsPerPrecursor = null; if (!string.IsNullOrEmpty(textMinTransitions.Text)) { int minVal; if (!helper.ValidateNumberTextBox(tabControl1, 0, textMinTransitions, 0, 100, out minVal)) { return; } minTransitionsPerPrecursor = minVal; } bool removeDuplicatePeptides = cbRemoveDuplicatePeptides.Checked; bool removeRepeatedPeptides = cbRemoveRepeatedPeptides.Checked; bool removeMissingLibrary = cbRemovePeptidesMissingLibrary.Checked; IsotopeLabelType refineLabelType = RefineLabelType; bool addLabelType = cbAdd.Checked; // If adding, make sure there is something to add if (addLabelType && refineLabelType != null && !CanAddLabelType(refineLabelType)) { MessageDlg.Show(this, string.Format(Resources.RefineDlg_OkDialog_The_label_type__0__cannot_be_added_There_are_no_modifications_for_this_type, refineLabelType.Name)); tabControl1.SelectedIndex = 0; comboRefineLabelType.Focus(); return; } double?minPeakFoundRatio = null, maxPeakFoundRatio = null; if (!string.IsNullOrEmpty(textMinPeakFoundRatio.Text)) { double minVal; if (!helper.ValidateDecimalTextBox(tabControl1, 1, textMinPeakFoundRatio, 0, 1, out minVal)) { return; } minPeakFoundRatio = minVal; } if (!string.IsNullOrEmpty(textMaxPeakFoundRatio.Text)) { double maxVal; if (!helper.ValidateDecimalTextBox(tabControl1, 1, textMaxPeakFoundRatio, 0, 1, out maxVal)) { return; } maxPeakFoundRatio = maxVal; } if (minPeakFoundRatio.HasValue && maxPeakFoundRatio.HasValue && minPeakFoundRatio.Value > maxPeakFoundRatio.Value) { helper.ShowTextBoxError(textMaxPeakFoundRatio, Resources.RefineDlg_OkDialog__0__must_be_less_than_min_peak_found_ratio); return; } int?maxPepPeakRank = null; if (!string.IsNullOrEmpty(textMaxPepPeakRank.Text)) { int maxVal; if (!helper.ValidateNumberTextBox(tabControl1, 1, textMaxPepPeakRank, 1, 10, out maxVal)) { return; } maxPepPeakRank = maxVal; } int?maxPeakRank = null; if (!string.IsNullOrEmpty(textMaxPeakRank.Text)) { int maxVal; if (!helper.ValidateNumberTextBox(tabControl1, 1, textMaxPeakRank, 1, 10, out maxVal)) { return; } maxPeakRank = maxVal; } bool removeMissingResults = radioRemoveMissing.Checked; double?rtRegressionThreshold = null; if (!string.IsNullOrEmpty(textRTRegressionThreshold.Text)) { double minVal; if (!helper.ValidateDecimalTextBox(tabControl1, 1, textRTRegressionThreshold, 0, 1, out minVal)) { return; } rtRegressionThreshold = minVal; } double?dotProductThreshold = null; if (!string.IsNullOrEmpty(textMinDotProduct.Text)) { double minVal; if (!helper.ValidateDecimalTextBox(tabControl1, 1, textMinDotProduct, 0, 1, out minVal)) { return; } dotProductThreshold = minVal; } double?idotProductThreshold = null; if (!string.IsNullOrEmpty(textMinIdotProduct.Text)) { double minVal; if (!helper.ValidateDecimalTextBox(tabControl1, 1, textMinIdotProduct, 0, 1, out minVal)) { return; } idotProductThreshold = minVal; } bool useBestResult = comboReplicateUse.SelectedIndex > 0; RefinementSettings = new RefinementSettings { MinPeptidesPerProtein = minPeptidesPerProtein, RemoveRepeatedPeptides = removeRepeatedPeptides, RemoveDuplicatePeptides = removeDuplicatePeptides, RemoveMissingLibrary = removeMissingLibrary, MinTransitionsPepPrecursor = minTransitionsPerPrecursor, RefineLabelType = refineLabelType, AddLabelType = addLabelType, MinPeakFoundRatio = minPeakFoundRatio, MaxPeakFoundRatio = maxPeakFoundRatio, MaxPepPeakRank = maxPepPeakRank, MaxPeakRank = maxPeakRank, PreferLargeIons = cbPreferLarger.Checked, RemoveMissingResults = removeMissingResults, RTRegressionThreshold = rtRegressionThreshold, DotProductThreshold = dotProductThreshold, IdotProductThreshold = idotProductThreshold, UseBestResult = useBestResult, AutoPickChildrenAll = (cbAutoPeptides.Checked ? PickLevel.peptides : 0) | (cbAutoPrecursors.Checked ? PickLevel.precursors : 0) | (cbAutoTransitions.Checked ? PickLevel.transitions : 0) }; DialogResult = DialogResult.OK; Close(); }
public bool TryLoadSpectrum(string sequence, int charge, ExplicitMods mods, out IsotopeLabelType type, out SpectrumPeaksInfo spectrum) { var libraries = PeptideSettings.Libraries; foreach (var typedSequence in GetTypedSequences(sequence, mods)) { var key = new LibKey(typedSequence.ModifiedSequence, charge); if (libraries.TryLoadSpectrum(key, out spectrum)) { type = typedSequence.LabelType; return true; } } type = IsotopeLabelType.light; spectrum = null; return false; }
public TransitionGroup GetTransitionGroup(IsotopeLabelType labelType, Adduct adduct) { return(new TransitionGroup(Peptide, adduct, labelType)); }
private static SequenceMassCalc GetMassCalc(IsotopeLabelType labelType, IList<TypedMassCalc> massCalcs) { int index = massCalcs.IndexOf(calc => ReferenceEquals(labelType, calc.LabelType)); if (index == -1) return null; return massCalcs[index].MassCalc; }
public TransitionGroupDocNode GetTransitionGroupDocNode(SrmSettings settings, IsotopeLabelType labelType, Adduct adduct) { var transitionGroup = GetTransitionGroup(labelType, adduct); var transitionGroupDocNode = new TransitionGroupDocNode(transitionGroup, Annotations.EMPTY, settings, ExplicitMods, null, ExplicitTransitionGroupValues.EMPTY, null, null, false); return(transitionGroupDocNode); }
public TypedSequence(string modifiedSequence, IsotopeLabelType labelType) : this() { ModifiedSequence = modifiedSequence; LabelType = labelType; }
public MoleculeMassOffset GetNeutralFormula(SrmSettings settings, IsotopeLabelType labelType) { var transitionGroupDocNode = GetTransitionGroupDocNode(settings, labelType, Adduct.SINGLY_PROTONATED); return(transitionGroupDocNode.GetNeutralFormula(settings, ExplicitMods)); }
public double GetFragmentMass(IsotopeLabelType labelType, ExplicitMods mods, Transition transition, IsotopeDistInfo isotopeDist) { // Return the singly protonated mass of the peptide fragment, or custom ion mass before electron removal IFragmentMassCalc calc = GetFragmentCalc(labelType, mods); if (calc == null && transition.IsCustom()) { // Small molecules provide their own ion formula, just use the standard calculator calc = GetDefaultFragmentCalc(); } if (calc == null) { Assume.Fail(string.Format("Unable to locate fragment calculator for isotope label type {0} and mods {1}", // Not L10N labelType == null ? "(null)" : labelType.ToString(), // Not L10N mods == null ? "(null)" : mods.ToString())); // Not L10N return 0; // Keep resharper happy } return calc.GetFragmentMass(transition, isotopeDist); }
public PaneKey(IsotopeLabelType isotopeLabelType) : this(null, isotopeLabelType, false) { }
public IPrecursorMassCalc GetPrecursorCalc(IsotopeLabelType labelType, ExplicitMods mods) { var precursorCalc = TryGetPrecursorCalc(labelType, mods); if (precursorCalc == null) { // Try to track down this exception: // https://skyline.gs.washington.edu/labkey/announcements/home/issues/exceptions/thread.view?entityId=217d79c8-9a84-1032-ae5f-da2025829168&_anchor=19667#row:19667 throw new InvalidDataException( String.Format("unable to locate precursor calculator for isotope label type {0} and mods {1}", // Not L10N labelType == null ? "(null)" : labelType.ToString(), // Not L10N mods == null ? "(null)" : mods.ToString())); // Not L10N } return precursorCalc; }
public static RatioPropertyName PeptideRatioProperty(IsotopeLabelType labelType, IsotopeLabelType standardType) { string prefix, propertyKey, headerText; if (standardType == null) { prefix = RATIO_GS_PREFIX; if (labelType.IsLight) { propertyKey = "RatioToGlobalStandards"; // Not L10N headerText = Resources.RatioPropertyAccessor_PeptideRatioProperty_Ratio_To_Global_Standards; } else { propertyKey = string.Format("Ratio{0}ToGlobalStandards", Helpers.MakeId(labelType.Name, true)); // Not L10N headerText = string.Format(Resources.RatioPropertyAccessor_PeptideRatioProperty_Ratio__0__To_Global_Standards, labelType.Title); } } else { prefix = RATIO_PREFIX; propertyKey = string.Format("Ratio{0}To{1}", // Not L10N Helpers.MakeId(labelType.Name, true), Helpers.MakeId(standardType.Name, true)); headerText = string.Format(Resources.RatioPropertyAccessor_PeptideProperty_Ratio__0__To__1_, labelType.Title, standardType.Title); } return new RatioPropertyName(prefix, propertyKey, headerText); }
/// <summary> /// Loads a list of all the spectra found in all loaded libraries /// matching the criteria passed in. /// </summary> /// <param name="sequence"> The sequence to match. </param> /// <param name="charge"> The charge to match. </param> /// <param name="labelType">The primary label type to match</param> /// <param name="mods"> The modifications to match. </param> /// <returns> Returns a list of the matching spectra. </returns> public IEnumerable<SpectrumInfo> GetRedundantSpectra(string sequence, int charge, IsotopeLabelType labelType, ExplicitMods mods) { string sequenceMod = GetModifiedSequence(sequence, labelType, mods); return PeptideSettings.Libraries.GetSpectra(new LibKey(sequenceMod, charge), labelType, false); }
public static RatioPropertyName PeptideRdotpProperty(IsotopeLabelType labelType, IsotopeLabelType standardType) { string key = string.Format("DotProduct{0}To{1}", // Not L10N Helpers.MakeId(labelType.Name, true), Helpers.MakeId(standardType.Name, true)); string headerText = string.Format(Resources.RDotPPropertyAccessor_PeptideProperty_Dot_Product__0__To__1_, labelType.Title, standardType.Title); return new RatioPropertyName(RDOTP_PREFIX, key, headerText); }
private void UpdateAxes(bool resetAxes, GraphValues.AggregateOp aggregateOp, AreaNormalizeToData normalizeData, AreaNormalizeToView areaView, IsotopeLabelType standardType) { if (resetAxes) { XAxis.Scale.MaxAuto = XAxis.Scale.MinAuto = true; YAxis.Scale.MaxAuto = true; } if (BarSettings.Type == BarType.PercentStack) { YAxis.Scale.Max = 100; YAxis.Scale.MaxAuto = false; YAxis.Title.Text = aggregateOp.AnnotateTitle(Resources.AreaReplicateGraphPane_UpdateGraph_Peak_Area_Percentage); YAxis.Type = AxisType.Linear; YAxis.Scale.MinAuto = false; FixedYMin = YAxis.Scale.Min = 0; } else { if (normalizeData == AreaNormalizeToData.optimization) { // If currently log scale or normalized to max, reset the y-axis max if (YAxis.Type == AxisType.Log || YAxis.Scale.Max == 1) { YAxis.Scale.MaxAuto = true; } YAxis.Title.Text = aggregateOp.AnnotateTitle(Resources.AreaReplicateGraphPane_UpdateGraph_Percent_of_Regression_Peak_Area); YAxis.Type = AxisType.Linear; YAxis.Scale.MinAuto = false; FixedYMin = YAxis.Scale.Min = 0; } else if (areaView == AreaNormalizeToView.area_maximum_view) { YAxis.Scale.Max = 1; if (IsDotProductVisible) { // Make YAxis Scale Max a little higher to accommodate for the dot products YAxis.Scale.Max = 1.1; } YAxis.Scale.MaxAuto = false; YAxis.Title.Text = aggregateOp.AnnotateTitle(Resources.AreaReplicateGraphPane_UpdateGraph_Peak_Area_Normalized); YAxis.Type = AxisType.Linear; YAxis.Scale.MinAuto = false; FixedYMin = YAxis.Scale.Min = 0; } else if (Settings.Default.AreaLogScale) { // If currently not log scale, reset the y-axis max if (YAxis.Type != AxisType.Log) { YAxis.Scale.MaxAuto = true; } if (Settings.Default.PeakAreaMaxArea != 0) { YAxis.Scale.MaxAuto = false; YAxis.Scale.Max = Settings.Default.PeakAreaMaxArea; } YAxis.Type = AxisType.Log; YAxis.Title.Text = GraphValues.AnnotateLogAxisTitle(aggregateOp.AnnotateTitle( Resources.AreaReplicateGraphPane_UpdateGraph_Peak_Area)); YAxis.Scale.MinAuto = false; FixedYMin = YAxis.Scale.Min = 1; } else { // If currently log scale, reset the y-axis max if (YAxis.Type == AxisType.Log) { YAxis.Scale.MaxAuto = true; } if (Settings.Default.PeakAreaMaxArea != 0) { YAxis.Scale.MaxAuto = false; YAxis.Scale.Max = Settings.Default.PeakAreaMaxArea; } else if (!YAxis.Scale.MaxAuto) { YAxis.Scale.MaxAuto = true; } string yTitle = Resources.AreaReplicateGraphPane_UpdateGraph_Peak_Area; switch (areaView) { case AreaNormalizeToView.area_ratio_view: yTitle = string.Format(Resources.AreaReplicateGraphPane_UpdateGraph_Peak_Area_Ratio_To__0_, standardType.Title); break; case AreaNormalizeToView.area_global_standard_view: yTitle = Resources.AreaReplicateGraphPane_UpdateGraph_Peak_Area_Ratio_To_Global_Standards; break; } YAxis.Title.Text = aggregateOp.AnnotateTitle(yTitle); YAxis.Type = AxisType.Linear; YAxis.Scale.MinAuto = false; FixedYMin = YAxis.Scale.Min = 0; } // Handle a switch from percent stack if (!YAxis.Scale.MaxAuto && YAxis.Scale.Max == 100) { YAxis.Scale.MaxAuto = true; } } Legend.IsVisible = Settings.Default.ShowPeakAreaLegend; AxisChange(); // Reformat Y-Axis for labels and whiskers var maxY = GraphHelper.GetMaxY(CurveList, this); if (IsDotProductVisible) { var extraSpace = _lableHeight * (maxY / (Chart.Rect.Height - _lableHeight * 2)) * 2; maxY += extraSpace; } GraphHelper.ReformatYAxis(this, maxY > 0 ? maxY : 0.1); // Avoid same min and max, since it blanks the entire graph pane }
public static RatioPropertyName PrecursorRdotpProperty(IsotopeLabelType standardType) { string key = string.Format("DotProductTo{0}", Helpers.MakeId(standardType.Name, true)); // Not L10N string headerText = string.Format(Resources.RDotPPropertyAccessor_PrecursorProperty_Dot_Product_To__0_, standardType.Title); return new RatioPropertyName(RDOTP_PREFIX, key, headerText); }
// ReSharper disable PossibleMultipleEnumeration protected GraphData(SrmDocument document, TransitionGroupDocNode selectedGroup, PeptideGroupDocNode selectedProtein, int?iResult, DisplayTypeChrom displayType, GraphValues.IRetentionTimeTransformOp retentionTimeTransformOp, PaneKey paneKey) { RetentionTimeTransformOp = retentionTimeTransformOp; // Determine the shortest possible unique ID for each peptide or molecule var sequences = new List <Tuple <string, bool> >(); foreach (var nodePep in document.Molecules) { sequences.Add(new Tuple <string, bool>(nodePep.ModifiedTarget.DisplayName, nodePep.IsProteomic)); } var uniquePrefixGenerator = new UniquePrefixGenerator(sequences, 3); int pointListCount = 0; var dictTypeToSet = new Dictionary <IsotopeLabelType, int>(); bool onePointPerPeptide = PeptideOrder == SummaryPeptideOrder.document && null != paneKey.IsotopeLabelType; // Figure out how many point lists to create bool displayTotals = (displayType == DisplayTypeChrom.total); if (displayTotals) { foreach (var nodeGroup in document.MoleculeTransitionGroups) { if (!paneKey.IncludesTransitionGroup(nodeGroup)) { continue; } IsotopeLabelType labelType = nodeGroup.TransitionGroup.LabelType; if (!dictTypeToSet.ContainsKey(labelType)) { dictTypeToSet.Add(labelType, pointListCount++); } } } else { foreach (var nodeGroup in document.MoleculeTransitionGroups) { if (!paneKey.IncludesTransitionGroup(nodeGroup)) { continue; } pointListCount = Math.Max(pointListCount, GraphChromatogram.GetDisplayTransitions(nodeGroup, displayType).Count()); } } // Build the list of points to show. var listPoints = new List <GraphPointData>(); foreach (PeptideGroupDocNode nodeGroupPep in document.MoleculeGroups) { if (AreaGraphController.AreaScope == AreaScope.protein) { if (!ReferenceEquals(nodeGroupPep, selectedProtein)) { continue; } } foreach (PeptideDocNode nodePep in nodeGroupPep.Children) { bool addBlankPoint = onePointPerPeptide && !nodePep.TransitionGroups.Any(paneKey.IncludesTransitionGroup); foreach (TransitionGroupDocNode nodeGroup in nodePep.Children) { var path = new IdentityPath(nodeGroupPep.PeptideGroup, nodePep.Peptide, nodeGroup.TransitionGroup); var graphPointData = new GraphPointData(nodePep, nodeGroup, path); if (addBlankPoint || paneKey.IncludesTransitionGroup(nodeGroup)) { listPoints.Add(graphPointData); } if (addBlankPoint) { break; } } } } // Sort into correct order var peptideOrder = PeptideOrder; if (peptideOrder == SummaryPeptideOrder.time) { if (displayTotals) { listPoints.Sort(ComparePeptideTimes); } else { listPoints.Sort(CompareGroupTimes); } } else if (peptideOrder == SummaryPeptideOrder.area) { listPoints.Sort(CompareGroupAreas); } else if (peptideOrder == SummaryPeptideOrder.mass_error) { listPoints.Sort(CompareGroupMassErrors); } // Init calculated values var pointPairLists = new List <PointPairList>(); var labels = new List <string>(); var xscalePaths = new List <IdentityPath>(); double maxY = 0; double minY = double.MaxValue; int selectedIndex = -1; for (int i = 0; i < pointListCount; i++) { pointPairLists.Add(new PointPairList()); } // Calculate lists and values PeptideDocNode nodePepCurrent = null; int chargeCount = 0; var chargeCurrent = Adduct.EMPTY; foreach (var dataPoint in listPoints) { var nodePep = dataPoint.NodePep; var nodeGroup = dataPoint.NodeGroup; if (!ReferenceEquals(nodePep, nodePepCurrent)) { nodePepCurrent = nodePep; chargeCount = GetChargeCount(nodePep); chargeCurrent = Adduct.EMPTY; } bool addLabel = !displayTotals; if (displayTotals && !Equals(nodeGroup.TransitionGroup.PrecursorAdduct, chargeCurrent)) { LevelPointPairLists(pointPairLists); addLabel = true; } chargeCurrent = nodeGroup.TransitionGroup.PrecursorAdduct; var transitionGroup = nodeGroup.TransitionGroup; int iGroup = labels.Count; if (addLabel) { string label = uniquePrefixGenerator.GetUniquePrefix(nodePep.ModifiedTarget.DisplayName, nodePep.IsProteomic) + (chargeCount > 1 ? Transition.GetChargeIndicator(transitionGroup.PrecursorAdduct) : string.Empty); if (!displayTotals && null == paneKey.IsotopeLabelType) { label += transitionGroup.LabelTypeText; } if (peptideOrder == SummaryPeptideOrder.time) { label += string.Format(@" ({0:F01})", displayTotals ? dataPoint.TimePepCharge : dataPoint.TimeGroup); } labels.Add(label); xscalePaths.Add(dataPoint.IdentityPath); } double groupMaxY = 0; double groupMinY = double.MaxValue; // ReSharper disable DoNotCallOverridableMethodsInConstructor int?resultIndex = iResult.HasValue && iResult >= 0 ? iResult : null; if (RTLinearRegressionGraphPane.ShowReplicate == ReplicateDisplay.best && nodePep != null) { resultIndex = null; int iBest = nodePep.BestResult; if (iBest != -1) { resultIndex = iBest; } } if (displayTotals) { var labelType = nodeGroup.TransitionGroup.LabelType; if (dictTypeToSet.ContainsKey(labelType)) { if (paneKey.IncludesTransitionGroup(nodeGroup)) { pointPairLists[dictTypeToSet[labelType]].Add(CreatePointPair(iGroup, nodeGroup, ref groupMaxY, ref groupMinY, resultIndex)); } else { pointPairLists[dictTypeToSet[labelType]].Add(PointPairMissing(iGroup)); } } } else { if (paneKey.IncludesTransitionGroup(nodeGroup)) { var nodeTrans = GraphChromatogram.GetDisplayTransitions(nodeGroup, displayType).ToArray(); for (int i = 0; i < pointListCount; i++) { var pointPairList = pointPairLists[i]; pointPairList.Add(i >= nodeTrans.Length ? CreatePointPairMissing(iGroup) : CreatePointPair(iGroup, nodeTrans[i], ref groupMaxY, ref groupMinY, resultIndex)); } } else { for (int i = 0; i < pointListCount; i++) { pointPairLists[i].Add(CreatePointPairMissing(iGroup)); } } } // ReSharper restore DoNotCallOverridableMethodsInConstructor // Save the selected index and its y extent if (ReferenceEquals(selectedGroup, nodeGroup)) { selectedIndex = labels.Count - 1; SelectedMaxY = groupMaxY; SelectedMinY = groupMinY; } // If multiple groups in the selection, make sure y extent is max of them else if (selectedIndex == labels.Count - 1) { SelectedMaxY = Math.Max(groupMaxY, SelectedMaxY); SelectedMinY = Math.Min(groupMinY, SelectedMinY); } maxY = Math.Max(maxY, groupMaxY); minY = Math.Min(minY, groupMinY); } PointPairLists = pointPairLists; Labels = labels.ToArray(); XScalePaths = xscalePaths.ToArray(); SelectedIndex = selectedIndex; MaxY = maxY; if (minY != double.MaxValue) { MinY = minY; } }
public static RatioPropertyName TransitionRatioProperty(IsotopeLabelType standardType) { string prefix, key, header; if (standardType == null) { prefix = RATIO_GS_PREFIX; key = "AreaRatioToGlobalStandards"; // Not L10N header = Resources.RatioPropertyAccessor_TransitionRatioProperty_Area_Ratio_To_Global_Standards; } else { prefix = RATIO_PREFIX; key = "AreaRatioTo" + Helpers.MakeId(standardType.Name, true); // Not L10N header = string.Format(Resources.RatioPropertyAccessor_TransitionRatioProperty_Area_Ratio_To__0_, standardType.Title); } return new RatioPropertyName(prefix, key, header); }
public static string PeakAreaRatioText(IsotopeLabelType numerator, IsotopeLabelType denominator) { return(PeakAreaRatioText(new[] { numerator }, denominator)); }
private static bool Matches(IsotopeLabelType labelType, string name) { return(String.Equals(name, NormalizePart(labelType.Name), StringComparison.InvariantCultureIgnoreCase)); }
public static string ConcentrationRatioText(ICollection <IsotopeLabelType> numerator, IsotopeLabelType denominator) { String denominatorTitle = denominator == null ? StandardType.SURROGATE_STANDARD.Title : denominator.Title; if (numerator.Count == 1) { return(string.Format(QuantificationStrings.CalibrationCurveFitter_ConcentrationRatioText__0___1__Concentration_Ratio, numerator.First().Title, denominatorTitle)); } return(string.Format(QuantificationStrings.CalibrationCurveFitter_ConcentrationRatioText_Concentration_Ratio_to__0_, denominatorTitle)); }
private static PeptideLabelRatio FindPeptideLabelRatio(PeptideResult peptideResult, IsotopeLabelType labelType, IsotopeLabelType standardType) { return(peptideResult.ChromInfo.LabelRatios.FirstOrDefault( labelRatio => ReferenceEquals(labelType, labelRatio.LabelType) && ReferenceEquals(standardType, labelRatio.StandardType))); }
public RatioToLabel(IsotopeLabelType isotopeLabelType) : base(ratio_prefix + isotopeLabelType.Name) { _isotopeLabelType = new IsotopeLabelType(isotopeLabelType.Name, 0); }
public CalibrationPoint(int replicateIndex, IsotopeLabelType labelType) : this() { ReplicateIndex = replicateIndex; LabelType = labelType; }
// ReSharper restore NonLocalizedString public static NormalizationMethod GetNormalizationMethod(IsotopeLabelType isotopeLabelType) { return(FromName(ratio_prefix + isotopeLabelType.Name)); }
public void TestModificationMatcher() { InitSeqs(); var carbC = StaticModList.GetDefaultsOn()[0]; // Test exception thrown if unable to match - mass. UpdateMatcherFail(STR_FAIL_MASS); UpdateMatcherFail(STR_FAIL_NOT_A_NUMBER); // Test exception thrown if unable to match - name. UpdateMatcherFail(STR_FAIL_NAME); // Can't match empty modifications. UpdateMatcherFail(STR_FAIL_EMPTY_MOD); UpdateMatcherFail(STR_FAIL_EMPTY_MOD2); // Can't match double modifications. UpdateMatcherFail(STR_FAIL_DOUBLE_MOD); // Test exception thrown if unimod not specified correctly UpdateMatcherFail(STR_FAIL_UNIMOD); UpdateMatcherFail(STR_UNKNOWN_UNIMOD); // Can't phosphorylate tryptophan UpdateMatcherFail(STR_FAIL_WRONG_AA_UNIMOD); // Can't put C-terminal modification in middle of peptide UpdateMatcherFail(STR_FAIL_UNIMOD_TERMINUS); // Test mods in UniMod match correctly. UpdateMatcher(StaticModList.GetDefaultsOn(), HeavyModList.GetDefaultsOn(), null, null); // A sequence with no modifications should not be explicitly modified. Assert.IsFalse(MATCHER.GetModifiedNode(STR_NO_MODS).HasExplicitMods); var nodeCysOxi = MATCHER.GetModifiedNode(STR_CYS_AND_OXI); Assert.IsTrue(nodeCysOxi.HasExplicitMods); Assert.IsFalse(nodeCysOxi.ExplicitMods.HasHeavyModifications); // Modifications should match by name. Assert.IsTrue(MATCHER.GetModifiedNode(STR_MOD_BY_NAME).ExplicitMods.StaticModifications.Contains(mod => Equals(mod.Modification.Name, "Phospho (ST)"))); // Test can find terminal modification Assert.IsTrue(MATCHER.GetModifiedNode(STR_TERM_ONLY).ExplicitMods.HeavyModifications.Contains(mod => mod.Modification.EquivalentAll(UniMod.GetModification("Label:13C(6) (C-term R)", false)))); // Test can find matches on terminus that are not terminal Assert.IsTrue(MATCHER.GetModifiedNode(STR_MOD_BY_NAME).ExplicitMods.StaticModifications.Contains(mod => mod.Modification.Terminus == null)); // Test matching negative masses Assert.IsTrue(MATCHER.GetModifiedNode(STR_AMMONIA_LOSS).ExplicitMods.StaticModifications.Contains(mod => mod.Modification.EquivalentAll(UniMod.GetModification("Ammonia-loss (N-term C)", true)))); // General and specific // If all AAs modified, try for most general modification. Assert.IsTrue(MATCHER.GetModifiedNode(STR_HEAVY_15) .ExplicitMods.HeavyModifications.Contains(mod => mod.Modification.Equivalent(LABEL15_N))); // Updating the settings. // Peptide settings should change to include new mods. var docNew = new SrmDocument(SrmSettingsList.GetDefault()); IdentityPath firstAdded; IdentityPath nextAdded; docNew = docNew.AddPeptideGroups(new[] { new PeptideGroupDocNode(new PeptideGroup(), "PepGroup1", "", new[] { MATCHER.GetModifiedNode(STR_MOD_BY_NAME) }) }, true, null, out firstAdded, out nextAdded); var pepSetNew = MATCHER.GetDocModifications(docNew); Assert.IsTrue(pepSetNew.StaticModifications.Contains(UniMod.GetModification("Phospho (ST)", true).ChangeExplicit(true))); // Update the document to the new settings. var pepSetNew1 = pepSetNew; var settingsNew2 = docNew.Settings.ChangePeptideModifications(mods => pepSetNew1); var lightGlobalMods = new MappedList <string, StaticMod>(); lightGlobalMods.AddRange(settingsNew2.PeptideSettings.Modifications.StaticModifications); var heavyGlobalMods = new MappedList <string, StaticMod>(); heavyGlobalMods.AddRange(settingsNew2.PeptideSettings.Modifications.AllHeavyModifications); // Match again. Test FoundMatches string should now be empty. MATCHER.CreateMatches(docNew.Settings.ChangePeptideModifications(mods => pepSetNew1), new List <string> { STR_MOD_BY_NAME }, lightGlobalMods, heavyGlobalMods); Assert.IsTrue(string.IsNullOrEmpty(MATCHER.FoundMatches)); // Adding 15N to the settings. UpdateMatcher(new[] { carbC }, new[] { LABEL15_N }, null, null); // Test sequences with only explicit heavy mods should not have explicit light mods Assert.IsNull(MATCHER.GetModifiedNode(STR_HEAVY_ONLY).ExplicitMods.StaticModifications); // Test sequences with only explicit light mods should not have explicit heavy mods Assert.IsFalse(MATCHER.GetModifiedNode(STR_LIGHT_ONLY).ExplicitMods.HasHeavyModifications); // Test global mods take precendence over UniMod UpdateMatcher(new[] { carbC }, null, new[] { OXIDATION_M_GLOBAL }, new[] { LABEL15_N }); Assert.IsTrue(MATCHER.GetModifiedNode(STR_CYS_AND_OXI).ExplicitMods.StaticModifications .Contains(mod => Equals(mod.Modification, OXIDATION_M_GLOBAL))); // Test document mods take precendence over UniMod UpdateMatcher(new[] { carbC, METHIONINE_OXIDATION }, null, new[] { OXIDATION_M_GLOBAL }, new[] { LABEL15_N }); Assert.IsFalse(MATCHER.GetModifiedNode(STR_CYS_AND_OXI).HasExplicitMods); // Test exception thrown if match doesn't make sense - wrong AA. UpdateMatcherFail(STR_FAIL_OX_ON_D); // Test exception thrown if match doesn't make sense - wrong terminus. _seqs.Add(STR_FAIL_OX_TERM); AssertEx.ThrowsException <FormatException>(() => UpdateMatcher(new[] { OXIDATION_M_C_TERM }, null, null, null)); _seqs.Remove(STR_FAIL_OX_TERM); // Heavy 15N - All AAs. UpdateMatcher(new[] { carbC, METHIONINE_OXIDATION }, new[] { LABEL15_N }, null, null); // Node should be created from document settings if possible. Assert.IsNull(MATCHER.GetModifiedNode(STR_HEAVY_15).ExplicitMods); // Heavy 15N - specific AA. // If only a specific AA is modified, there must be an explicit mod. Assert.IsTrue(MATCHER.GetModifiedNode(STR_HEAVY_15_F).HasExplicitMods); // Test variable mods match correctly. // Put variable mod in global mod and not on doc - make sure don't get variable mod, // should get explicit mod in that case. var variableMetOx = METHIONINE_OXIDATION.ChangeVariable(true); UpdateMatcher(new[] { carbC }, null, new[] { variableMetOx }, null); Assert.IsTrue(MATCHER.GetModifiedNode(STR_CYS_AND_OXI).HasExplicitMods); Assert.IsFalse(MATCHER.GetModifiedNode(STR_CYS_OXI_PHOS).ExplicitMods.IsVariableStaticMods); Assert.IsFalse(MATCHER.GetModifiedNode(STR_CYS_OXI_PHOS_CAP).ExplicitMods.IsVariableStaticMods); // Add variable mod to doc UpdateMatcher(new[] { carbC, variableMetOx }, null, null, null); // Mod can be created by the settings. Assert.IsTrue(MATCHER.GetModifiedNode(STR_CYS_AND_OXI).HasExplicitMods); Assert.IsTrue(MATCHER.GetModifiedNode(STR_CYS_AND_OXI).ExplicitMods.IsVariableStaticMods); // Mod cannot be created by the settings. Assert.IsFalse(MATCHER.GetModifiedNode(STR_CYS_OXI_PHOS).ExplicitMods.IsVariableStaticMods); Assert.IsFalse(MATCHER.GetModifiedNode(STR_CYS_OXI_PHOS_CAP).ExplicitMods.IsVariableStaticMods); // Add Met Ox to global. Test: +16 finds it. UpdateMatcher(new[] { carbC }, null, new[] { MET_OX_ROUNDED }, null); Assert.IsTrue(MATCHER.GetModifiedNode(STR_CYS_AND_OXI). ExplicitMods.StaticModifications.Contains(mod => Equals(mod.Modification, MET_OX_ROUNDED))); // Test: +15.99 finds UniMod. Assert.IsFalse(MATCHER.GetModifiedNode(STR_HEAVY_15). ExplicitMods.StaticModifications.Contains(mod => Equals(mod.Modification, MET_OX_ROUNDED))); // Add Methionine Oxidation before Met Ox. Test: +16 finds it. UpdateMatcher(new[] { carbC }, null, new[] { METHIONINE_OXIDATION, MET_OX_ROUNDED }, null); Assert.IsFalse(MATCHER.GetModifiedNode(STR_CYS_AND_OXI). ExplicitMods.StaticModifications.Contains(mod => Equals(mod.Modification, MET_OX_ROUNDED))); Assert.IsTrue(MATCHER.GetModifiedNode(STR_CYS_AND_OXI). ExplicitMods.StaticModifications.Contains(mod => Equals(mod.Modification, METHIONINE_OXIDATION))); // Test long masses rounded. Assert.IsTrue(MATCHER.GetModifiedNode(STR_METOX_LONG_MASS).ExplicitMods.StaticModifications.Contains(mod => Equals(mod.Modification, METHIONINE_OXIDATION))); // Test UniMod label types var node = MATCHER.GetModifiedNode(STR_UNIMOD_LABEL); Assert.IsNotNull(node); Assert.IsNull(node.ExplicitMods.StaticModifications); Assert.IsTrue(node.ExplicitMods.HeavyModifications.Contains(mod => Equals(mod.Modification, N_TERM_LABEL))); UpdateMatcherWithNoSequences(new[] { carbC }, new[] { N_TERM_LABEL }, new[] { METHIONINE_OXIDATION, MET_OX_ROUNDED }, null); var nodeNew = MATCHER.GetModifiedNode(STR_UNIMOD_LABEL); Assert.IsNotNull(nodeNew); Assert.IsTrue(nodeNew.TransitionGroups.Any(group => Equals(group.TransitionGroup.LabelType, IsotopeLabelType.heavy))); UpdateMatcher(new[] { carbC }, null, new[] { METHIONINE_OXIDATION, MET_OX_ROUNDED }, null); // Test case where there are lots of unimod labels var nodeUniAll = MATCHER.GetModifiedNode(STR_UNIMOD_ALL); Assert.AreEqual(nodeUniAll.ExplicitMods.HeavyModifications.Count, 10); Assert.IsNull(nodeUniAll.ExplicitMods.StaticModifications); foreach (var mod in nodeUniAll.ExplicitMods.HeavyModifications) { Assert.AreEqual(mod.Modification.ShortName, "+01"); Assert.AreEqual(mod.Modification.UnimodId, 994); } // Test unimod terminal label var nodeUniTerm = MATCHER.GetModifiedNode(STR_UNIMOD_TERMINUS); Assert.AreEqual(nodeUniTerm.ExplicitMods.HeavyModifications.Count, 1); Assert.IsNull(nodeUniTerm.ExplicitMods.StaticModifications); Assert.AreEqual(nodeUniTerm.ExplicitMods.HeavyModifications[0].Modification.Terminus, ModTerminus.C); Assert.AreEqual(nodeUniTerm.ExplicitMods.HeavyModifications[0].Modification.UnimodId, 298); // Basic multi-label test var heavyLabelType2 = new IsotopeLabelType("Heavy2", 1); var typedMod = new TypedModifications(heavyLabelType2, new List <StaticMod> { LABEL15_N }); var peptideMods = new PeptideModifications(new List <StaticMod>(), new List <TypedModifications> { typedMod }); var settingsMultiLabel = SrmSettingsList.GetDefault().ChangePeptideModifications(mods => peptideMods); var defSetSetLight = new MappedList <string, StaticMod>(); defSetSetLight.AddRange(StaticModList.GetDefaultsOn()); var defSetHeavy = new MappedList <string, StaticMod>(); defSetHeavy.AddRange(HeavyModList.GetDefaultsOn()); defSetHeavy.Add(LABEL15_N); MATCHER.CreateMatches(settingsMultiLabel, new List <string> { STR_HEAVY_15_F }, defSetSetLight, defSetHeavy); Assert.IsTrue(MATCHER.GetModifiedNode(STR_HEAVY_15_F).ExplicitMods.GetHeavyModifications().Contains(mod => Equals(mod.LabelType, heavyLabelType2))); // Peptide settings should not change. var docNew0 = new SrmDocument(settingsMultiLabel).AddPeptideGroups(new[] { new PeptideGroupDocNode(new PeptideGroup(), "PepGroup1", "", new[] { MATCHER.GetModifiedNode(STR_HEAVY_15_F) }) }, true, null, out firstAdded, out nextAdded); var settingsNew = MATCHER.GetDocModifications(docNew0); Assert.AreEqual(settingsMultiLabel.PeptideSettings.Modifications.ChangeHasHeavyModifications(false), settingsNew.ChangeHasHeavyModifications(false)); // Finding specific modifications. // If only specific AA modified, try for most specific modification. UpdateMatcher(null, null, null, null, new[] { STR_HEAVY_15_F }); Assert.IsTrue(MATCHER.GetModifiedNode(STR_HEAVY_15_F) .ExplicitMods.HeavyModifications.Contains(mod => mod.Modification.AminoAcids.Contains(c => c == 'F'))); // If only some AAs modified, try for most specific modifications. UpdateMatcher(null, null, null, null, new[] { STR_HEAVY_15_NOT_ALL }); Assert.IsTrue(MATCHER.GetModifiedNode(STR_HEAVY_15_NOT_ALL) .ExplicitMods.HeavyModifications.Contains(mod => mod.Modification.AminoAcids.Contains(c => c == 'I'))); using (var testDir = new TestFilesDir(TestContext, ZIP_FILE)) using (var modMatchDocContainer = InitMatchDocContainer(testDir)) { var libkeyModMatcher = new LibKeyModificationMatcher(); var anlLibSpec = new BiblioSpecLiteSpec("ANL_Combo", testDir.GetTestPath("ANL_Combined.blib")); var yeastLibSpec = new BiblioSpecLiteSpec("Yeast", testDir.GetTestPath("Yeast_atlas_small.blib")); modMatchDocContainer.ChangeLibSpecs(new[] { anlLibSpec, yeastLibSpec }); var docLibraries = modMatchDocContainer.Document.Settings.PeptideSettings.Libraries.Libraries; int anlLibIndex = docLibraries.IndexOf(library => Equals(library.Name, anlLibSpec.Name)); int yeastLibIndex = docLibraries.IndexOf(library => Equals(library.Name, yeastLibSpec.Name)); libkeyModMatcher.CreateMatches(modMatchDocContainer.Document.Settings, docLibraries[anlLibIndex].Keys, defSetSetLight, defSetHeavy); // Test can match 15N Assert.IsTrue(libkeyModMatcher.Matches.Values.Contains(match => match.HeavyMod != null && match.HeavyMod.Equivalent(LABEL15_N))); var uniModMetOx = UniMod.GetModification("Oxidation (M)", true); // Test can match Met Ox Assert.IsTrue(libkeyModMatcher.Matches.Values.Contains(match => match.StructuralMod != null && match.StructuralMod.Equivalent(uniModMetOx))); // Test can match 15N and Met ox! Assert.IsTrue(libkeyModMatcher.Matches.Contains(match => match.Key.Mass == 17 && match.Value.StructuralMod != null && match.Value.StructuralMod.Equivalent(uniModMetOx) && match.Value.HeavyMod != null && match.Value.HeavyMod.Equivalent(LABEL15_N))); // Test can match Cysteine (Implicit) and Met Ox (variable) libkeyModMatcher.CreateMatches(modMatchDocContainer.Document.Settings, docLibraries[yeastLibIndex].Keys, defSetSetLight, defSetHeavy); Assert.IsTrue(libkeyModMatcher.MatcherPepMods.StaticModifications.Contains(mod => mod.Formula.Equals(UniMod.GetModification(StaticModList.DEFAULT_NAME, true).Formula) && !mod.IsVariable)); Assert.IsTrue(libkeyModMatcher.MatcherPepMods.StaticModifications.Contains(mod => mod.Formula.Equals("O") && mod.IsVariable)); } }
public void UpdateUI(bool selectionChanged = true) { // Only worry about updates, if the graph is visible // And make sure it is not disposed, since rendering happens on a timer if (!Visible || IsDisposed) { return; } // Clear existing data from the graph pane var graphPane = (MSGraphPane)graphControl.MasterPane[0]; graphPane.CurveList.Clear(); graphPane.GraphObjList.Clear(); GraphItem = null; GraphHelper.FormatGraphPane(graphControl.GraphPane); GraphHelper.FormatFontSize(graphControl.GraphPane, Settings.Default.SpectrumFontSize); // Try to find a tree node with spectral library info associated // with the current selection. var nodeTree = _stateProvider.SelectedNode as SrmTreeNode; var nodeGroupTree = nodeTree as TransitionGroupTreeNode; var nodeTranTree = nodeTree as TransitionTreeNode; if (nodeTranTree != null) { nodeGroupTree = nodeTranTree.Parent as TransitionGroupTreeNode; } var nodeGroup = (nodeGroupTree != null ? nodeGroupTree.DocNode : null); PeptideTreeNode nodePepTree; if (nodeGroup == null) { nodePepTree = nodeTree as PeptideTreeNode; if (nodePepTree != null) { var listInfoGroups = GetLibraryInfoChargeGroups(nodePepTree); if (listInfoGroups.Length == 1) { nodeGroup = listInfoGroups[0]; } else if (listInfoGroups.Length > 1) { _nodeGroup = null; toolBar.Visible = false; _graphHelper.SetErrorGraphItem(new NoDataMSGraphItem( Resources.GraphSpectrum_UpdateUI_Multiple_charge_states_with_library_spectra)); return; } } } else { nodePepTree = nodeGroupTree.Parent as PeptideTreeNode; } // Check for appropriate spectrum to load SrmSettings settings = DocumentUI.Settings; PeptideLibraries libraries = settings.PeptideSettings.Libraries; bool available = false; if (nodeGroup == null || (!nodeGroup.HasLibInfo && !libraries.HasMidasLibrary)) { _spectra = null; } else { TransitionGroup group = nodeGroup.TransitionGroup; TransitionDocNode transition = (nodeTranTree == null ? null : nodeTranTree.DocNode); var lookupSequence = group.Peptide.Target;// Sequence or custom ion id ExplicitMods lookupMods = null; if (nodePepTree != null) { lookupSequence = nodePepTree.DocNode.SourceUnmodifiedTarget; lookupMods = nodePepTree.DocNode.SourceExplicitMods; } try { // Try to load a list of spectra matching the criteria for // the current node group. if (libraries.HasLibraries && libraries.IsLoaded) { if (NodeGroupChanged(nodeGroup)) { try { UpdateSpectra(nodeGroup, lookupSequence, lookupMods); UpdateToolbar(); } catch (Exception) { _spectra = null; UpdateToolbar(); throw; } _nodeGroup = nodeGroup; if (settings.TransitionSettings.Instrument.IsDynamicMin) { ZoomSpectrumToSettings(); } } var spectrum = SelectedSpectrum; if (spectrum != null) { IsotopeLabelType typeInfo = spectrum.LabelType; var types = _stateProvider.ShowIonTypes(group.IsProteomic); var adducts = (group.IsProteomic ? Transition.DEFAULT_PEPTIDE_LIBRARY_CHARGES : nodeGroup.InUseAdducts).ToArray(); var charges = _stateProvider.ShowIonCharges(adducts); var rankTypes = group.IsProteomic ? settings.TransitionSettings.Filter.PeptideIonTypes : settings.TransitionSettings.Filter.SmallMoleculeIonTypes; var rankAdducts = group.IsProteomic ? settings.TransitionSettings.Filter.PeptideProductCharges : settings.TransitionSettings.Filter.SmallMoleculeFragmentAdducts; var rankCharges = Adduct.OrderedAbsoluteChargeValues(rankAdducts); // Make sure the types and charges in the settings are at the head // of these lists to give them top priority, and get rankings correct. int i = 0; foreach (IonType type in rankTypes) { if (types.Remove(type)) { types.Insert(i++, type); } } i = 0; var showAdducts = new List <Adduct>(); foreach (var charge in rankCharges) { if (charges.Remove(charge)) { charges.Insert(i++, charge); } // NB for all adducts we just look at abs value of charge // CONSIDER(bspratt): we may want finer per-adduct control for small molecule use showAdducts.AddRange(adducts.Where(a => charge == Math.Abs(a.AdductCharge))); } showAdducts.AddRange(adducts.Where(a => charges.Contains(Math.Abs(a.AdductCharge)) && !showAdducts.Contains(a))); SpectrumPeaksInfo spectrumInfo = spectrum.SpectrumPeaksInfo; var spectrumInfoR = new LibraryRankedSpectrumInfo(spectrumInfo, typeInfo, nodeGroup, settings, lookupSequence, lookupMods, showAdducts, types, rankAdducts, rankTypes); GraphItem = new SpectrumGraphItem(nodeGroup, transition, spectrumInfoR, spectrum.LibName) { ShowTypes = types, ShowCharges = charges, ShowRanks = Settings.Default.ShowRanks, ShowMz = Settings.Default.ShowIonMz, ShowObservedMz = Settings.Default.ShowObservedMz, ShowDuplicates = Settings.Default.ShowDuplicateIons, FontSize = Settings.Default.SpectrumFontSize, LineWidth = Settings.Default.SpectrumLineWidth }; LibraryChromGroup chromatogramData = null; if (Settings.Default.ShowLibraryChromatograms) { chromatogramData = spectrum.LoadChromatogramData(); } if (null == chromatogramData) { _graphHelper.ResetForSpectrum(new[] { nodeGroup.TransitionGroup }); _graphHelper.AddSpectrum(GraphItem); _graphHelper.ZoomSpectrumToSettings(DocumentUI, nodeGroup); } else { _graphHelper.ResetForChromatograms(new[] { nodeGroup.TransitionGroup }); var displayType = GraphChromatogram.GetDisplayType(DocumentUI, nodeGroup); IList <TransitionDocNode> displayTransitions = GraphChromatogram.GetDisplayTransitions(nodeGroup, displayType).ToArray(); int numTrans = displayTransitions.Count; var allChromDatas = chromatogramData.ChromDatas.Where( chromData => DisplayTypeMatches(chromData, displayType)).ToList(); var chromDatas = new List <LibraryChromGroup.ChromData>(); for (int iTran = 0; iTran < numTrans; iTran++) { var displayTransition = displayTransitions[iTran]; var indexMatch = allChromDatas.IndexOf(chromData => IonMatches(displayTransition.Transition, chromData)); if (indexMatch >= 0) { chromDatas.Add(allChromDatas[indexMatch]); allChromDatas.RemoveAt(indexMatch); } else { chromDatas.Add(null); } } allChromDatas.Sort((chromData1, chromData2) => chromData1.Mz.CompareTo(chromData2.Mz)); chromDatas.AddRange(allChromDatas); double maxHeight = chromDatas.Max(chromData => null == chromData ? double.MinValue : chromData.Height); int iChromDataPrimary = chromDatas.IndexOf(chromData => null != chromData && maxHeight == chromData.Height); int colorOffset = displayType == DisplayTypeChrom.products ? GraphChromatogram.GetDisplayTransitions(nodeGroup, DisplayTypeChrom. precursors).Count() : 0; for (int iChromData = 0; iChromData < chromDatas.Count; iChromData++) { var chromData = chromDatas[iChromData]; if (chromData == null) { continue; } string label; var pointAnnotation = GraphItem.AnnotatePoint(new PointPair(chromData.Mz, 1.0)); if (null != pointAnnotation) { label = pointAnnotation.Label; } else { label = chromData.Mz.ToString(@"0.####"); } TransitionDocNode matchingTransition; Color color; if (iChromData < numTrans) { matchingTransition = displayTransitions[iChromData]; color = GraphChromatogram.COLORS_LIBRARY[ (iChromData + colorOffset) % GraphChromatogram.COLORS_LIBRARY.Count]; } else { matchingTransition = null; color = GraphChromatogram.COLORS_GROUPS[ iChromData % GraphChromatogram.COLORS_GROUPS.Count]; } TransitionChromInfo tranPeakInfo; ChromatogramInfo chromatogramInfo; MakeChromatogramInfo(nodeGroup.PrecursorMz, chromatogramData, chromData, out chromatogramInfo, out tranPeakInfo); var graphItem = new ChromGraphItem(nodeGroup, matchingTransition, chromatogramInfo, iChromData == iChromDataPrimary ? tranPeakInfo : null, null, new[] { iChromData == iChromDataPrimary }, null, 0, false, false, null, 0, color, Settings.Default.ChromatogramFontSize, 1); LineItem curve = (LineItem)_graphHelper.AddChromatogram(PaneKey.DEFAULT, graphItem); if (matchingTransition == null) { curve.Label.Text = label; } curve.Line.Width = Settings.Default.ChromatogramLineWidth; if (null != transition) { if (IonMatches(transition.Transition, chromData)) { color = ChromGraphItem.ColorSelected; } } curve.Color = color; } graphPane.Title.IsVisible = false; graphPane.Legend.IsVisible = true; _graphHelper.FinishedAddingChromatograms(chromatogramData.StartTime, chromatogramData.EndTime, false); graphControl.Refresh(); } graphControl.IsEnableVPan = graphControl.IsEnableVZoom = !Settings.Default.LockYAxis; available = true; } } } catch (Exception) { _graphHelper.SetErrorGraphItem(new NoDataMSGraphItem( Resources.GraphSpectrum_UpdateUI_Failure_loading_spectrum__Library_may_be_corrupted)); return; } } // Show unavailable message, if no spectrum loaded if (!available) { UpdateToolbar(); _nodeGroup = null; _graphHelper.SetErrorGraphItem(new UnavailableMSGraphItem()); } }
/// <summary> /// For creating at the Molecule level (create molecule and first transition group) or modifying at the transition level /// Null values imply "don't ask user for this" /// </summary> public EditCustomMoleculeDlg(SkylineWindow parent, UsageMode usageMode, string title, Identity initialId, IEnumerable <Identity> existingIds, int minCharge, int maxCharge, SrmSettings settings, CustomMolecule molecule, Adduct defaultCharge, ExplicitTransitionGroupValues explicitTransitionGroupAttributes, ExplicitTransitionValues explicitTransitionAttributes, ExplicitRetentionTimeInfo explicitRetentionTime, IsotopeLabelType defaultIsotopeLabelType) { Text = title; _parent = parent; _initialId = initialId; _existingIds = existingIds; _minCharge = minCharge; _maxCharge = maxCharge; _transitionSettings = settings != null ? settings.TransitionSettings : null; _peptideSettings = settings != null ? settings.PeptideSettings : null; _resultAdduct = Adduct.EMPTY; _resultCustomMolecule = molecule; _usageMode = usageMode; var enableFormulaEditing = usageMode == UsageMode.moleculeNew || usageMode == UsageMode.moleculeEdit || usageMode == UsageMode.fragment; var enableAdductEditing = usageMode == UsageMode.moleculeNew || usageMode == UsageMode.precursor || usageMode == UsageMode.fragment; var suggestOnlyAdductsWithMass = usageMode != UsageMode.fragment; var needExplicitTransitionValues = usageMode == UsageMode.fragment; var needExplicitTransitionGroupValues = usageMode == UsageMode.moleculeNew || usageMode == UsageMode.precursor; InitializeComponent(); NameText = molecule == null ? String.Empty : molecule.Name; textName.Enabled = usageMode == UsageMode.moleculeNew || usageMode == UsageMode.moleculeEdit || usageMode == UsageMode.fragment; // Can user edit name? var needOptionalValuesBox = explicitRetentionTime != null || explicitTransitionGroupAttributes != null || explicitTransitionAttributes != null; if (!needExplicitTransitionValues) { labelCollisionEnergy.Visible = false; textCollisionEnergy.Visible = false; labelSLens.Visible = false; textSLens.Visible = false; labelConeVoltage.Visible = false; textConeVoltage.Visible = false; labelIonMobilityHighEnergyOffset.Visible = false; textIonMobilityHighEnergyOffset.Visible = false; labelDeclusteringPotential.Visible = false; textDeclusteringPotential.Visible = false; } if (!needExplicitTransitionGroupValues) { labelCCS.Visible = false; textBoxCCS.Visible = false; labelIonMobility.Visible = false; textIonMobility.Visible = false; labelIonMobilityUnits.Visible = false; comboBoxIonMobilityUnits.Visible = false; } var heightDelta = 0; // Initialise the ion mobility units dropdown with L10N values foreach (eIonMobilityUnits t in Enum.GetValues(typeof(eIonMobilityUnits))) { comboBoxIonMobilityUnits.Items.Add(IonMobilityFilter.IonMobilityUnitsL10NString(t)); } if (needOptionalValuesBox) { var newHeight = groupBoxOptionalValues.Height; var movers = new List <Control>(); int offset = 0; if (!needExplicitTransitionGroupValues && !needExplicitTransitionValues) { // We blanked out everything but the retention time newHeight = labelCollisionEnergy.Location.Y; } else if (!needExplicitTransitionGroupValues) { // We need to shift transition-level items up to where retention time was movers.AddRange(new Control[] { textCollisionEnergy, labelCollisionEnergy, textDeclusteringPotential, labelDeclusteringPotential, textSLens, labelSLens, textConeVoltage, labelConeVoltage, textIonMobilityHighEnergyOffset, labelIonMobilityHighEnergyOffset }); labelIonMobilityHighEnergyOffset.Location = labelIonMobility.Location; textIonMobilityHighEnergyOffset.Location = textIonMobility.Location; offset = labelCollisionEnergy.Location.Y - labelRetentionTime.Location.Y; newHeight = textBoxCCS.Location.Y; } else if (!needExplicitTransitionValues) { // We need to shift precursor-level items up to where retention time was movers.AddRange(new Control[] { textBoxCCS, labelCCS, textIonMobility, labelIonMobility, comboBoxIonMobilityUnits, labelIonMobilityUnits }); offset = labelIonMobility.Location.Y - (explicitRetentionTime == null ? labelRetentionTime.Location.Y : labelCollisionEnergy.Location.Y); newHeight = explicitRetentionTime == null ? textSLens.Location.Y : textIonMobility.Location.Y; } foreach (var mover in movers) { mover.Anchor = AnchorStyles.Left | AnchorStyles.Top; mover.Location = new Point(mover.Location.X, mover.Location.Y - offset); } heightDelta = groupBoxOptionalValues.Height - newHeight; groupBoxOptionalValues.Height = newHeight; } ResultExplicitTransitionGroupValues = new ExplicitTransitionGroupValues(explicitTransitionGroupAttributes); ResultExplicitTransitionValues = new ExplicitTransitionValues(explicitTransitionAttributes); string labelAverage = !defaultCharge.IsEmpty ? Resources.EditCustomMoleculeDlg_EditCustomMoleculeDlg_A_verage_m_z_ : Resources.EditCustomMoleculeDlg_EditCustomMoleculeDlg_A_verage_mass_; string labelMono = !defaultCharge.IsEmpty ? Resources.EditCustomMoleculeDlg_EditCustomMoleculeDlg__Monoisotopic_m_z_ : Resources.EditCustomMoleculeDlg_EditCustomMoleculeDlg__Monoisotopic_mass_; var defaultFormula = molecule == null ? string.Empty : molecule.Formula; var transition = initialId as Transition; FormulaBox.EditMode editMode; if (enableAdductEditing && !enableFormulaEditing) { editMode = FormulaBox.EditMode.adduct_only; } else if (!enableAdductEditing && enableFormulaEditing) { editMode = FormulaBox.EditMode.formula_only; } else { editMode = FormulaBox.EditMode.formula_and_adduct; } string formulaBoxLabel; if (defaultCharge.IsEmpty) { formulaBoxLabel = Resources.EditCustomMoleculeDlg_EditCustomMoleculeDlg_Chemi_cal_formula_; } else if (editMode == FormulaBox.EditMode.adduct_only) { var prompt = defaultFormula; if (string.IsNullOrEmpty(defaultFormula) && molecule != null) { // Defined by mass only prompt = molecule.ToString(); } formulaBoxLabel = string.Format(Resources.EditCustomMoleculeDlg_EditCustomMoleculeDlg_Addu_ct_for__0__, prompt); } else { formulaBoxLabel = Resources.EditMeasuredIonDlg_EditMeasuredIonDlg_Ion__chemical_formula_; } double?averageMass = null; double?monoMass = null; if (transition != null && string.IsNullOrEmpty(defaultFormula) && transition.IsCustom()) { averageMass = transition.CustomIon.AverageMass; monoMass = transition.CustomIon.MonoisotopicMass; } else if (molecule != null) { averageMass = molecule.AverageMass; monoMass = molecule.MonoisotopicMass; } _formulaBox = new FormulaBox(false, // Not proteomic, so offer Cl and Br in atoms popup formulaBoxLabel, labelAverage, labelMono, defaultCharge, editMode, suggestOnlyAdductsWithMass) { NeutralFormula = defaultFormula, AverageMass = averageMass, MonoMass = monoMass, Location = new Point(textName.Left, textName.Bottom + 12) }; _formulaBox.ChargeChange += (sender, args) => { if (!_formulaBox.Adduct.IsEmpty) { Adduct = _formulaBox.Adduct; var revisedFormula = _formulaBox.NeutralFormula + Adduct.AdductFormula; if (!Equals(revisedFormula, _formulaBox.Formula)) { _formulaBox.Formula = revisedFormula; } if (string.IsNullOrEmpty(_formulaBox.NeutralFormula) && averageMass.HasValue) { _formulaBox.AverageMass = averageMass; _formulaBox.MonoMass = monoMass; } } }; Controls.Add(_formulaBox); _formulaBox.TabIndex = 2; _formulaBox.Enabled = enableFormulaEditing || enableAdductEditing; Adduct = defaultCharge; var needCharge = !Adduct.IsEmpty; textCharge.Visible = labelCharge.Visible = needCharge; if (needOptionalValuesBox && !needCharge) { heightDelta += groupBoxOptionalValues.Location.Y - labelCharge.Location.Y; groupBoxOptionalValues.Location = new Point(groupBoxOptionalValues.Location.X, labelCharge.Location.Y); } if (explicitRetentionTime == null) { // Don't ask user for retetention times RetentionTime = null; RetentionTimeWindow = null; labelRetentionTime.Visible = false; labelRetentionTimeWindow.Visible = false; textRetentionTime.Visible = false; textRetentionTimeWindow.Visible = false; } else { RetentionTime = explicitRetentionTime.RetentionTime; RetentionTimeWindow = explicitRetentionTime.RetentionTimeWindow; } if (!needOptionalValuesBox) { groupBoxOptionalValues.Visible = false; heightDelta = groupBoxOptionalValues.Height; } // Initialize label if (settings != null && defaultIsotopeLabelType != null) { _driverLabelType = new PeptideSettingsUI.LabelTypeComboDriver(PeptideSettingsUI.LabelTypeComboDriver.UsageType.InternalStandardPicker, comboIsotopeLabelType, settings.PeptideSettings.Modifications, null, null, null, null) { SelectedName = defaultIsotopeLabelType.Name }; } else { comboIsotopeLabelType.Visible = false; labelIsotopeLabelType.Visible = false; } Height -= heightDelta; }
private const string RDOTP_PREFIX = "rdotp_"; // Not L10N public static RatioPropertyName PeptideRatioProperty(IsotopeLabelType labelType, IsotopeLabelType standardType) { string prefix, propertyKey, headerText; if (standardType == null) { prefix = RATIO_GS_PREFIX; if (labelType.IsLight) { propertyKey = "RatioToGlobalStandards"; // Not L10N headerText = Resources.RatioPropertyAccessor_PeptideRatioProperty_Ratio_To_Global_Standards; } else { propertyKey = string.Format("Ratio{0}ToGlobalStandards", Helpers.MakeId(labelType.Name, true)); // Not L10N headerText = string.Format(Resources.RatioPropertyAccessor_PeptideRatioProperty_Ratio__0__To_Global_Standards, labelType.Title); } } else { prefix = RATIO_PREFIX; propertyKey = string.Format("Ratio{0}To{1}", // Not L10N Helpers.MakeId(labelType.Name, true), Helpers.MakeId(standardType.Name, true)); headerText = string.Format(Resources.RatioPropertyAccessor_PeptideProperty_Ratio__0__To__1_, labelType.Title, standardType.Title); } return(new RatioPropertyName(prefix, propertyKey, headerText)); }
public bool HasPrecursorCalc(IsotopeLabelType labelType, ExplicitMods mods) { if (labelType.IsLight) return true; return TryGetPrecursorCalc(labelType, mods) != null; }