示例#1
0
        public void UseResults()
        {
            CheckDisposed();
            var document = Program.ActiveDocumentUI;

            if (!document.Settings.HasResults)
            {
                MessageDlg.Show(this, Resources.CalibrateIrtDlg_UseResults_The_document_must_contain_results_to_calibrate_a_standard);
                return;
            }

            var targetResolver = TargetResolver.MakeTargetResolver(document);

            calibratePeptides.TargetResolver = targetResolver;

            int count = document.Molecules.Count(nodePep => nodePep.SchedulingTime.HasValue);

            if (count > 20)
            {
                using (var dlg = new AddIrtStandardsDlg(count))
                {
                    if (dlg.ShowDialog(this) != DialogResult.OK)
                    {
                        return;
                    }

                    count = dlg.StandardCount;
                }
            }

            _gridViewDriver.Recalculate(document, count);
        }
示例#2
0
        private bool SetCalibrationPeptides(ICollection <PeptideDocNode> exclude)
        {
            CheckDisposed();
            var document = Program.ActiveDocumentUI;

            if (!document.Settings.HasResults)
            {
                MessageDlg.Show(this, Resources.CalibrateIrtDlg_UseResults_The_document_must_contain_results_to_calibrate_a_standard);
                return(false);
            }

            var targetResolver = TargetResolver.MakeTargetResolver(document);

            _gridViewDriver.TargetResolver = targetResolver;

            var peptides = document.Molecules.Where(nodePep => nodePep.SchedulingTime.HasValue).ToArray();
            var count    = peptides.Length;

            if (exclude != null && exclude.Count > 0)
            {
                peptides = peptides.Where(nodePep => !exclude.Contains(nodePep)).ToArray();
                count    = peptides.Length;
                if (count < MIN_STANDARD_PEPTIDES)
                {
                    MessageDlg.Show(this,
                                    ModeUIAwareStringFormat(
                                        Resources.CalibrateIrtDlg_SetCalibrationPeptides_The_document_contains_results_for__0__peptide_s__not_in_this_standard__which_is_less_than_the_minimum_requirement_of__1__to_calibrate_a_standard_,
                                        count, MIN_STANDARD_PEPTIDES));
                    return(false);
                }
                else if (count < MIN_SUGGESTED_STANDARD_PEPTIDES)
                {
                    if (MultiButtonMsgDlg.Show(this,
                                               ModeUIAwareStringFormat(
                                                   Resources.CalibrateIrtDlg_SetCalibrationPeptides_The_document_only_contains_results_for__0__peptide_s__not_in_this_standard__It_is_recommended_to_use_at_least__1__peptides_to_calibrate_a_standard__Are_you_sure_you_wish_to_continue_,
                                                   count, MIN_SUGGESTED_STANDARD_PEPTIDES),
                                               MultiButtonMsgDlg.BUTTON_YES, MultiButtonMsgDlg.BUTTON_NO, false) != DialogResult.Yes)
                    {
                        return(false);
                    }
                }
            }
            if (count > 20)
            {
                using (var dlg = new AddIrtStandardsDlg(count, exclude != null && exclude.Count > 0))
                {
                    if (dlg.ShowDialog(this) != DialogResult.OK)
                    {
                        return(false);
                    }

                    count = dlg.StandardCount;
                }
            }

            _gridViewDriver.Recalculate(document, count, exclude);
            return(true);
        }
