Esempio n. 1
0
        public void OkDialog()
        {
            var helper = new MessageBoxHelper(this);

            int standardCount;
            if (!helper.ValidateNumberTextBox(textPeptideCount, CalibrateIrtDlg.MIN_STANDARD_PEPTIDES, _peptideCount, out standardCount))
                return;

            DialogResult = DialogResult.OK;
        }
        public void OkDialog()
        {
            var helper = new MessageBoxHelper(this);

            int lineWidth;
            if (!helper.ValidateNumberTextBox(textLineWidth, 1, 5, out lineWidth))
                return;

            Settings.Default.SpectrumLineWidth = lineWidth;
            Settings.Default.SpectrumFontSize = GraphFontSize.GetFontSize(textSizeComboBox).PointSize;
            DialogResult = DialogResult.OK;
        }
Esempio n. 3
0
        /// <summary>
        /// This function will validate all the settings required for exporting a method,
        /// placing the values on the ExportDlgProperties _exportProperties. It returns
        /// boolean whether or not it succeeded. It can show MessageBoxes or not based
        /// on a parameter.
        /// </summary>
        public bool ValidateSettings(MessageBoxHelper helper)
        {
            // ReSharper disable ConvertIfStatementToConditionalTernaryExpression
            if (radioSingle.Checked)
                _exportProperties.ExportStrategy = ExportStrategy.Single;
            else if (radioProtein.Checked)
                _exportProperties.ExportStrategy = ExportStrategy.Protein;
            else
                _exportProperties.ExportStrategy = ExportStrategy.Buckets;
            // ReSharper restore ConvertIfStatementToConditionalTernaryExpression

            _exportProperties.IgnoreProteins = cbIgnoreProteins.Checked;
            _exportProperties.FullScans = _document.Settings.TransitionSettings.FullScan.IsEnabledMsMs;
            _exportProperties.AddEnergyRamp = panelThermoColumns.Visible && cbEnergyRamp.Checked;
            _exportProperties.UseSlens = cbSlens.Checked;
            _exportProperties.AddTriggerReference = panelThermoColumns.Visible && cbTriggerRefColumns.Checked;

            _exportProperties.ExportMultiQuant = panelAbSciexTOF.Visible && cbExportMultiQuant.Checked;

            _exportProperties.RetentionStartAndEnd = panelThermoRt.Visible && cbUseStartAndEndRts.Checked;

            _exportProperties.ExportEdcMass = panelWaters.Visible && cbExportEdcMass.Checked;

            _exportProperties.Ms1Scan = _document.Settings.TransitionSettings.FullScan.IsEnabledMs &&
                                        _document.Settings.TransitionSettings.FullScan.IsEnabledMsMs;

            _exportProperties.InclusionList = IsInclusionListMethod;

            _exportProperties.MsAnalyzer =
                TransitionFullScan.MassAnalyzerToString(
                    _document.Settings.TransitionSettings.FullScan.PrecursorMassAnalyzer);
            _exportProperties.MsMsAnalyzer =
                TransitionFullScan.MassAnalyzerToString(
                    _document.Settings.TransitionSettings.FullScan.ProductMassAnalyzer);

            _exportProperties.OptimizeType = comboOptimizing.SelectedItem == null ? ExportOptimize.NONE : comboOptimizing.SelectedItem.ToString();
            var prediction = _document.Settings.TransitionSettings.Prediction;
            if (Equals(_exportProperties.OptimizeType, ExportOptimize.CE))
            {
                var regression = prediction.CollisionEnergy;
                _exportProperties.OptimizeStepSize = regression.StepSize;
                _exportProperties.OptimizeStepCount = regression.StepCount;
            }
            else if (Equals(_exportProperties.OptimizeType, ExportOptimize.DP))
            {
                var regression = prediction.DeclusteringPotential;
                _exportProperties.OptimizeStepSize = regression.StepSize;
                _exportProperties.OptimizeStepCount = regression.StepCount;
            }
            else if (Equals(_exportProperties.OptimizeType, ExportOptimize.COV))
            {
                string tuning = comboTuning.SelectedItem.ToString();
                _exportProperties.OptimizeType = tuning;

                var compensationVoltage = prediction.CompensationVoltage;
                var tuneLevel = CompensationVoltageParameters.GetTuneLevel(tuning);

                if (helper.ShowMessages)
                {
                    if (tuneLevel.Equals(CompensationVoltageParameters.Tuning.medium))
                    {
                        var missing = _document.GetMissingCompensationVoltages(CompensationVoltageParameters.Tuning.rough).ToList();
                        if (missing.Any())
                        {
                            missing.Insert(0, Resources.ExportMethodDlg_ValidateSettings_Cannot_export_medium_tune_transition_list__The_following_precursors_are_missing_rough_tune_results_);
                            helper.ShowTextBoxError(comboTuning, TextUtil.LineSeparate(missing));
                            return false;
                        }
                    }
                    else if (tuneLevel.Equals(CompensationVoltageParameters.Tuning.fine))
                    {
                        var missing = _document.GetMissingCompensationVoltages(CompensationVoltageParameters.Tuning.medium).ToList();
                        if (missing.Any())
                        {
                            missing.Insert(0, Resources.ExportMethodDlg_ValidateSettings_Cannot_export_fine_tune_transition_list__The_following_precursors_are_missing_medium_tune_results_);
                            helper.ShowTextBoxError(comboTuning, TextUtil.LineSeparate(missing));
                            return false;
                        }
                    }
                }

                _exportProperties.OptimizeStepSize = compensationVoltage.GetStepSize(tuneLevel);
                _exportProperties.OptimizeStepCount = compensationVoltage.GetStepCount(tuneLevel);
                _exportProperties.PrimaryTransitionCount = 1;
            }
            else
            {
                _exportProperties.OptimizeType = null;
                _exportProperties.OptimizeStepSize = _exportProperties.OptimizeStepCount = _exportProperties.PrimaryTransitionCount = 0;
            }

            string maxTran = textMaxTransitions.Text;
            if (string.IsNullOrEmpty(maxTran))
            {
                if (_exportProperties.ExportStrategy == ExportStrategy.Buckets)
                {
                    helper.ShowTextBoxError(textMaxTransitions, Resources.ExportMethodDlg_ValidateSettings__0__must_contain_a_value);
                    return false;
                }
                _exportProperties.MaxTransitions = null;
            }

            int maxVal;
            // CONSIDER: Better error message when instrument limitation encountered?
            int maxInstrumentTrans = _document.Settings.TransitionSettings.Instrument.MaxTransitions ??
                                        TransitionInstrument.MAX_TRANSITION_MAX;
            int minTrans = IsFullScanInstrument
                               ? AbstractMassListExporter.MAX_TRANS_PER_INJ_MIN
                               : MethodExporter.MAX_TRANS_PER_INJ_MIN_TLTQ;

            if (_exportProperties.ExportStrategy != ExportStrategy.Buckets)
                maxVal = maxInstrumentTrans;
            else if (!helper.ValidateNumberTextBox(textMaxTransitions, minTrans, maxInstrumentTrans, out maxVal))
                return false;

            // Make sure all the transitions of all precursors can fit into a single document,
            // but not if this is a full-scan instrument, because then the maximum is refering
            // to precursors and not transitions.
            if (!IsFullScanInstrument && !ValidatePrecursorFit(_document, maxVal, helper.ShowMessages))
                return false;
            _exportProperties.MaxTransitions = maxVal;

            _exportProperties.MethodType = ExportMethodTypeExtension.GetEnum(comboTargetType.SelectedItem.ToString());

            if (textPrimaryCount.Visible)
            {
                int primaryCount;
                if (!helper.ValidateNumberTextBox(textPrimaryCount, AbstractMassListExporter.PRIMARY_COUNT_MIN, AbstractMassListExporter.PRIMARY_COUNT_MAX, out primaryCount))
                    return false;

                _exportProperties.PrimaryTransitionCount = primaryCount;
            }
            if (textDwellTime.Visible)
            {
                int dwellTime;
                if (!helper.ValidateNumberTextBox(textDwellTime, AbstractMassListExporter.DWELL_TIME_MIN, AbstractMassListExporter.DWELL_TIME_MAX, out dwellTime))
                    return false;

                _exportProperties.DwellTime = dwellTime;
            }
            if (textRunLength.Visible)
            {
                double runLength;
                if (!helper.ValidateDecimalTextBox(textRunLength, AbstractMassListExporter.RUN_LENGTH_MIN, AbstractMassListExporter.RUN_LENGTH_MAX, out runLength))
                    return false;

                _exportProperties.RunLength = runLength;
            }

            // If export method type is scheduled, and allows multiple scheduling options
            // ask the user which to use.
            if (_exportProperties.MethodType != ExportMethodType.Standard && HasMultipleSchedulingOptions(_document))
            {
                if (!helper.ShowMessages)
                {
                    // CONSIDER: Kind of a hack, but pick some reasonable defaults.  The user
                    //           may decide otherwise later, but this is the best we can do
                    //           without asking.
                    if (!_document.Settings.HasResults || Settings.Default.ScheduleAvergeRT)
                        SchedulingAlgorithm = ExportSchedulingAlgorithm.Average;
                    else
                    {
                        SchedulingAlgorithm = ExportSchedulingAlgorithm.Single;
                        SchedulingReplicateNum = _document.Settings.MeasuredResults.Chromatograms.Count - 1;
                    }
                }
                else
                {
                    using (var schedulingOptionsDlg = new SchedulingOptionsDlg(_document, i =>
                            _exportProperties.MethodType != ExportMethodType.Triggered || CanTriggerReplicate(i)))
                    {
                        if (schedulingOptionsDlg.ShowDialog(this) != DialogResult.OK)
                            return false;

                        SchedulingAlgorithm = schedulingOptionsDlg.Algorithm;
                        SchedulingReplicateNum = schedulingOptionsDlg.ReplicateNum;
                    }
                }
            }

            if (ExportOptimize.CompensationVoltageTuneTypes.Contains(_exportProperties.OptimizeType))
            {
                var precursorsMissingRanks = _document.GetPrecursorsWithoutTopRank(0, _exportProperties.SchedulingReplicateNum).ToArray();
                if (precursorsMissingRanks.Any())
                {
                    if (helper.ShowMessages)
                    {
                        if (DialogResult.Cancel == MultiButtonMsgDlg.Show(this, TextUtil.LineSeparate(
                            Resources.ExportMethodDlg_OkDialog_Compensation_voltage_optimization_should_be_run_on_one_transition_per_peptide__and_the_best_transition_cannot_be_determined_for_the_following_precursors_,
                            TextUtil.LineSeparate(precursorsMissingRanks),
                            Resources.ExportMethodDlg_OkDialog_Provide_transition_ranking_information_through_imported_results__a_spectral_library__or_choose_only_one_target_transition_per_precursor_),
                            Resources.ExportMethodDlg_OkDialog_OK))
                        {
                            return false;
                        }
                    }
                    _exportProperties.PrimaryTransitionCount = 0;
                }
            }

            return true;
        }
        public void OkDialog()
        {
            var helper = new MessageBoxHelper(this);

            int lineWidth;
            if (!helper.ValidateNumberTextBox(textLineWidth, 1, 5, out lineWidth))
                return;

            double timeRange = 0;
            if (!string.IsNullOrEmpty(textTimeRange.Text))
            {
                if (!helper.ValidateDecimalTextBox(textTimeRange, 0.05, 15.0, out timeRange))
                    return;
            }
            bool relative = cbRelative.Checked;

            double minIntensity = 0;
            if (!string.IsNullOrEmpty(textMinIntensity.Text))
            {
                if (!helper.ValidateDecimalTextBox(textMinIntensity, 0, double.MaxValue, out minIntensity))
                    return;
            }

            double maxIntensity = 0;
            if (!string.IsNullOrEmpty(textMaxIntensity.Text))
            {
                if (!helper.ValidateDecimalTextBox(textMaxIntensity, 5, double.MaxValue, out maxIntensity))
                    return;
            }

            Settings.Default.ChromatogramLineWidth = lineWidth;
            Settings.Default.ChromatogramFontSize = GraphFontSize.GetFontSize(textSizeComboBox).PointSize;
            Settings.Default.ChromatogramTimeRange = timeRange;
            Settings.Default.ChromatogramTimeRangeRelative = relative;
            Settings.Default.ChromatogramMinIntensity = minIntensity;
            Settings.Default.ChromatogramMaxIntensity = maxIntensity;
            if (maxIntensity != 0)
                Settings.Default.LockYChrom = true;
            Settings.Default.AllowLabelOverlap = cbShowOverlappingLabels.Checked;
            Settings.Default.AllowMultiplePeptideSelection = cbShowMultiplePeptides.Checked;
            DialogResult = DialogResult.OK;
        }
        public void OkDialog()
        {
            var helper = new MessageBoxHelper(this);

            // Validate start and end.
            double start;
            double end;
            if (!helper.ValidateDecimalTextBox(textStart, TransitionFullScan.MIN_RES_MZ, TransitionFullScan.MAX_RES_MZ, out start) ||
                !helper.ValidateDecimalTextBox(textEnd, TransitionFullScan.MIN_RES_MZ, TransitionFullScan.MAX_RES_MZ, out end))
            {
                return;
            }

            if (start >= end)
            {
                MessageDlg.Show(this, Resources.CalculateIsolationSchemeDlg_OkDialog_Start_value_must_be_less_than_End_value);
                return;
            }

            // Validate window width.
            double windowWidth;
            if (!helper.ValidateDecimalTextBox(textWidth, 0.1, TransitionFullScan.MAX_RES_MZ - TransitionFullScan.MIN_RES_MZ, out windowWidth))
            {
                return;
            }

            if (windowWidth > end - start)
            {
                MessageDlg.Show(this, Resources.CalculateIsolationSchemeDlg_OkDialog_Window_width_must_be_less_than_or_equal_to_the_isolation_range);
                return;
            }

            // Validate margins.
            double? margin = null;
            if (!helper.IsZeroOrEmpty(textMargin))
            {
                double marginValue;
                if (!helper.ValidateDecimalTextBox(textMargin, TransitionInstrument.MIN_MZ_MATCH_TOLERANCE,
                    TransitionFullScan.MAX_RES_MZ - TransitionFullScan.MIN_RES_MZ, out marginValue))
                {
                    return;
                }
                margin = marginValue;
            }

            // Validate CE range.
            double? ceRange = null;
            if (!helper.IsZeroOrEmpty(textCERange))
            {
                double ceRangeValue;
                if (!helper.ValidateDecimalTextBox(textCERange, 0.0, double.MaxValue, out ceRangeValue))
                {
                    return;
                }
                ceRange = ceRangeValue;
            }

            // Validate multiplexing.
            if (Multiplexed)
            {
                int windowsPerScan;
                if (!helper.ValidateNumberTextBox(textWindowsPerScan, 2, 20, out windowsPerScan))
                {
                    return;
                }

                // Make sure multiplexed window count is a multiple of windows per scan.
                if (Multiplexed && IsolationWindows.Count % windowsPerScan != 0)
                {
                    MessageDlg.Show(this, Resources.CalculateIsolationSchemeDlg_OkDialog_The_number_of_generated_windows_could_not_be_adjusted_to_be_a_multiple_of_the_windows_per_scan_Try_changing_the_windows_per_scan_or_the_End_value);
                    return;
                }
            }

            try
            {
            // ReSharper disable ObjectCreationAsStatement
                new IsolationWindow(start, end, null, margin, margin, ceRange);
            // ReSharper restore ObjectCreationAsStatement
            }
            catch (InvalidDataException x)
            {
                MessageDlg.ShowException(this, x);
                return;
            }

            DialogResult = DialogResult.OK;
        }
