Пример #1
0
        public void OkDialog()
        {
            var helper = new MessageBoxHelper(this);

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

            bool decimalCv = cbDecimalCvs.Checked;

            double maxCv = 0;
            if (!string.IsNullOrEmpty(textMaxCv.Text))
            {
                double maxAllowed = 500;
                if (decimalCv)
                    maxAllowed /= 100;
                if (!helper.ValidateDecimalTextBox(textMaxCv, 0, maxAllowed, out maxCv))
                    return;
            }

            Settings.Default.PeakAreaMaxArea = maxArea;
            Settings.Default.PeakAreaMaxCv = maxCv;
            Settings.Default.PeakDecimalCv = decimalCv;
            Settings.Default.AreaFontSize = GraphFontSize.GetFontSize(textSizeComboBox).PointSize;

            DialogResult = DialogResult.OK;
        }
        public void OkDialog()
        {
            var helper = new MessageBoxHelper(this);
            if (!helper.ValidateDecimalTextBox(textThreshold, 0, double.MaxValue, out _threshold))
                return;

            DialogResult = DialogResult.OK;
            Close();
        }
        public void OkDialog()
        {
            var helper = new MessageBoxHelper(this);
            if (!helper.ValidateDecimalTextBox(textThreshold, 0, 1.0, out _threshold))
                return;

            // Round to precision used in calculating optimal regressions
            _threshold = Math.Round(_threshold, RetentionTimeRegression.ThresholdPrecision);

            DialogResult = DialogResult.OK;
            Close();
        }
        public void OkDialog()
        {
            var helper = new MessageBoxHelper(this);
            double lockmassPositive;
            if (string.IsNullOrEmpty(textLockmassPositive.Text))
                lockmassPositive = 0;
            else if (!helper.ValidateDecimalTextBox(textLockmassPositive, 0, null, out lockmassPositive))
                return;
            double lockmassNegative;
            if (string.IsNullOrEmpty(textLockmassNegative.Text))
                lockmassNegative = 0;
            else if (!helper.ValidateDecimalTextBox(textLockmassNegative, 0, null, out lockmassNegative))
                return;
            double lockmassTolerance;
            if (string.IsNullOrEmpty(textLockmassTolerance.Text))
                lockmassTolerance = 0;
            else if (!helper.ValidateDecimalTextBox(textLockmassTolerance, LockMassParameters.LOCKMASS_TOLERANCE_MIN, LockMassParameters.LOCKMASS_TOLERANCE_MAX, out lockmassTolerance))
                return;

            Settings.Default.LockmassParameters = LockMassParameters = new LockMassParameters(lockmassPositive, lockmassNegative, lockmassTolerance);
            DialogResult = DialogResult.OK;
        }
        public void OkDialog()
        {
            var helper = new MessageBoxHelper(this);
            double window;
            if (!helper.ValidateDecimalTextBox(txtWindow, out window))
                return;

            if (Settings.Default.RetentionTimeList.Any(regression => regression.Name == txtName.Text))
            {
                MessageDlg.Show(this, Resources.AddRetentionTimePredictorDlg_OkDialog_A_retention_time_predictor_with_that_name_already_exists__Please_choose_a_new_name_);
                txtName.Focus();
                return;
            }

            Regression = new RetentionTimeRegression(
                txtName.Text, Calculator, null, null, window, new List<MeasuredRetentionTime>());

            DialogResult = DialogResult.OK;
        }
Пример #6
0
        public void OkDialog()
        {
            double minIrt;
            double maxIrt;

            var helper = new MessageBoxHelper(this);
            if (!helper.ValidateDecimalTextBox(textMinIrt, null, null, out minIrt))
                return;
            if (!helper.ValidateDecimalTextBox(textMaxIrt, minIrt, null, out maxIrt))
                return;

            var peptide1 = (DbIrtPeptide) comboFixedPoint1.SelectedItem;
            var peptide2 = (DbIrtPeptide) comboFixedPoint2.SelectedItem;

            double minCurrent = Math.Min(peptide1.Irt, peptide2.Irt);
            double maxCurrent = Math.Max(peptide1.Irt, peptide2.Irt);

            var statX = new Statistics(minCurrent, maxCurrent);
            var statY = new Statistics(minIrt, maxIrt);

            LinearEquation = new RegressionLine(statY.Slope(statX), statY.Intercept(statX));

            // Convert all of the peptides to the new scale.
            foreach (var peptide in _irtPeptides)
            {
                peptide.Irt = LinearEquation.GetY(peptide.Irt);
            }

            DialogResult = DialogResult.OK;
        }
