示例#1
0
        public SrmSettings(string name, PeptideSettings peptideSettings, TransitionSettings transitionSettings, DataSettings dataSettings, DocumentRetentionTimes documentRetentionTimes)
            : base(name)
        {
            PeptideSettings = peptideSettings;
            TransitionSettings = transitionSettings;
            DataSettings = dataSettings;
            DocumentRetentionTimes = documentRetentionTimes;

            // Create cached calculator instances
            CreatePrecursorMassCalcs();
            CreateFragmentMassCalcs();
        }
示例#2
0
        public SrmSettings ChangePeptideSettings(PeptideSettings prop)
        {
            SrmSettings settings = ChangeProp(ImClone(this), im => im.PeptideSettings = prop);

            // If modifications have change, then new mass calculators are needed.
            if (!Equals(prop.Modifications, PeptideSettings.Modifications))
            {
                settings.CreatePrecursorMassCalcs();
                settings.CreateFragmentMassCalcs();
            }

            return settings;
        }
        public void OkDialog()
        {
            var helper = new MessageBoxHelper(this);
            var charge = 0;
            if (textCharge.Visible && !helper.ValidateSignedNumberTextBox(textCharge, _minCharge, _maxCharge, out charge))
                return;
            if (RetentionTimeWindow.HasValue && !RetentionTime.HasValue)
            {
                helper.ShowTextBoxError(textRetentionTimeWindow,
                    Resources.Peptide_ExplicitRetentionTimeWindow_Explicit_retention_time_window_requires_an_explicit_retention_time_value_);
                return;
            }
            Charge = charge; // Note: order matters here, this settor indirectly updates _formulaBox.MonoMass when formula is empty
            if (string.IsNullOrEmpty(_formulaBox.Formula))
            {
                // Can the text fields be understood as mz?
                if (!_formulaBox.ValidateAverageText(helper))
                    return;
                if (!_formulaBox.ValidateMonoText(helper))
                    return;
            }
            var formula = _formulaBox.Formula;
            var monoMass = _formulaBox.MonoMass ?? 0;
            var averageMass = _formulaBox.AverageMass ?? 0;
            if (monoMass < CustomIon.MIN_MASS || averageMass < CustomIon.MIN_MASS)
            {
                _formulaBox.ShowTextBoxErrorFormula(helper,
                    string.Format(Resources.EditCustomMoleculeDlg_OkDialog_Custom_molecules_must_have_a_mass_greater_than_or_equal_to__0__,
                        CustomIon.MIN_MASS));
                return;
            }
            if (monoMass > CustomIon.MAX_MASS || averageMass > CustomIon.MAX_MASS)
            {
                _formulaBox.ShowTextBoxErrorFormula(helper,
                    string.Format(Resources.EditCustomMoleculeDlg_OkDialog_Custom_molecules_must_have_a_mass_less_than_or_equal_to__0__, CustomIon.MAX_MASS));
                return;
            }

            if ((_transitionSettings != null) &&
                (!_transitionSettings.IsMeasurablePrecursor(BioMassCalc.CalculateIonMz(monoMass, charge)) ||
                !_transitionSettings.IsMeasurablePrecursor(BioMassCalc.CalculateIonMz(averageMass, charge))))
            {
                _formulaBox.ShowTextBoxErrorFormula(helper, Resources.SkylineWindow_AddMolecule_The_precursor_m_z_for_this_molecule_is_out_of_range_for_your_instrument_settings_);
                return;
            }
            if (!string.IsNullOrEmpty(_formulaBox.Formula))
            {
                try
                {
                    ResultCustomIon = new DocNodeCustomIon(formula, textName.Text);
                }
                catch (InvalidDataException x)
                {
                    _formulaBox.ShowTextBoxErrorFormula(helper, x.Message);
                    return;
                }
            }
            else
            {
                ResultCustomIon = new DocNodeCustomIon(monoMass, averageMass, textName.Text);
            }
            // Did user change the list of heavy labels?
            if (_driverLabelType != null)
            {
                PeptideModifications modifications = new PeptideModifications(
                    _peptideSettings.Modifications.StaticModifications,
                    _peptideSettings.Modifications.MaxVariableMods,
                    _peptideSettings.Modifications.MaxNeutralLosses,
                    _driverLabelType.GetHeavyModifications(), // This is the only thing the user may have altered
                    _peptideSettings.Modifications.InternalStandardTypes);
                var settings = _peptideSettings.ChangeModifications(modifications);
                // Only update if anything changed
                if (!Equals(settings, _peptideSettings))
                {
                    SrmSettings newSettings = _parent.DocumentUI.Settings.ChangePeptideSettings(settings);
                    if (!_parent.ChangeSettings(newSettings, true))
                    {
                        return;
                    }
                    _peptideSettings = newSettings.PeptideSettings;
                }
            }

            // See if this combination of charge and label would conflict with any existing transition groups
            if (_existingIds != null && _existingIds.Any(t =>
                {
                    var transitionGroup = t as TransitionGroup;
                    return transitionGroup != null && Equals(transitionGroup.LabelType, IsotopeLabelType) &&
                           Equals(transitionGroup.PrecursorCharge, Charge) && !ReferenceEquals(t, _initialId);
                }))
            {
                helper.ShowTextBoxError(textName,
                    Resources.EditCustomMoleculeDlg_OkDialog_A_precursor_with_that_charge_and_label_type_already_exists_, textName.Text);
                return;
            }

            // See if this would conflict with any existing transitions
            if (_existingIds != null && (_existingIds.Any(t =>
                {
                    var transition = t as Transition;
                    return transition != null && ((transition.Charge == Charge) && Equals(transition.CustomIon, ResultCustomIon)) && !ReferenceEquals(t, _initialId);
                })))
            {
                helper.ShowTextBoxError(textName,
                    Resources.EditCustomMoleculeDlg_OkDialog_A_similar_transition_already_exists_, textName.Text);
                return;
            }
            DialogResult = DialogResult.OK;
        }
        /// <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;
        }