Esempio n. 6
0
 private int? ValidateCharge()
 {
     var helper = new MessageBoxHelper(this);
     int charge;
     const int min = Transition.MIN_PRODUCT_CHARGE;
     const int max = Transition.MAX_PRODUCT_CHARGE;
     if (!helper.ValidateNumberTextBox(textCharge, min, max, out charge))
     {
         return null;
     }
     _formulaBox.Charge = charge;
     return charge;
 }
Esempio n. 7
0
        public void OkDialog()
        {
            var helper = new MessageBoxHelper(this);

            string name;
            if (!helper.ValidateNameTextBox(textName, out name))
                return;

            if (_existing.Contains(m => !ReferenceEquals(_measuredIon, m) && Equals(name, m.Name)))
            {
                helper.ShowTextBoxError(textName, Resources.EditMeasuredIonDlg_OkDialog_The_special_ion__0__already_exists, name);
                return;
            }

            if (radioFragment.Checked)
            {
                string cleavage;
                if (!ValidateAATextBox(helper, textFragment, false, out cleavage))
                    return;
                string restrict;
                if (!ValidateAATextBox(helper, textRestrict, true, out restrict))
                    return;

                SequenceTerminus direction = (comboDirection.SelectedIndex == 0 ?
                    SequenceTerminus.C : SequenceTerminus.N);

                int minAas;
                if (!helper.ValidateNumberTextBox(textMinAas, MeasuredIon.MIN_MIN_FRAGMENT_LENGTH,
                        MeasuredIon.MAX_MIN_FRAGMENT_LENGTH, out minAas))
                    return;

                _measuredIon = new MeasuredIon(name, cleavage, restrict, direction, minAas);
            }
            else
            {
                var customIon = ValidateCustomIon(name);
                if (customIon == null)
                    return;
                _measuredIon = customIon;
            }

            DialogResult = DialogResult.OK;
        }
        public void OkDialog()
        {
            var helper = new MessageBoxHelper(this);
            int countGroups;
            if (!helper.ValidateNumberTextBox(textGroups, 1, _countGraphs, out countGroups))
                return;
            Groups = countGroups;

            if (radioSeparate.Checked)
                GroupType = GroupGraphsType.separated;
            else if (radioDistribute.Checked)
                GroupType = GroupGraphsType.distributed;

            DisplayType = DisplayGraphsTypeExtension.GetEnum(comboBoxDisplay.SelectedItem.ToString(),
                DisplayGraphsType.Tiled);
            GroupOrder = GroupGraphsOrderExtension.GetEnum(comboSortOrder.SelectedItem.ToString(), GroupGraphsOrder.Position);
            Reversed = cbReversed.Checked;
            // Only save the reverse flag, if the order is document.  Otherwise,
            // subsequent changes will flip the order back and forth.
            if (GroupOrder == GroupGraphsOrder.Document)
                Settings.Default.ArrangeGraphsReversed = Reversed;

            DialogResult = DialogResult.OK;
        }