Пример #7
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;
        }
Пример #8
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 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;
        }
Пример #10
0
 public bool ValidateMonoText(MessageBoxHelper helper, double min, double max, out double val)
 {
     return helper.ValidateDecimalTextBox(textMono, min, max, out val);
 }
Пример #11
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;
        }
Пример #12
0
        public bool ValidateProductResMz(MessageBoxHelper helper, out double? productResMz, TabControl tabControl = null, int tabIndex = -1)
        {
            FullScanAcquisitionMethod acquisitionMethod = AcquisitionMethod;
            productResMz = null;

            if (acquisitionMethod != FullScanAcquisitionMethod.None)
            {
                if (IsResMzAnalyzer(ProductMassAnalyzer))
                {
                    double prodResMz;
                    bool valid;
                    if (null != tabControl)
                    {
                        valid = helper.ValidateDecimalTextBox(tabControl, (int) TransitionSettingsUI.TABS.FullScan,
                                                              textProductAt,
                                                              TransitionFullScan.MIN_RES_MZ,
                                                              TransitionFullScan.MAX_RES_MZ, out prodResMz);

                    }
                    else
                    {
                        valid = helper.ValidateDecimalTextBox(textProductAt,
                                                              TransitionFullScan.MIN_RES_MZ,
                                                              TransitionFullScan.MAX_RES_MZ, out prodResMz);

                    }

                    if (!valid)
                    {
                        return false;
                    }

                    productResMz = prodResMz;
                }
            }

            return true;
        }
Пример #13
0
        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;
        }
Пример #14
0
        public bool ValidateProductRes(MessageBoxHelper helper, out double? productRes, TabControl tabControl = null, int tabIndex = -1)
        {
            FullScanAcquisitionMethod acquisitionMethod = AcquisitionMethod;
            productRes = null;

            if (acquisitionMethod != FullScanAcquisitionMethod.None)
            {
                double minFilt, maxFilt;

                GetFilterMinMax(ProductMassAnalyzer, out minFilt, out maxFilt);

                double prodRes;
                bool valid;
                if (null != tabControl)
                {
                    valid = helper.ValidateDecimalTextBox(tabControl, (int) TransitionSettingsUI.TABS.FullScan,
                                                          textProductRes, minFilt, maxFilt, out prodRes);
                }
                else
                {
                    valid = helper.ValidateDecimalTextBox(textProductRes, minFilt, maxFilt, out prodRes);
                }

                if (!valid)
                    return false;

                productRes = prodRes;
            }

            return true;
        }
Пример #15
0
        public bool ValidatePrecursorResMz(MessageBoxHelper helper, out double? precursorResMz, TabControl tabControl = null, int tabIndex = -1)
        {
            precursorResMz = null;
            FullScanPrecursorIsotopes precursorIsotopes = PrecursorIsotopesCurrent;
            if (precursorIsotopes != FullScanPrecursorIsotopes.None)
            {
                if (IsResMzAnalyzer(PrecursorMassAnalyzer))
                {
                    double precResMz;
                    bool valid;
                    if (null != tabControl)
                    {
                        valid = helper.ValidateDecimalTextBox(tabControl, tabIndex, textPrecursorAt,
                                                              TransitionFullScan.MIN_RES_MZ,
                                                              TransitionFullScan.MAX_RES_MZ, out precResMz);
                    }
                    else
                    {
                        valid = helper.ValidateDecimalTextBox(textPrecursorAt,
                                                              TransitionFullScan.MIN_RES_MZ,
                                                              TransitionFullScan.MAX_RES_MZ, out precResMz);
                    }

                    if (!valid)
                        return false;

                    precursorResMz = precResMz;
                }
            }

            return true;
        }
