public void FindPeaks(double[] retentionTimes, TimeIntervals timeIntervals, ExplicitRetentionTimeInfo explicitRT) { Finder = Crawdads.NewCrawdadPeakFinder(); Finder.SetChromatogram(Times, Intensities); if (timeIntervals == null) { RawPeaks = Finder.CalcPeaks(MAX_PEAKS, TimesToIndices(retentionTimes)); } else { var identifiedIndices = TimesToIndices(retentionTimes); var allPeaks = timeIntervals.Intervals.SelectMany(interval => FindIntervalPeaks(interval.Key, interval.Value, identifiedIndices)); RawPeaks = allPeaks.OrderByDescending(peak => Tuple.Create(peak.Identified, peak.Area)) .Take(MAX_PEAKS).ToArray(); } // Calculate smoothing for later use in extending the Crawdad peaks IntensitiesSmooth = ChromatogramInfo.SavitzkyGolaySmooth(Intensities.ToArray()); // Accept only peaks within the user-provided RT window, if any if (explicitRT != null) { var winLow = (float)(explicitRT.RetentionTime - 0.5 * (explicitRT.RetentionTimeWindow ?? 0)); var winHigh = winLow + (float)(explicitRT.RetentionTimeWindow ?? 0); RawPeaks = RawPeaks.Where(rp => { var t = Times[rp.TimeIndex]; return(winLow <= t && t <= winHigh); }); } }
public ExplicitValues(ExplicitRetentionTimeInfo resultRetentionTimeInfo, ExplicitTransitionGroupValues resultExplicitTransitionGroupValues, ExplicitTransitionValues resultExplicitTransitionValues) { ResultRetentionTimeInfo = resultRetentionTimeInfo; ResultExplicitTransitionGroupValues = resultExplicitTransitionGroupValues; ResultExplicitTransitionValues = resultExplicitTransitionValues; }
/// <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; }
/// <summary> /// For modifying at the Molecule level /// </summary> public EditCustomMoleculeDlg(SkylineWindow parent, string title, SrmSettings settings, string defaultName, string defaultFormula, ExplicitRetentionTimeInfo explicitRetentionTime) : this(parent, title, null, null, 0, 0, null, defaultName, defaultFormula, null, null, explicitRetentionTime, null, false) { }
/// <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; }
/// <summary> /// For modifying at the Molecule level /// </summary> public EditCustomMoleculeDlg(SkylineWindow parent, string title, SrmSettings settings, CustomMolecule molecule, ExplicitRetentionTimeInfo explicitRetentionTime) : this(parent, UsageMode.moleculeEdit, title, null, null, 0, 0, null, molecule, Adduct.EMPTY, null, null, explicitRetentionTime, null) { }