Esempio n. 9
0
        public void OkDialog()
        {
            var helper = new MessageBoxHelper(this);

            string name;
            if (!helper.ValidateNameTextBox(textName, out name))
                return;

            if (_existing.Contains(r => !ReferenceEquals(_parameters, r) && Equals(name, r.Name)))
            {
                helper.ShowTextBoxError(textName, Resources.EditCoVDlg_btnOk_Click_The_compensation_voltage_parameters___0___already_exist_, name);
                return;
            }

            double covMin;
            if (!helper.ValidateDecimalTextBox(textMin, 0, null, out covMin))
                return;

            double covMax;
            if (!helper.ValidateDecimalTextBox(textMax, 0, null, out covMax))
                return;

            if (covMax < covMin)
            {
                helper.ShowTextBoxError(textMax, Resources.EditCoVDlg_btnOk_Click_Maximum_compensation_voltage_cannot_be_less_than_minimum_compensation_volatage_);
                return;
            }

            int stepCountRough;
            if (!helper.ValidateNumberTextBox(textStepsRough, CompensationVoltageParameters.MIN_STEP_COUNT, CompensationVoltageParameters.MAX_STEP_COUNT, out stepCountRough))
                return;

            int stepCountMedium;
            if (!helper.ValidateNumberTextBox(textStepsMedium, CompensationVoltageParameters.MIN_STEP_COUNT, CompensationVoltageParameters.MAX_STEP_COUNT, out stepCountMedium))
                return;

            int stepCountFine;
            if (!helper.ValidateNumberTextBox(textStepsFine, CompensationVoltageParameters.MIN_STEP_COUNT, CompensationVoltageParameters.MAX_STEP_COUNT, out stepCountFine))
                return;

            _parameters = new CompensationVoltageParameters(name, covMin, covMax, stepCountRough, stepCountMedium, stepCountFine);
            DialogResult = DialogResult.OK;
        }