Пример #16
0
        public bool ValidatePrecursorRes(MessageBoxHelper helper, double? precursorIsotopeFilter, out double? precursorRes, TabControl tabControl = null, int tabIndex = -1)
        {
            precursorRes = null;
            FullScanPrecursorIsotopes precursorIsotopes = PrecursorIsotopesCurrent;
            FullScanMassAnalyzerType precursorAnalyzerType = PrecursorMassAnalyzer;
            if (precursorIsotopes != FullScanPrecursorIsotopes.None)
            {
                if (precursorAnalyzerType == FullScanMassAnalyzerType.qit)
                {
                    if (precursorIsotopes != FullScanPrecursorIsotopes.Count || precursorIsotopeFilter != 1)
                    {
                        if (null != tabControl)
                        {
                            helper.ShowTextBoxError(tabControl, tabIndex, textPrecursorIsotopeFilter,
                                                    Resources.
                                                        TransitionSettingsUI_OkDialog_For_MS1_filtering_with_a_QIT_mass_analyzer_only_1_isotope_peak_is_supported);
                        }
                        else
                        {
                            helper.ShowTextBoxError(textPrecursorIsotopeFilter,
                                                    Resources.
                                                        TransitionSettingsUI_OkDialog_For_MS1_filtering_with_a_QIT_mass_analyzer_only_1_isotope_peak_is_supported);

                        }

                        return false;
                    }
                }
                double minFilt, maxFilt;
                GetFilterMinMax(PrecursorMassAnalyzer, out minFilt, out maxFilt);

                double precRes;
                bool valid;
                if (null != tabControl)
                {
                    valid = helper.ValidateDecimalTextBox(tabControl, tabIndex, textPrecursorRes,
                                                          minFilt, maxFilt, out precRes);
                }
                else
                {
                    valid = helper.ValidateDecimalTextBox(textPrecursorRes,
                                                          minFilt, maxFilt, out precRes);
                }
                if (!valid)
                    return false;

                precursorRes = precRes;
            }

            return true;
        }
Пример #17
0
        public bool ValidatePrecursorIsotopeFilter(MessageBoxHelper helper, out double? precursorIsotopeFilter, TabControl tabControl = null, int tabIndex = -1)
        {
            precursorIsotopeFilter = null;
            FullScanPrecursorIsotopes precursorIsotopes = PrecursorIsotopesCurrent;
            if (precursorIsotopes != FullScanPrecursorIsotopes.None)
            {
                double minFilt, maxFilt;
                if (precursorIsotopes == FullScanPrecursorIsotopes.Count)
                {
                    minFilt = TransitionFullScan.MIN_ISOTOPE_COUNT;
                    maxFilt = TransitionFullScan.MAX_ISOTOPE_COUNT;
                }
                else
                {
                    minFilt = TransitionFullScan.MIN_ISOTOPE_PERCENT;
                    maxFilt = TransitionFullScan.MAX_ISOTOPE_PERCENT;
                }
                double precIsotopeFilt;
                bool valid;
                if (null != tabControl)
                {
                    valid = helper.ValidateDecimalTextBox(tabControl, tabIndex, textPrecursorIsotopeFilter,
                                                          minFilt, maxFilt, out precIsotopeFilt);
                }
                else
                {
                    valid = helper.ValidateDecimalTextBox(textPrecursorIsotopeFilter,
                                                          minFilt, maxFilt, out precIsotopeFilt);
                }

                if (!valid)
                    return false;

                precursorIsotopeFilter = precIsotopeFilt;
            }

            return true;
        }
Пример #18
0
        public void OkDialog()
        {
            var helper = new MessageBoxHelper(this);

            double qCutoff = double.MaxValue;
            if (reintegrateQCutoff.Checked)
            {
                if (!helper.ValidateDecimalTextBox(textBoxCutoff, 0.0, 1.0, out qCutoff))
                    return;
            }

            using (var longWaitDlg = new LongWaitDlg
                {
                    Text = Resources.ReintegrateDlg_OkDialog_Reintegrating,
                })
            {
                try
                {
                    if (_driverPeakScoringModel.SelectedItem == null || !_driverPeakScoringModel.SelectedItem.IsTrained)
                    {
                        throw new InvalidDataException(Resources.ReintegrateDlg_OkDialog_You_must_train_and_select_a_model_in_order_to_reintegrate_peaks_);
                    }
                    var scoringModel = _driverPeakScoringModel.SelectedItem;
                    var resultsHandler = new MProphetResultsHandler(Document, scoringModel)
                    {
                        QValueCutoff = qCutoff,
                        OverrideManual = checkBoxOverwrite.Checked,
                        AddAnnotation = checkBoxAnnotation.Checked,
                        AddMAnnotation = checkBoxAnnotation.Checked
                    };
                    longWaitDlg.PerformWork(this, 1000, pm =>
                        {
                            resultsHandler.ScoreFeatures(pm);
                            if (resultsHandler.IsMissingScores())
                            {
                                throw new InvalidDataException(Resources.ReintegrateDlg_OkDialog_The_current_peak_scoring_model_is_incompatible_with_one_or_more_peptides_in_the_document___Please_train_a_new_model_);
                            }
                            // TODO: Add a checkbox for including decoys.  Probably most of the time real users won't want to bother with reintegrating decoys
                            Document = resultsHandler.ChangePeaks(pm);
                        });
                    if (longWaitDlg.IsCanceled)
                        return;
                }
                catch (Exception x)
                {
                    var message = TextUtil.LineSeparate(string.Format(Resources.ReintegrateDlg_OkDialog_Failed_attempting_to_reintegrate_peaks_),
                                                                      x.Message);
                    MessageDlg.ShowWithException(this, message, x);
                    return;
                }
            }

            var newPeakScoringModel = _driverPeakScoringModel.SelectedItem;
            if (!Equals(newPeakScoringModel, Document.Settings.PeptideSettings.Integration.PeakScoringModel))
            {
                Document = Document.ChangeSettings(Document.Settings.ChangePeptideIntegration(
                    i => i.ChangePeakScoringModel(newPeakScoringModel)));
            }

            DialogResult = DialogResult.OK;
        }