示例#5
0
 public Digestion GetDigestion(ProteomeDb proteomeDb, PeptideSettings peptideSettings)
 {
     return proteomeDb.GetDigestion(peptideSettings.Enzyme.Name);
 }
示例#6
0
 public bool HasDigestion(PeptideSettings peptideSettings)
 {
     return DigestionNames.Contains(peptideSettings.Enzyme.Name);
 }
示例#7
0
        public PeptideSettingsUI(SkylineWindow parent, LibraryManager libraryManager)
        {
            InitializeComponent();

            btnUpdateIonMobilityLibraries.Visible = false; // TODO: ion mobility libraries are more complex than initially thought - put this off until after summer 2014 release

            _parent = parent;
            _libraryManager = libraryManager;
            _peptideSettings = parent.DocumentUI.Settings.PeptideSettings;

            // Initialize digestion settings
            _driverEnzyme = new SettingsListComboDriver<Enzyme>(comboEnzyme, Settings.Default.EnzymeList);
            _driverEnzyme.LoadList(_peptideSettings.Enzyme.GetKey());
            for (int i = DigestSettings.MIN_MISSED_CLEAVAGES; i <= DigestSettings.MAX_MISSED_CLEAVAGES; i++)
                comboMissedCleavages.Items.Add(i.ToString(CultureInfo.InvariantCulture));
            comboMissedCleavages.SelectedItem = Digest.MaxMissedCleavages.ToString(LocalizationHelper.CurrentCulture);
            if (comboMissedCleavages.SelectedIndex < 0)
                comboMissedCleavages.SelectedIndex = 0;
            cbRaggedEnds.Checked = Digest.ExcludeRaggedEnds;

            // Initialize prediction settings
            _driverRT = new SettingsListComboDriver<RetentionTimeRegression>(comboRetentionTime, Settings.Default.RetentionTimeList);
            string sel = (Prediction.RetentionTime == null ? null : Prediction.RetentionTime.Name);
            _driverRT.LoadList(sel);
            cbUseMeasuredRT.Checked = textMeasureRTWindow.Enabled = Prediction.UseMeasuredRTs;
            if (Prediction.MeasuredRTWindow.HasValue)
                textMeasureRTWindow.Text = Prediction.MeasuredRTWindow.Value.ToString(LocalizationHelper.CurrentCulture);

            _driverDT = new SettingsListComboDriver<DriftTimePredictor>(comboDriftTimePredictor, Settings.Default.DriftTimePredictorList);
            string selDT = (Prediction.DriftTimePredictor == null ? null : Prediction.DriftTimePredictor.Name);
            _driverDT.LoadList(selDT);
            cbUseSpectralLibraryDriftTimes.Checked = textSpectralLibraryDriftTimesResolvingPower.Enabled = Prediction.UseLibraryDriftTimes;
            if (Prediction.LibraryDriftTimesResolvingPower.HasValue)
                textSpectralLibraryDriftTimesResolvingPower.Text = Prediction.LibraryDriftTimesResolvingPower.Value.ToString(LocalizationHelper.CurrentCulture);

            // Initialize filter settings
            _driverExclusion = new SettingsListBoxDriver<PeptideExcludeRegex>(listboxExclusions, Settings.Default.PeptideExcludeList);
            _driverExclusion.LoadList(null, Filter.Exclusions);

            textExcludeAAs.Text = Filter.ExcludeNTermAAs.ToString(LocalizationHelper.CurrentCulture);
            textMaxLength.Text = Filter.MaxPeptideLength.ToString(LocalizationHelper.CurrentCulture);
            textMinLength.Text = Filter.MinPeptideLength.ToString(LocalizationHelper.CurrentCulture);
            cbAutoSelect.Checked = Filter.AutoSelect;

            // Initialize spectral library settings
            _driverLibrary = new SettingsListBoxDriver<LibrarySpec>(listLibraries, Settings.Default.SpectralLibraryList);
            IList<LibrarySpec> listLibrarySpecs = Libraries.LibrarySpecs;

            _driverLibrary.LoadList(null, listLibrarySpecs);
            _driverBackgroundProteome = new SettingsListComboDriver<BackgroundProteomeSpec>(comboBackgroundProteome, Settings.Default.BackgroundProteomeList);
            _driverBackgroundProteome.LoadList(_peptideSettings.BackgroundProteome.Name);

            panelPick.Visible = listLibrarySpecs.Count > 0;
            btnExplore.Enabled = listLibraries.Items.Count > 0;

            comboMatching.SelectedIndex = (int) Libraries.Pick;

            _lastRankId = Libraries.RankId;
            _lastPeptideCount = Libraries.PeptideCount.HasValue
                                    ? Libraries.PeptideCount.Value.ToString(LocalizationHelper.CurrentCulture)
                                    : null;

            UpdateRanks(null);

            // Initialize modification settings
            _driverStaticMod = new SettingsListBoxDriver<StaticMod>(listStaticMods, Settings.Default.StaticModList);
            _driverStaticMod.LoadList(null, Modifications.StaticModifications);
            _driverHeavyMod = new SettingsListBoxDriver<StaticMod>(listHeavyMods, Settings.Default.HeavyModList);
            _driverLabelType = new LabelTypeComboDriver(comboLabelType, Modifications, _driverHeavyMod,
                labelStandardType, comboStandardType, listStandardTypes);
            textMaxVariableMods.Text = Modifications.MaxVariableMods.ToString(LocalizationHelper.CurrentCulture);
            textMaxNeutralLosses.Text = Modifications.MaxNeutralLosses.ToString(LocalizationHelper.CurrentCulture);

            // Initialize peak scoring settings.
            _driverPeakScoringModel = new SettingsListComboDriver<PeakScoringModelSpec>(comboPeakScoringModel, Settings.Default.PeakScoringModelList);
            var peakScoringModel = _peptideSettings.Integration.PeakScoringModel;
            _driverPeakScoringModel.LoadList(peakScoringModel != null ? peakScoringModel.Name : null);

            IsShowLibraryExplorer = false;
            tabControl1.TabPages.Remove(tabIntegration);
            comboNormalizationMethod.Items.AddRange(
                NormalizationMethod.ListNormalizationMethods(parent.DocumentUI).ToArray());
            comboNormalizationMethod.SelectedItem = _peptideSettings.Quantification.NormalizationMethod;
            comboWeighting.Items.AddRange(RegressionWeighting.All.Cast<object>().ToArray());
            comboWeighting.SelectedItem = _peptideSettings.Quantification.RegressionWeighting;
            comboRegressionFit.Items.AddRange(RegressionFit.All.Cast<object>().ToArray());
            comboRegressionFit.SelectedItem = _peptideSettings.Quantification.RegressionFit;
            comboQuantMsLevel.SelectedIndex = Math.Max(0, _quantMsLevels.IndexOf(_peptideSettings.Quantification.MsLevel));
            tbxQuantUnits.Text = _peptideSettings.Quantification.Units;
        }