Esempio n. 10
0
        private PeptideSettings ValidateNewSettings(bool showMessages)
        {
            var helper = new MessageBoxHelper(this, showMessages);

            // Validate and hold digestion settings
            Enzyme enzyme = Settings.Default.GetEnzymeByName(comboEnzyme.SelectedItem.ToString());
            Helpers.AssignIfEquals(ref enzyme, _peptideSettings.Enzyme);

            int maxMissedCleavages =
                int.Parse(comboMissedCleavages.SelectedItem.ToString());
            bool excludeRaggedEnds = cbRaggedEnds.Checked;
            DigestSettings digest = new DigestSettings(maxMissedCleavages, excludeRaggedEnds);
            Helpers.AssignIfEquals(ref digest, Digest);

            var backgroundProteomeSpec = _driverBackgroundProteome.SelectedItem;
            BackgroundProteome backgroundProteome = BackgroundProteome.NONE;
            if (!backgroundProteomeSpec.IsNone)
            {
                backgroundProteome = new BackgroundProteome(backgroundProteomeSpec, true);
                if (backgroundProteome.DatabaseInvalid)
                {

                    var message = TextUtil.LineSeparate(string.Format(Resources.PeptideSettingsUI_ValidateNewSettings_Failed_to_load_background_proteome__0__,
                                                                      backgroundProteomeSpec.Name),
                                                        string.Format(Resources.PeptideSettingsUI_ValidateNewSettings_The_file__0__may_not_be_a_valid_proteome_file,
                                                                      backgroundProteomeSpec.DatabasePath));
                    MessageDlg.Show(this, message);
                    tabControl1.SelectedIndex = 0;
                    _driverBackgroundProteome.Combo.Focus();
                    return null;
                }
            }
            Helpers.AssignIfEquals(ref backgroundProteome, _peptideSettings.BackgroundProteome);

            // Validate and hold prediction settings
            string nameRT = comboRetentionTime.SelectedItem.ToString();
            RetentionTimeRegression retentionTime =
                Settings.Default.GetRetentionTimeByName(nameRT);
            if (retentionTime != null && retentionTime.Calculator != null)
            {
                RetentionScoreCalculatorSpec retentionCalc =
                    Settings.Default.GetCalculatorByName(retentionTime.Calculator.Name);
                // Just in case the calculator in use in the current documet got removed,
                // never set the calculator to null.  Just keep using the one we have.
                if (retentionCalc != null && !ReferenceEquals(retentionCalc, retentionTime.Calculator))
                    retentionTime = retentionTime.ChangeCalculator(retentionCalc);
            }
            bool useMeasuredRT = cbUseMeasuredRT.Checked;
            double? measuredRTWindow = null;
            if (!string.IsNullOrEmpty(textMeasureRTWindow.Text))
            {
                double measuredRTWindowOut;
                const double minWindow = PeptidePrediction.MIN_MEASURED_RT_WINDOW;
                const double maxWindow = PeptidePrediction.MAX_MEASURED_RT_WINDOW;
                if (!helper.ValidateDecimalTextBox(tabControl1, (int) TABS.Prediction,
                        textMeasureRTWindow, minWindow, maxWindow, out measuredRTWindowOut))
                    return null;
                measuredRTWindow = measuredRTWindowOut;
            }

            string nameDt = comboDriftTimePredictor.SelectedItem.ToString();
            DriftTimePredictor driftTimePredictor =
                Settings.Default.GetDriftTimePredictorByName(nameDt);
            if (driftTimePredictor != null && driftTimePredictor.IonMobilityLibrary != null)
            {
                IonMobilityLibrarySpec ionMobilityLibrary =
                    Settings.Default.GetIonMobilityLibraryByName(driftTimePredictor.IonMobilityLibrary.Name);
                // Just in case the library in use in the current documet got removed,
                // never set the library to null.  Just keep using the one we have.
                if (ionMobilityLibrary != null && !ReferenceEquals(ionMobilityLibrary, driftTimePredictor.IonMobilityLibrary))
                    driftTimePredictor = driftTimePredictor.ChangeLibrary(ionMobilityLibrary);
            }
            bool useLibraryDriftTime = cbUseSpectralLibraryDriftTimes.Checked;
            double? libraryDTResolvingPower = null;
            if (useLibraryDriftTime || !string.IsNullOrEmpty(textSpectralLibraryDriftTimesResolvingPower.Text))
            {
                double libraryDTWindowOut;
                if (!helper.ValidateDecimalTextBox(tabControl1, (int)TABS.Prediction,
                        textSpectralLibraryDriftTimesResolvingPower, null, null, out libraryDTWindowOut))
                    return null;
                string errmsg = EditDriftTimePredictorDlg.ValidateResolvingPower(libraryDTWindowOut);
                if (errmsg != null)
                {
                    helper.ShowTextBoxError(tabControl1, (int)TABS.Prediction, textSpectralLibraryDriftTimesResolvingPower, errmsg);
                    return null;
                }
                libraryDTResolvingPower = libraryDTWindowOut;
            }

            var prediction = new PeptidePrediction(retentionTime, driftTimePredictor, useMeasuredRT, measuredRTWindow, useLibraryDriftTime, libraryDTResolvingPower);
            Helpers.AssignIfEquals(ref prediction, Prediction);

            // Validate and hold filter settings
            int excludeNTermAAs;
            if (!helper.ValidateNumberTextBox(tabControl1, (int) TABS.Filter, textExcludeAAs,
                    PeptideFilter.MIN_EXCLUDE_NTERM_AA, PeptideFilter.MAX_EXCLUDE_NTERM_AA, out excludeNTermAAs))
                return null;
            int minPeptideLength;
            if (!helper.ValidateNumberTextBox(tabControl1, (int) TABS.Filter, textMinLength,
                    PeptideFilter.MIN_MIN_LENGTH, PeptideFilter.MAX_MIN_LENGTH, out minPeptideLength))
                return null;
            int maxPeptideLength;
            if (!helper.ValidateNumberTextBox(tabControl1, (int)TABS.Filter, textMaxLength,
                    Math.Max(PeptideFilter.MIN_MAX_LENGTH, minPeptideLength), PeptideFilter.MAX_MAX_LENGTH, out maxPeptideLength))
                return null;

            PeptideExcludeRegex[] exclusions = _driverExclusion.Chosen;

            bool autoSelect = cbAutoSelect.Checked;
            PeptideFilter filter;
            try
            {
                filter = new PeptideFilter(excludeNTermAAs,
                                           minPeptideLength,
                                           maxPeptideLength,
                                           exclusions,
                                           autoSelect);
            }
            catch (InvalidDataException x)
            {
                if (showMessages)
                    MessageDlg.ShowException(this, x);
                return null;
            }

            Helpers.AssignIfEquals(ref filter, Filter);

            // Validate and hold libraries
            PeptideLibraries libraries;
            IList<LibrarySpec> librarySpecs = _driverLibrary.Chosen;
            if (librarySpecs.Count == 0)
                libraries = new PeptideLibraries(PeptidePick.library, null, null, false, librarySpecs, new Library[0]);
            else
            {
                int? peptideCount = null;
                if (cbLimitPeptides.Checked)
                {
                    int peptideCountVal;
                    if (!helper.ValidateNumberTextBox(textPeptideCount, PeptideLibraries.MIN_PEPTIDE_COUNT,
                            PeptideLibraries.MAX_PEPTIDE_COUNT, out peptideCountVal))
                        return null;
                    peptideCount = peptideCountVal;
                }
                PeptidePick pick = (PeptidePick) comboMatching.SelectedIndex;

                IList<Library> librariesLoaded = new Library[librarySpecs.Count];
                bool documentLibrary = false;
                if (Libraries != null)
                {
                    // Use existing library spec's, if nothing was changed.
                    // Avoid changing the libraries, just because the the picking
                    // algorithm changed.
                    if (ArrayUtil.EqualsDeep(librarySpecs, Libraries.LibrarySpecs))
                    {
                        librarySpecs = Libraries.LibrarySpecs;
                        librariesLoaded = Libraries.Libraries;
                    }

                    documentLibrary = Libraries.HasDocumentLibrary;
                    // Otherwise, leave the list of loaded libraries empty,
                    // and let the LibraryManager refill it.  This ensures a
                    // clean save of library specs only in the user config, rather
                    // than a mix of library specs and libraries.
                }

                PeptideRankId rankId = (PeptideRankId) comboRank.SelectedItem;
                if (comboRank.SelectedIndex == 0)
                    rankId = null;

                libraries = new PeptideLibraries(pick, rankId, peptideCount, documentLibrary, librarySpecs, librariesLoaded);
            }
            Helpers.AssignIfEquals(ref libraries, Libraries);

            // Validate and hold modifications
            int maxVariableMods;
            if (!helper.ValidateNumberTextBox(tabControl1, (int)TABS.Modifications, textMaxVariableMods,
                    PeptideModifications.MIN_MAX_VARIABLE_MODS, PeptideModifications.MAX_MAX_VARIABLE_MODS, out maxVariableMods))
                return null;
            int maxNeutralLosses;
            if (!helper.ValidateNumberTextBox(tabControl1, (int)TABS.Modifications, textMaxNeutralLosses,
                    PeptideModifications.MIN_MAX_NEUTRAL_LOSSES, PeptideModifications.MAX_MAX_NEUTRAL_LOSSES, out maxNeutralLosses))
                return null;

            var standardTypes = _driverLabelType.InternalStandardTypes;
            PeptideModifications modifications = new PeptideModifications(
                _driverStaticMod.Chosen, maxVariableMods, maxNeutralLosses,
                _driverLabelType.GetHeavyModifications(), standardTypes);
            // Should not be possible to change explicit modifications in the background,
            // so this should be safe.  CONSIDER: Document structure because of a library load?
            modifications = modifications.DeclareExplicitMods(_parent.DocumentUI,
                Settings.Default.StaticModList, Settings.Default.HeavyModList);
            Helpers.AssignIfEquals(ref modifications, _peptideSettings.Modifications);

            PeptideIntegration integration = new PeptideIntegration(_driverPeakScoringModel.SelectedItem);
            Helpers.AssignIfEquals(ref integration, Integration);

            QuantificationSettings quantification = QuantificationSettings.DEFAULT
                .ChangeNormalizationMethod(comboNormalizationMethod.SelectedItem as NormalizationMethod ?? NormalizationMethod.NONE)
                .ChangeRegressionWeighting(comboWeighting.SelectedItem as RegressionWeighting)
                .ChangeRegressionFit(comboRegressionFit.SelectedItem as RegressionFit)
                .ChangeMsLevel(_quantMsLevels[comboQuantMsLevel.SelectedIndex])
                .ChangeUnits(tbxQuantUnits.Text);

            return new PeptideSettings(enzyme, digest, prediction, filter, libraries, modifications, integration, backgroundProteome)
                    .ChangeAbsoluteQuantification(quantification);
        }