Пример #19
0
 public bool ValidateAverageText(MessageBoxHelper helper)
 {
     double val;
     return helper.ValidateDecimalTextBox(textAverage, out val);
 }
Пример #20
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);
        }
Пример #21
0
 public bool ValidateMonoText(MessageBoxHelper helper)
 {
     double val;
     return helper.ValidateDecimalTextBox(textMono, out val);
 }
Пример #22
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;
        }
        public bool BuildPeptideSearchLibrary(CancelEventArgs e)
        {
            // Nothing to build, if now search files were specified
            if (!SearchFilenames.Any())
            {
                var libraries = SkylineWindow.Document.Settings.PeptideSettings.Libraries;
                if (!libraries.HasLibraries)
                    return false;
                var libSpec = libraries.LibrarySpecs.FirstOrDefault(s => s.IsDocumentLibrary);
                return libSpec != null && LoadPeptideSearchLibrary(libSpec);
            }

            double cutOffScore;
            MessageBoxHelper helper = new MessageBoxHelper(WizardForm);
            if (!helper.ValidateDecimalTextBox(textCutoff, 0, 1.0, out cutOffScore))
            {
                e.Cancel = true;
                return false;
            }
            ImportPeptideSearch.CutoffScore = cutOffScore;

            BiblioSpecLiteBuilder builder;
            try
            {
                builder = ImportPeptideSearch.GetLibBuilder(SkylineWindow.Document, SkylineWindow.DocumentFilePath, cbIncludeAmbiguousMatches.Checked);
            }
            catch (FileEx.DeleteException de)
            {
                MessageDlg.ShowException(this, de);
                return false;
            }

            using (var longWaitDlg = new LongWaitDlg
                {
                    Text = Resources.BuildPeptideSearchLibraryControl_BuildPeptideSearchLibrary_Building_Peptide_Search_Library,
                    Message = Resources.BuildPeptideSearchLibraryControl_BuildPeptideSearchLibrary_Building_document_library_for_peptide_search_,
                })
            {
                // Disable the wizard, because the LongWaitDlg does not
                try
                {
                    ImportPeptideSearch.ClosePeptideSearchLibraryStreams(SkylineWindow.DocumentUI);
                    var status = longWaitDlg.PerformWork(WizardForm, 800,
                        monitor => LibraryManager.BuildLibraryBackground(SkylineWindow, builder, monitor, new LibraryManager.BuildState(null, null)));
                    if (status.IsError)
                    {
                        MessageDlg.ShowException(WizardForm, status.ErrorException);
                        return false;
                    }
                }
                catch (Exception x)
                {
                    MessageDlg.ShowWithException(WizardForm, TextUtil.LineSeparate(string.Format(Resources.BuildPeptideSearchLibraryControl_BuildPeptideSearchLibrary_Failed_to_build_the_library__0__,
                                                                                    Path.GetFileName(BiblioSpecLiteSpec.GetLibraryFileName(SkylineWindow.DocumentFilePath))), x.Message), x);
                    return false;
                }
            }

            var docLibSpec = builder.LibrarySpec.ChangeDocumentLibrary(true);
            Settings.Default.SpectralLibraryList.Insert(0, docLibSpec);

            // Go ahead and load the library - we'll need it for
            // the modifications and chromatograms page.
            if (!LoadPeptideSearchLibrary(docLibSpec))
                return false;

            var docNew = ImportPeptideSearch.AddDocumentSpectralLibrary(SkylineWindow.Document, docLibSpec);
            if (docNew == null)
                return false;

            SkylineWindow.ModifyDocument(Resources.BuildPeptideSearchLibraryControl_BuildPeptideSearchLibrary_Add_document_spectral_library, doc => docNew);

            if (!string.IsNullOrEmpty(builder.AmbiguousMatchesMessage))
            {
                MessageDlg.Show(WizardForm, builder.AmbiguousMatchesMessage);
            }
            return true;
        }
        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);
        }