示例#8
0
        public void ShowViewLibraryDlg(string libName = null)
        {
            CheckDisposed();

            // Validate new settings without showing message boxes
            PeptideSettings settings = ValidateNewSettings(false);
            // Only update, if anything changed
            if (!Equals(settings, _peptideSettings))
            {
                var result = MultiButtonMsgDlg.Show(
                    this,
                    Resources.PeptideSettingsUI_ShowViewLibraryDlg_Peptide_settings_have_been_changed_Save_changes,
                    MultiButtonMsgDlg.BUTTON_YES,
                    MultiButtonMsgDlg.BUTTON_NO,
                    true);
                switch (result)
                {
                    case DialogResult.Yes:
                        // If settings are null, then validation failed the first time
                        if (settings == null)
                        {
                            // Show the error this time
                            ValidateNewSettings(true);
                            return;
                        }
                        SrmSettings newSettings = _parent.DocumentUI.Settings.ChangePeptideSettings(settings);
                        if (_parent.ChangeSettings(newSettings, true))
                        {
                            _peptideSettings = settings;
                        }
                        break;
                    case DialogResult.No:
                        break;
                    case DialogResult.Cancel:
                        return;
                }
            }
            IsShowLibraryExplorer = true;
            DialogResult = DialogResult.OK;
            var index = _parent.OwnedForms.IndexOf(form => form is ViewLibraryDlg);
            if (index == -1)
            {
                // Selected library name should be the ListBox selected item if possible, else the first checked item,
                // else the empty string.
                if (libName == null)
                {
                    libName = _driverLibrary.ListBox.SelectedItem != null
                                  ? _driverLibrary.ListBox.SelectedItem.ToString()
                                  : (_driverLibrary.CheckedNames.Any() ? _driverLibrary.CheckedNames[0] : string.Empty);
                }
                var viewLibraryDlg = new ViewLibraryDlg(_libraryManager, libName, _parent) { Owner = Owner };
                viewLibraryDlg.Show();
            }
        }