Esempio n. 11
0
        public void OkDialog()
        {
            var helper = new MessageBoxHelper(this);

            // Validate and store prediction settings
            string massType = comboPrecursorMass.SelectedItem.ToString();
            MassType precursorMassType = MassTypeExtension.GetEnum(massType);
            massType = comboIonMass.SelectedItem.ToString();
            MassType fragmentMassType = MassTypeExtension.GetEnum(massType);
            string nameCE = comboCollisionEnergy.SelectedItem.ToString();
            CollisionEnergyRegression collisionEnergy =
                Settings.Default.GetCollisionEnergyByName(nameCE);
            string nameDP = comboDeclusterPotential.SelectedItem.ToString();
            DeclusteringPotentialRegression declusteringPotential =
                Settings.Default.GetDeclusterPotentialByName(nameDP);
            string nameCoV = comboCompensationVoltage.SelectedItem.ToString();
            CompensationVoltageParameters compensationVoltage =
                Settings.Default.GetCompensationVoltageByName(nameCoV);
            string nameOptLib = comboOptimizationLibrary.SelectedItem.ToString();
            OptimizationLibrary optimizationLibrary =
                Settings.Default.GetOptimizationLibraryByName(nameOptLib);
            OptimizedMethodType optimizedMethodType = OptimizedMethodType.None;
            if (cbUseOptimized.Checked)
            {
                optimizedMethodType = OptimizedMethodTypeExtension.GetEnum(comboOptimizeType.SelectedItem.ToString());
            }
            TransitionPrediction prediction = new TransitionPrediction(precursorMassType,
                                                                       fragmentMassType, collisionEnergy,
                                                                       declusteringPotential,
                                                                       compensationVoltage,
                                                                       optimizationLibrary,
                                                                       optimizedMethodType);
            Helpers.AssignIfEquals(ref prediction, Prediction);

            // Validate and store filter settings
            int[] precursorCharges;
            int min = TransitionGroup.MIN_PRECURSOR_CHARGE;
            int max = TransitionGroup.MAX_PRECURSOR_CHARGE;
            if (!helper.ValidateNumberListTextBox(tabControl1, (int) TABS.Filter, textPrecursorCharges,
                    min, max, out precursorCharges))
                return;
            precursorCharges = precursorCharges.Distinct().ToArray();

            int[] productCharges;
            min = Transition.MIN_PRODUCT_CHARGE;
            max = Transition.MAX_PRODUCT_CHARGE;
            if (!helper.ValidateNumberListTextBox(tabControl1, (int) TABS.Filter, textIonCharges,
                    min, max, out productCharges))
                return;
            productCharges = productCharges.Distinct().ToArray();

            IonType[] types = TransitionFilter.ParseTypes(textIonTypes.Text, new IonType[0]);
            if (types.Length == 0)
            {
                helper.ShowTextBoxError(tabControl1, (int) TABS.Filter, textIonTypes,
                                        Resources.TransitionSettingsUI_OkDialog_Ion_types_must_contain_a_comma_separated_list_of_ion_types_a_b_c_x_y_z_and_p_for_precursor);
                return;
            }
            types = types.Distinct().ToArray();

            double exclusionWindow = 0;
            if (!string.IsNullOrEmpty(textExclusionWindow.Text) &&
                !Equals(textExclusionWindow.Text, exclusionWindow.ToString(LocalizationHelper.CurrentCulture)))
            {
                if (!helper.ValidateDecimalTextBox(tabControl1, (int)TABS.Filter, textExclusionWindow,
                        TransitionFilter.MIN_EXCLUSION_WINDOW, TransitionFilter.MAX_EXCLUSION_WINDOW, out exclusionWindow))
                {
                    return;
                }
            }

            string fragmentRangeFirst = TransitionFilter.GetStartFragmentNameFromLabel(comboRangeFrom.SelectedItem.ToString());
            string fragmentRangeLast = TransitionFilter.GetEndFragmentNameFromLabel(comboRangeTo.SelectedItem.ToString());

            var measuredIons = _driverIons.Chosen;
            bool autoSelect = cbAutoSelect.Checked;
            bool exclusionUseDIAWindow = FullScanSettingsControl.IsDIA() && cbExclusionUseDIAWindow.Checked;
            var filter = new TransitionFilter(precursorCharges, productCharges, types,
                                              fragmentRangeFirst, fragmentRangeLast, measuredIons,
                                              exclusionWindow, exclusionUseDIAWindow, autoSelect);
            Helpers.AssignIfEquals(ref filter, Filter);

            // Validate and store library settings
            TransitionLibraryPick pick = TransitionLibraryPick.none;
            if (cbLibraryPick.Checked)
            {
                if (radioAll.Checked)
                    pick = TransitionLibraryPick.all;
                else if (radioAllAndFiltered.Checked)
                    pick = TransitionLibraryPick.all_plus;
                else
                    pick = TransitionLibraryPick.filter;
            }

            double ionMatchTolerance;

            double minTol = TransitionLibraries.MIN_MATCH_TOLERANCE;
            double maxTol = TransitionLibraries.MAX_MATCH_TOLERANCE;
            if (!helper.ValidateDecimalTextBox(tabControl1, (int) TABS.Library, textTolerance,
                    minTol, maxTol, out ionMatchTolerance))
                return;

            int ionCount = Libraries.IonCount;

            if (pick != TransitionLibraryPick.none)
            {
                min = TransitionLibraries.MIN_ION_COUNT;
                max = TransitionLibraries.MAX_ION_COUNT;
                if (!helper.ValidateNumberTextBox(tabControl1, (int) TABS.Library, textIonCount,
                        min, max, out ionCount))
                    return;
            }

            TransitionLibraries libraries = new TransitionLibraries(ionMatchTolerance, ionCount, pick);
            Helpers.AssignIfEquals(ref libraries, Libraries);

            // This dialog does not yet change integration settings
            TransitionIntegration integration = _transitionSettings.Integration;

            // Validate and store instrument settings
            int minMz;
            min = TransitionInstrument.MIN_MEASUREABLE_MZ;
            max = TransitionInstrument.MAX_MEASURABLE_MZ - TransitionInstrument.MIN_MZ_RANGE;
            if (!helper.ValidateNumberTextBox(tabControl1, (int) TABS.Instrument, textMinMz, min, max, out minMz))
                return;
            int maxMz;
            min = minMz + TransitionInstrument.MIN_MZ_RANGE;
            max = TransitionInstrument.MAX_MEASURABLE_MZ;
            if (!helper.ValidateNumberTextBox(tabControl1, (int) TABS.Instrument, textMaxMz, min, max, out maxMz))
                return;
            bool isDynamicMin = cbDynamicMinimum.Checked;
            double mzMatchTolerance;
            minTol = TransitionInstrument.MIN_MZ_MATCH_TOLERANCE;
            maxTol = TransitionInstrument.MAX_MZ_MATCH_TOLERANCE;
            if (!helper.ValidateDecimalTextBox(tabControl1, (int) TABS.Instrument, textMzMatchTolerance,
                    minTol, maxTol, out mzMatchTolerance))
                return;
            int? maxTrans = null;
            if (!string.IsNullOrEmpty(textMaxTrans.Text))
            {
                int maxTransTemp;
                min = TransitionInstrument.MIN_TRANSITION_MAX;
                max = TransitionInstrument.MAX_TRANSITION_MAX;
                if (!helper.ValidateNumberTextBox(tabControl1, (int) TABS.Instrument, textMaxTrans,
                        min, max, out maxTransTemp))
                    return;
                maxTrans = maxTransTemp;
            }
            int? maxInclusions = null;
            if (!string.IsNullOrEmpty(textMaxInclusions.Text))
            {
                int maxInclusionsTemp;
                min = TransitionInstrument.MIN_INCLUSION_MAX;
                max = TransitionInstrument.MAX_INCLUSION_MAX;
                if (!helper.ValidateNumberTextBox(tabControl1, (int) TABS.Instrument, textMaxInclusions,
                        min, max, out maxInclusionsTemp))
                    return;
                maxInclusions = maxInclusionsTemp;
            }
            int? minTime = null, maxTime = null;
            min = TransitionInstrument.MIN_TIME;
            max = TransitionInstrument.MAX_TIME;
            if (!string.IsNullOrEmpty(textMinTime.Text))
            {
                int minTimeTemp;
                if (!helper.ValidateNumberTextBox(tabControl1, (int)TABS.Instrument, textMinTime,
                        min, max, out minTimeTemp))
                    return;
                minTime = minTimeTemp;
            }
            if (!string.IsNullOrEmpty(textMaxTime.Text))
            {
                int maxTimeTemp;
                if (!helper.ValidateNumberTextBox(tabControl1, (int)TABS.Instrument, textMaxTime,
                        min, max, out maxTimeTemp))
                    return;
                maxTime = maxTimeTemp;
            }
            if (minTime.HasValue && maxTime.HasValue && maxTime.Value - minTime.Value < TransitionInstrument.MIN_TIME_RANGE)
            {
                helper.ShowTextBoxError(tabControl1, (int) TABS.Instrument, textMaxTime,
                                        string.Format(Resources.TransitionSettingsUI_OkDialog_The_allowable_retention_time_range__0__to__1__must_be_at_least__2__minutes_apart,
                                                      minTime, maxTime, TransitionInstrument.MIN_TIME_RANGE));
                return;
            }

            TransitionInstrument instrument = new TransitionInstrument(minMz,
                maxMz, isDynamicMin, mzMatchTolerance, maxTrans, maxInclusions, minTime, maxTime);
            Helpers.AssignIfEquals(ref instrument, Instrument);

            // Validate and store full-scan settings

            // If high resolution MS1 filtering is enabled, make sure precursor m/z type
            // is monoisotopic and isotope enrichments are set
            FullScanPrecursorIsotopes precursorIsotopes = PrecursorIsotopesCurrent;
            FullScanMassAnalyzerType precursorAnalyzerType = PrecursorMassAnalyzer;
            if (precursorIsotopes != FullScanPrecursorIsotopes.None &&
                    precursorAnalyzerType != FullScanMassAnalyzerType.qit)
            {
                if (precursorMassType != MassType.Monoisotopic)
                {
                    MessageDlg.Show(this, Resources.TransitionSettingsUI_OkDialog_High_resolution_MS1_filtering_requires_use_of_monoisotopic_precursor_masses);
                    tabControl1.SelectedIndex = (int)TABS.Prediction;
                    comboPrecursorMass.Focus();
                    return;
                }

                if (FullScanSettingsControl.Enrichments == null)
                {
                    tabControl1.SelectedIndex = (int) TABS.FullScan;
                    MessageDlg.Show(GetParentForm(this), Resources.TransitionSettingsUI_OkDialog_Isotope_enrichment_settings_are_required_for_MS1_filtering_on_high_resolution_mass_spectrometers);
                    FullScanSettingsControl.ComboEnrichmentsSetFocus();
                    return;
                }
            }

            IsolationScheme isolationScheme = FullScanSettingsControl.IsolationScheme;
            FullScanAcquisitionMethod acquisitionMethod = AcquisitionMethod;
            if (isolationScheme == null && acquisitionMethod == FullScanAcquisitionMethod.DIA)
            {
                tabControl1.SelectedIndex = (int)TABS.FullScan;
                MessageDlg.Show(this, Resources.TransitionSettingsUI_OkDialog_An_isolation_scheme_is_required_to_match_multiple_precursors);
                FullScanSettingsControl.ComboIsolationSchemeSetFocus();
                return;
            }

            if (isolationScheme != null && isolationScheme.WindowsPerScan.HasValue && !maxInclusions.HasValue)
            {
                MessageDlg.Show(this, Resources.TransitionSettingsUI_OkDialog_Before_performing_a_multiplexed_DIA_scan_the_instrument_s_firmware_inclusion_limit_must_be_specified);
                tabControl1.SelectedIndex = (int)TABS.Instrument;
                textMaxInclusions.Focus();
                return;
            }

            if (FullScanSettingsControl.IsDIA() && cbExclusionUseDIAWindow.Checked)
            {
                if (FullScanSettingsControl.IsolationScheme.IsAllIons)
                {
                    MessageDlg.Show(this, Resources.TransitionSettingsUI_OkDialog_Cannot_use_DIA_window_for_precusor_exclusion_when__All_Ions__is_selected_as_the_isolation_scheme___To_use_the_DIA_window_for_precusor_exclusion__change_the_isolation_scheme_in_the_Full_Scan_settings_);
                    tabControl1.SelectedIndex = (int)TABS.Filter;
                    cbExclusionUseDIAWindow.Focus();
                    return;
                }
                if (FullScanSettingsControl.IsolationScheme.FromResults)
                {
                    MessageDlg.Show(this, Resources.TransitionSettingsUI_OkDialog_Cannot_use_DIA_window_for_precursor_exclusion_when_isolation_scheme_does_not_contain_prespecified_windows___Please_select_an_isolation_scheme_with_prespecified_windows_);
                    tabControl1.SelectedIndex = (int)TABS.Filter;
                    cbExclusionUseDIAWindow.Focus();
                    return;
                }
            }

            TransitionFullScan fullScan;
            if (!FullScanSettingsControl.ValidateFullScanSettings(helper, out fullScan, tabControl1, (int)TABS.FullScan))
                return;

            Helpers.AssignIfEquals(ref fullScan, FullScan);

            TransitionSettings settings = new TransitionSettings(prediction,
                filter, libraries, integration, instrument, fullScan);

            // Only update, if anything changed
            if (!Equals(settings, _transitionSettings))
            {
                if (!_parent.ChangeSettingsMonitored(this, Resources.TransitionSettingsUI_OkDialog_Changing_transition_settings,
                                                     s => s.ChangeTransitionSettings(settings)))
                {
                    return;
                }
                _transitionSettings = settings;
            }

            DialogResult = DialogResult.OK;
        }