示例#3
0
        public void UseResults()
        {
            if (!_document.Settings.HasResults)
            {
                MessageDlg.Show(this, Resources.CalibrateIrtDlg_UseResults_The_document_must_contain_results_to_calibrate_a_standard);
                return;
            }

            var count = _document.Molecules.Where(nodePep => nodePep.SchedulingTime.HasValue).Select(nodePep => nodePep.ModifiedTarget).Distinct().Count();

            if (count < CalibrateIrtDlg.MIN_STANDARD_PEPTIDES)
            {
                MessageDlg.Show(this,
                                string.Format(
                                    Resources.CalibrateIrtDlg_UseResults_The_document_contains_results_for__0__peptides__which_is_less_than_the_minimum_requirement_of__1__to_calibrate_a_standard_,
                                    count, CalibrateIrtDlg.MIN_STANDARD_PEPTIDES));
                return;
            }
            else if (count < CalibrateIrtDlg.MIN_SUGGESTED_STANDARD_PEPTIDES)
            {
                if (MultiButtonMsgDlg.Show(this,
                                           string.Format(
                                               Resources.CalibrateIrtDlg_UseResults_The_document_contains_results_for__0__peptides__but_using_fewer_than__1__standard_peptides_is_not_recommended__Are_you_sure_you_want_to_continue_,
                                               count, CalibrateIrtDlg.MIN_SUGGESTED_STANDARD_PEPTIDES),
                                           MultiButtonMsgDlg.BUTTON_YES, MultiButtonMsgDlg.BUTTON_NO, false) != DialogResult.Yes)
                {
                    return;
                }
            }
            else if (count > 20)
            {
                using (var dlg = new AddIrtStandardsDlg(count, false))
                {
                    if (dlg.ShowDialog(this) != DialogResult.OK)
                    {
                        return;
                    }
                    count = dlg.StandardCount;
                }
            }

            if (!_picker.HasScoredPeptides)
            {
                using (var longWaitDlg = new LongWaitDlg {
                    Text = Resources.CalibrationGridViewDriver_FindEvenlySpacedPeptides_Calculating_scores
                })
                {
                    longWaitDlg.PerformWork(this, 1000, pm => _picker.ScorePeptides(_document, pm));
                    if (longWaitDlg.IsCanceled)
                    {
                        return;
                    }
                }
            }

            var useCirt = false;

            if (_picker.TryGetCirtRegression(count, out _, out _))
            {
                switch (MultiButtonMsgDlg.Show(this, string.Format(
                                                   Resources.CalibrationGridViewDriver_FindEvenlySpacedPeptides_This_document_contains__0__CiRT_peptides__Would_you_like_to_use__1__of_them_as_your_iRT_standards_,
                                                   _picker.CirtPeptideCount, count), MultiButtonMsgDlg.BUTTON_YES, MultiButtonMsgDlg.BUTTON_NO, true))
                {
                case DialogResult.Yes:
                    useCirt = true;
                    break;

                case DialogResult.No:
                    break;

                case DialogResult.Cancel:
                    return;
                }
            }

            comboProteins.SelectedIndex = 0;
            PeptideLines = _picker.Pick(count, null, useCirt).Select(pep => pep.Target.ToString()).ToArray();
        }
示例#4
0
        public bool SetCalibrationPeptides()
        {
            CheckDisposed();
            var document = Program.ActiveDocumentUI;

            if (!document.Settings.HasResults)
            {
                MessageDlg.Show(this, Resources.CalibrateIrtDlg_UseResults_The_document_must_contain_results_to_calibrate_a_standard);
                return(false);
            }
            var targetResolver = TargetResolver.MakeTargetResolver(document);

            _gridViewDriver.TargetResolver = targetResolver;

            var docTargets = document.Molecules.Where(nodePep => nodePep.SchedulingTime.HasValue).Select(nodePep => nodePep.ModifiedTarget).Distinct().ToArray();
            var count      = docTargets.Length;

            // If calibrating against another standard, exclude peptides in that standard
            var excludePeps = SelectedRegressionOption?.MatchedRegressionPeptides?.Select(match => match.Item2.ModifiedTarget).ToHashSet();
            var exclude     = excludePeps != null && excludePeps.Count > 0;

            if (exclude)
            {
                docTargets = docTargets.Where(target => !excludePeps.Contains(target)).ToArray();
                count      = docTargets.Length;
            }

            if (count < MIN_STANDARD_PEPTIDES)
            {
                MessageDlg.Show(this,
                                ModeUIAwareStringFormat(!exclude
                            ? Resources.CalibrateIrtDlg_UseResults_The_document_contains_results_for__0__peptides__which_is_less_than_the_minimum_requirement_of__1__to_calibrate_a_standard_
                            : Resources.CalibrateIrtDlg_SetCalibrationPeptides_The_document_contains_results_for__0__peptide_s__not_in_this_standard__which_is_less_than_the_minimum_requirement_of__1__to_calibrate_a_standard_,
                                                        count, MIN_STANDARD_PEPTIDES));
                return(false);
            }
            else if (count < MIN_SUGGESTED_STANDARD_PEPTIDES)
            {
                if (MultiButtonMsgDlg.Show(this,
                                           ModeUIAwareStringFormat(!exclude
                                ? Resources.CalibrateIrtDlg_UseResults_The_document_contains_results_for__0__peptides__but_using_fewer_than__1__standard_peptides_is_not_recommended__Are_you_sure_you_want_to_continue_
                                : Resources.CalibrateIrtDlg_UseResults_The_document_contains_results_for__0__peptides_not_in_this_standard__but_using_fewer_than__1__standard_peptides_is_not_recommended__Are_you_sure_you_want_to_continue_,
                                                                   count, MIN_SUGGESTED_STANDARD_PEPTIDES),
                                           MultiButtonMsgDlg.BUTTON_YES, MultiButtonMsgDlg.BUTTON_NO, false) != DialogResult.Yes)
                {
                    return(false);
                }
            }
            else if (count > 20)
            {
                using (var dlg = new AddIrtStandardsDlg(count, excludePeps != null && excludePeps.Count > 0))
                {
                    if (dlg.ShowDialog(this) != DialogResult.OK)
                    {
                        return(false);
                    }
                    count = dlg.StandardCount;
                }
            }

            _gridViewDriver.Recalculate(document, count, SelectedRegressionOption, excludePeps);
            return(true);
        }