示例#9
0
        public void OkDialog()
        {
            PeptideSettings settings = ValidateNewSettings(true);
            if (settings == null)
                return;

            // Only update, if anything changed
            if (!Equals(settings, _peptideSettings))
            {
                if (!_parent.ChangeSettingsMonitored(this, Resources.PeptideSettingsUI_OkDialog_Changing_peptide_settings,
                                                     s => s.ChangePeptideSettings(settings)))
                {
                    return;
                }
                _peptideSettings = settings;
            }
            DialogResult = DialogResult.OK;
        }
示例#10
0
 public PeptideSettings MergeDefaults(PeptideSettings defPep)
 {
     PeptideSettings newPeptideSettings = ImClone(this);
     newPeptideSettings.Enzyme = newPeptideSettings.Enzyme ?? defPep.Enzyme;
     newPeptideSettings.DigestSettings = newPeptideSettings.DigestSettings ?? defPep.DigestSettings;
     newPeptideSettings.Prediction = newPeptideSettings.Prediction ?? defPep.Prediction;
     newPeptideSettings.Filter = newPeptideSettings.Filter ?? defPep.Filter;
     newPeptideSettings.Libraries = newPeptideSettings.Libraries ?? defPep.Libraries;
     newPeptideSettings.BackgroundProteome = newPeptideSettings.BackgroundProteome ?? defPep.BackgroundProteome;
     newPeptideSettings.Modifications = newPeptideSettings.Modifications ?? defPep.Modifications;
     newPeptideSettings.Integration = newPeptideSettings.Integration ?? defPep.Integration;
     return Equals(newPeptideSettings, this) ? this : newPeptideSettings;
 }
示例#11
0
 public bool Equals(PeptideSettings obj)
 {
     if (ReferenceEquals(null, obj)) return false;
     if (ReferenceEquals(this, obj)) return true;
     return Equals(obj.Enzyme, Enzyme) &&
            Equals(obj.DigestSettings, DigestSettings) &&
            Equals(obj.Prediction, Prediction) &&
            Equals(obj.Filter, Filter) &&
            Equals(obj.Libraries, Libraries) &&
            Equals(obj.Modifications, Modifications) &&
            Equals(obj.Integration, Integration) &&
            Equals(obj.BackgroundProteome, BackgroundProteome) &&
            Equals(obj.Quantification, Quantification);
 }