Esempio n. 12
0
        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;

            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,
                                         RemoveDuplicatePeptides = removeDuplicatePeptides,
                                         RemoveRepeatedPeptides = removeRepeatedPeptides,
                                         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 TransitionSettings GetTransitionSettings(Form parent)
        {
            var helper = new MessageBoxHelper(parent);
            TransitionSettings settings = SkylineWindow.DocumentUI.Settings.TransitionSettings;

            // Validate and store filter settings
            int[] precursorCharges;
            if (!helper.ValidateNumberListTextBox(txtPrecursorCharges, TransitionGroup.MIN_PRECURSOR_CHARGE, TransitionGroup.MAX_PRECURSOR_CHARGE, out precursorCharges))
                return null;
            precursorCharges = precursorCharges.Distinct().ToArray();

            int[] productCharges;
            if (!helper.ValidateNumberListTextBox(txtIonCharges, Transition.MIN_PRODUCT_CHARGE, Transition.MAX_PRODUCT_CHARGE, out productCharges))
                return null;
            productCharges = productCharges.Distinct().ToArray();

            IonType[] types = IonTypes;
            if (types.Length == 0)
            {
                helper.ShowTextBoxError(txtIonTypes, Resources.TransitionSettingsUI_OkDialog_Ion_types_must_contain_a_comma_separated_list_of_ion_types_a_b_c_x_y_z_and_p_for_precursor);
                return null;
            }
            types = types.Distinct().ToArray();

            bool exclusionUseDIAWindow = cbExclusionUseDIAWindow.Visible && cbExclusionUseDIAWindow.Checked;
            var filter = new TransitionFilter(precursorCharges, productCharges, types, settings.Filter.FragmentRangeFirstName, settings.Filter.FragmentRangeLastName,
                                              settings.Filter.MeasuredIons, settings.Filter.PrecursorMzWindow, exclusionUseDIAWindow, settings.Filter.AutoSelect);
            Helpers.AssignIfEquals(ref filter, settings.Filter);

            // Validate and store library settings
            double ionMatchTolerance;
            if (!helper.ValidateDecimalTextBox(txtTolerance, TransitionLibraries.MIN_MATCH_TOLERANCE, TransitionLibraries.MAX_MATCH_TOLERANCE, out ionMatchTolerance))
                return null;

            int ionCount = settings.Libraries.IonCount;
            if (!helper.ValidateNumberTextBox(txtIonCount, TransitionLibraries.MIN_ION_COUNT, TransitionLibraries.MAX_ION_COUNT, out ionCount))
                return null;

            TransitionLibraryPick pick = (settings.Libraries.Pick != TransitionLibraryPick.none) ? settings.Libraries.Pick : TransitionLibraryPick.all;
            var libraries = new TransitionLibraries(ionMatchTolerance, ionCount, pick);
            Helpers.AssignIfEquals(ref libraries, settings.Libraries);

            return new TransitionSettings(settings.Prediction, filter, libraries, settings.Integration, settings.Instrument, settings.FullScan);
        }
        public void OkDialog()
        {
            var helper = new MessageBoxHelper(this);
            double[] timeWindows;
            if (!helper.ValidateDecimalListTextBox(textTimeWindows,
                                                   PeptidePrediction.MIN_MEASURED_RT_WINDOW,
                                                   PeptidePrediction.MAX_MEASURED_RT_WINDOW,
                                                   out timeWindows))
                return;

            int primaryTransitionCount = 0;
            if (!string.IsNullOrEmpty(textPrimaryTransitionCount.Text))
            {
                if (!helper.ValidateNumberTextBox(textPrimaryTransitionCount,
                                                  AbstractMassListExporter.PRIMARY_COUNT_MIN,
                                                  AbstractMassListExporter.PRIMARY_COUNT_MAX,
                                                  out primaryTransitionCount))
                    return;
            }

            Array.Sort(timeWindows);

            RTScheduleGraphPane.ScheduleWindows = timeWindows;
            RTScheduleGraphPane.PrimaryTransitionCount = primaryTransitionCount;

            DialogResult = DialogResult.OK;
        }