コード例 #1
0
        private void comboIsolationScheme_SelectedIndexChanged(object sender, EventArgs e)
        {
            _driverIsolationScheme.SelectedIndexChangedEvent(sender, e);

            // If we have a callback function and the isolation scheme _did_ really change its value, we invoke the handler
            if (IsolationSchemeChangedEvent != null && !Equals(_prevval_comboIsolationScheme, IsolationScheme))
            {
                IsolationSchemeChangedEvent.Invoke(sender, e);
            }
            _prevval_comboIsolationScheme = IsolationScheme; //update previous isolation scheme
        }
コード例 #2
0
        public FullScanSettingsControl(SkylineWindow skylineWindow)
        {
            SkylineWindow = skylineWindow;

            InitializeComponent();

            InitializeMs1FilterUI();
            InitializeMsMsFilterUI();
            InitializeRetentionTimeFilterUI();

            // Update the precursor analyzer type in case the SelectedIndex is still -1
            UpdatePrecursorAnalyzerType();
            UpdateProductAnalyzerType();

            PrecursorIsotopesCurrent = FullScan.PrecursorIsotopes;
            PrecursorMassAnalyzer    = FullScan.PrecursorMassAnalyzer;

            _prevval_comboIsolationScheme = IsolationScheme; // initialize previous value to initial value
        }
コード例 #3
0
        public void Initialize()
        {
            InitializeComponent();

            InitializeMs1FilterUI();
            InitializeMsMsFilterUI();
            InitializeRetentionTimeFilterUI();
            InitializeUseSpectralLibraryIonMobilityUI();

            // Update the precursor analyzer type in case the SelectedIndex is still -1
            UpdatePrecursorAnalyzerType();
            UpdateProductAnalyzerType();

            PrecursorIsotopesCurrent = FullScan.PrecursorIsotopes;
            PrecursorMassAnalyzer    = FullScan.PrecursorMassAnalyzer;

            cbHighSelectivity.Checked = FullScan.UseSelectiveExtraction;

            _prevval_comboIsolationScheme = IsolationScheme; // initialize previous value to initial value
        }
コード例 #4
0
        public FullScanSettingsControl(IModifyDocumentContainer documentContainer)
        {
            _documentContainer = documentContainer;

            InitializeComponent();

            InitializeMs1FilterUI();
            InitializeMsMsFilterUI();
            InitializeRetentionTimeFilterUI();

            // Update the precursor analyzer type in case the SelectedIndex is still -1
            UpdatePrecursorAnalyzerType();
            UpdateProductAnalyzerType();

            PrecursorIsotopesCurrent = FullScan.PrecursorIsotopes;
            PrecursorMassAnalyzer    = FullScan.PrecursorMassAnalyzer;

            cbHighSelectivity.Checked = FullScan.UseSelectiveExtraction;

            _prevval_comboIsolationScheme = IsolationScheme; // initialize previous value to initial value
        }
コード例 #5
0
ファイル: EditIsolationSchemeDlg.cs プロジェクト: zrolfs/pwiz
        private void ImportRangesFromFiles(MsDataFileUri[] dataSources)
        {
            try
            {
                IsolationScheme isolationScheme = null;
                using (var dlg = new LongWaitDlg
                {
                    Message = Resources.EditIsolationSchemeDlg_ImportRangesFromFiles_Reading_isolation_scheme___
                })
                {
                    var reader = new IsolationSchemeReader(dataSources);
                    dlg.PerformWork(this, 500, progressMonitor => isolationScheme = reader.Import("temp", progressMonitor)); // Not L10N
                }

                if (isolationScheme != null)
                {
                    cbSpecifyMargin.Checked     = isolationScheme.PrespecifiedIsolationWindows.Count(w => w.StartMargin.HasValue) > 1;
                    comboDeconvPre.SelectedItem = isolationScheme.SpecialHandling == IsolationScheme.SpecialHandlingType.OVERLAP_MULTIPLEXED
                        ? DeconvolutionMethod.OVERLAP
                        : DeconvolutionMethod.NONE;
                    _gridViewDriver.Items.Clear();
                    foreach (var isolationWindow in isolationScheme.PrespecifiedIsolationWindows)
                    {
                        _gridViewDriver.Items.Add(new EditIsolationWindow
                        {
                            Start       = isolationWindow.Start,
                            End         = isolationWindow.End,
                            StartMargin = isolationWindow.StartMargin
                        });
                    }
                }
            }
            catch (Exception x)
            {
                MessageDlg.ShowWithException(this, TextUtil.LineSeparate(Resources.EditIsolationSchemeDlg_ImportRangesFromFiles_Failed_reading_isolation_scheme_, x.Message), x);
            }
        }
コード例 #6
0
ファイル: ExportMethodDialogTest.cs プロジェクト: zrolfs/pwiz
        private void BrukerTOFMethodTest()
        {
            const string brukerOutputMethodFilename = "RetTimeMassListFile.Method";

            RunUI(() => SkylineWindow.OpenFile(TestFilesDir.GetTestPath("Bovine_std_curated_seq_small2-trigger.sky")));
            string brukerActualMeth   = TestFilesDir.GetTestPath("brukermethodexport.m");
            string brukerExpectedMeth = TestFilesDir.GetTestPath("BrukerExpected.Method");
            string brukerTemplateMeth = TestFilesDir.GetTestPath("Bruker Template Scheduled Precursor List.m");

            WaitForDocumentLoaded();

            // Export PRM method unscheduled
            RunDlg <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.Method),
                                     exportMethodDlg =>
            {
                exportMethodDlg.InstrumentType = ExportInstrumentType.BRUKER_TOF;
                exportMethodDlg.ExportStrategy = ExportStrategy.Single;
                exportMethodDlg.SetTemplateFile(brukerTemplateMeth);
                exportMethodDlg.MethodType = ExportMethodType.Standard;
                Assert.IsTrue(exportMethodDlg.IsRunLengthVisible);
                Assert.IsFalse(exportMethodDlg.IsOptimizeTypeEnabled);
                exportMethodDlg.RunLength = 20;
                exportMethodDlg.OkDialog(brukerActualMeth);
            });

            Assert.IsTrue(Directory.Exists(brukerActualMeth));
            AssertEx.NoDiff(File.ReadAllText(brukerExpectedMeth), File.ReadAllText(Path.Combine(brukerActualMeth, brukerOutputMethodFilename)));
            DirectoryEx.SafeDelete(brukerActualMeth);

            // Export PRM method scheduled
            RunDlg <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.Method),
                                     exportMethodDlg =>
            {
                exportMethodDlg.InstrumentType = ExportInstrumentType.BRUKER_TOF;
                exportMethodDlg.ExportStrategy = ExportStrategy.Single;
                exportMethodDlg.SetTemplateFile(brukerTemplateMeth);
                exportMethodDlg.MethodType = ExportMethodType.Scheduled;
                Assert.IsFalse(exportMethodDlg.IsRunLengthVisible);
                Assert.IsFalse(exportMethodDlg.IsOptimizeTypeEnabled);
                exportMethodDlg.OkDialog(brukerActualMeth);
            });

            Assert.IsTrue(Directory.Exists(brukerActualMeth));
            brukerExpectedMeth = TestFilesDir.GetTestPath("BrukerExpectedSched.Method");
            AssertEx.NoDiff(File.ReadAllText(brukerExpectedMeth), File.ReadAllText(Path.Combine(brukerActualMeth, brukerOutputMethodFilename)));
            DirectoryEx.SafeDelete(brukerActualMeth);

            // Export PRM method scheduled error
            {
                RunUI(() => SkylineWindow.ModifyDocument("Remove RT prediction",
                                                         doc => doc.ChangeSettings(doc.Settings.ChangePeptidePrediction(predict => predict.ChangeRetentionTime(null)))));
                var exportMethodDlgError = ShowDialog <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.Method));
                RunUI(() =>
                {
                    exportMethodDlgError.InstrumentType = ExportInstrumentType.BRUKER_TOF;
                    exportMethodDlgError.ExportStrategy = ExportStrategy.Single;
                    exportMethodDlgError.SetTemplateFile(brukerTemplateMeth);
                });
                RunDlg <MessageDlg>(() => exportMethodDlgError.MethodType = ExportMethodType.Scheduled,
                                    dlg => dlg.CancelDialog());
                OkDialog(exportMethodDlgError, exportMethodDlgError.CancelDialog);
            }

            // Export DIA Method
            {
                var isoWindows = new IsolationScheme("Prespecified", new[]
                {
                    new IsolationWindow(500, 521, null, 0.5, 0.5),
                    new IsolationWindow(520, 541, null, 0.5, 0.5),
                    new IsolationWindow(540, 561, null, 0.5, 0.5),
                });

                RunUI(() => SkylineWindow.ModifyDocument("Add isolation window list",
                                                         doc => doc.ChangeSettings(doc.Settings.ChangeTransitionFullScan(full => full.ChangeAcquisitionMethod(FullScanAcquisitionMethod.DIA, isoWindows)))));
                var exportMethodDlgDia = ShowDialog <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.Method));

                RunUI(() =>
                {
                    exportMethodDlgDia.InstrumentType = ExportInstrumentType.BRUKER_TOF;
                    exportMethodDlgDia.ExportStrategy = ExportStrategy.Single;
                    exportMethodDlgDia.SetTemplateFile(brukerTemplateMeth);
                });

                RunDlg <MessageDlg>(() => exportMethodDlgDia.MethodType = ExportMethodType.Scheduled, dlg =>
                {
                    Assert.AreEqual(Resources.ExportMethodDlg_comboTargetType_SelectedIndexChanged_Scheduled_methods_are_not_yet_supported_for_DIA_acquisition, dlg.Message);
                    dlg.CancelDialog();
                });

                RunUI(() =>
                {
                    Assert.IsTrue(exportMethodDlgDia.IsRunLengthVisible);
                    exportMethodDlgDia.RunLength = 20;
                });
                OkDialog(exportMethodDlgDia, () => exportMethodDlgDia.OkDialog(brukerActualMeth));

                Assert.IsTrue(Directory.Exists(brukerActualMeth));
                brukerExpectedMeth = TestFilesDir.GetTestPath("BrukerExpectedDIA.Method");
                AssertEx.NoDiff(File.ReadAllText(brukerExpectedMeth), File.ReadAllText(Path.Combine(brukerActualMeth, brukerOutputMethodFilename)));
            }

            // Export DIA method error not prespecified
            {
                var isoResults = new IsolationScheme("Results (20)", 20.0);
                RunUI(() => SkylineWindow.ModifyDocument("Add results isolation scheme",
                                                         doc => doc.ChangeSettings(doc.Settings.ChangeTransitionFullScan(full => full.ChangeAcquisitionMethod(FullScanAcquisitionMethod.DIA, isoResults)))));

                var exportMethodDlgDia = ShowDialog <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.Method));

                RunUI(() =>
                {
                    exportMethodDlgDia.InstrumentType = ExportInstrumentType.BRUKER_TOF;
                    exportMethodDlgDia.ExportStrategy = ExportStrategy.Single;
                    exportMethodDlgDia.SetTemplateFile(brukerTemplateMeth);
                });

                RunDlg <MessageDlg>(exportMethodDlgDia.OkDialog, dlg =>
                {
                    Assert.AreEqual(Resources.ExportMethodDlg_OkDialog_The_DIA_isolation_list_must_have_prespecified_windows_, dlg.Message);
                    dlg.CancelDialog();
                });

                OkDialog(exportMethodDlgDia, exportMethodDlgDia.CancelDialog);
            }
        }
コード例 #7
0
        public void SerializeIsolationSchemeTest()
        {
            var isolationScheme = new IsolationScheme("object test", 1.0, 2.0);

            // Test IsolationScheme.Validate method through ChangeProp
            isolationScheme = (IsolationScheme)isolationScheme.ChangeName("test2");

            // Test IsolationScheme object methods
            isolationScheme.Equals(null);
            isolationScheme.Equals(isolationScheme);
// ReSharper disable ReturnValueOfPureMethodIsNotUsed
            isolationScheme.Equals((object)null);
            isolationScheme.Equals((object)isolationScheme);
            isolationScheme.GetHashCode();
// ReSharper restore ReturnValueOfPureMethodIsNotUsed

            // Test IsolationWindow object methods
            var isolationWindow = new IsolationWindow(100.0, 150.0, 125.0, 1.0, 1.0);

            isolationWindow.Equals(null);
            isolationWindow.Equals(isolationWindow);
// ReSharper disable ReturnValueOfPureMethodIsNotUsed
            isolationWindow.Equals((object)null);
            isolationWindow.Equals((object)isolationWindow);
// ReSharper disable SuspiciousTypeConversion.Global
            isolationWindow.Equals(2);
// ReSharper restore SuspiciousTypeConversion.Global
            isolationWindow.GetHashCode();
            isolationWindow.GetSchema();
// ReSharper restore ReturnValueOfPureMethodIsNotUsed

            // Test round trip serialization
            AssertEx.Serialization <IsolationSchemeList>(ISOLATION_SCHEME_LIST, CheckSettingsList, false); // Not part of a Skyline document, don't check against schema

            // Valid first
            AssertEx.DeserializeNoError <IsolationScheme>(
                @"<isolation_scheme name=""Validate (1)"" precursor_filter=""1""/>");
            AssertEx.DeserializeNoError <IsolationScheme>(
                @"<isolation_scheme name=""Validate (2)"" precursor_left_filter=""0.5"" precursor_right_filter=""0.5""/>");
            AssertEx.DeserializeNoError <IsolationScheme>(
                @"<isolation_scheme name=""Validate (3)"" special_handling=""Multiplexed"" windows_per_scan=""2"">
                    <isolation_window start=""100"" end=""110""/><isolation_window start=""110"" end=""130""/></isolation_scheme>");
            AssertEx.DeserializeNoError <IsolationScheme>(
                @"<isolation_scheme name=""Validate (4)"" special_handling=""MSe""/>");

            // Missing parameters
            AssertEx.DeserializeError <IsolationScheme>(@"<isolation_scheme/>");
            // No name
            AssertEx.DeserializeError <IsolationScheme>(@"<isolation_scheme precursor_filter=""1""/>");
            // Filter and prespecified window
            AssertEx.DeserializeError <IsolationScheme>(
                @"<isolation_scheme name=""Invalid (1)"" precursor_filter=""1""><isolation_window start=""1"" end=""10""/></isolation_scheme>");
            // Filter and special handling
            //AssertEx.DeserializeError<IsolationScheme>(
            //    @"<isolation_scheme name=""Invalid (2)"" precursor_filter=""1"" special_handling=""MSe""/>");
            // Filter and windows per scan
            AssertEx.DeserializeError <IsolationScheme>(
                @"<isolation_scheme name=""Invalid (3)"" precursor_filter=""1"" windows_per_scan=""3""/>");
            // Special handling but no windows (now uses results windows)
//            AssertEx.DeserializeError<IsolationScheme>(
//                @"<isolation_scheme name=""Invalid (4)"" special_handling=""Multiplexed""/>");
            // Right filter only
            AssertEx.DeserializeError <IsolationScheme>(
                @"<isolation_scheme name=""Invalid (5)"" precursor_right_filter=""1""/>");
            // Windows per scan with no special handling
            AssertEx.DeserializeError <IsolationScheme>(
                @"<isolation_scheme name=""Invalid (6)"" windows_per_scan=""2""><isolation_window start=""1"" end=""10""/></isolation_scheme>");
            // Windows per scan with MSe
            AssertEx.DeserializeError <IsolationScheme>(
                @"<isolation_scheme name=""Invalid (7)"" windows_per_scan=""2"" special_handling=""MSe"" />");
            // Multiplexed and no windows per scan
            AssertEx.DeserializeError <IsolationScheme>(
                @"<isolation_scheme name=""Invalid (8)"" special_handling=""Multiplexed""><isolation_window start=""1"" end=""10""/></isolation_scheme>");
            // Multiplexed and invalid windows per scan
            AssertEx.DeserializeError <IsolationScheme>(
                @"<isolation_scheme name=""Invalid (9)"" windows_per_scan=""0"" special_handling=""Multiplexed""><isolation_window start=""1"" end=""10""/></isolation_scheme>");
            // Invalid special handling
            AssertEx.DeserializeError <IsolationScheme>(
                @"<isolation_scheme name=""Invalid (10)"" special_handling=""invalid option""/>");

            // Bad window: start > end
            AssertEx.DeserializeError <IsolationScheme>(
                @"<isolation_scheme name=""Invalid (10)""><isolation_window start=""10"" end=""1""/></isolation_scheme>");
            // Bad window: target not between start and end
            AssertEx.DeserializeError <IsolationScheme>(
                @"<isolation_scheme name=""Invalid (11)""><isolation_window start=""1"" end=""10"" target=""20""/></isolation_scheme>");
            // Bad window: start margin < 0
            AssertEx.DeserializeError <IsolationScheme>(
                @"<isolation_scheme name=""Invalid (12)""><isolation_window start=""1"" end=""10"" margin_left=""-1"" margin_right=""2""/></isolation_scheme>");
            // MSe with window
            AssertEx.DeserializeError <IsolationScheme>(
                @"<isolation_scheme name=""Invalid (14)"" special_handling=""MSe""><isolation_window start=""1"" end=""10""/></isolation_scheme>");
        }
コード例 #8
0
ファイル: EditIsolationSchemeDlg.cs プロジェクト: zrolfs/pwiz
        public void OkDialog()
        {
            var helper = new MessageBoxHelper(this);

            string name;

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

            if (_existing.Contains(en => !ReferenceEquals(_isolationScheme, en) && Equals(name, en.Name)))
            {
                helper.ShowTextBoxError(textName,
                                        Resources.EditIsolationSchemeDlg_OkDialog_The_isolation_scheme_named__0__already_exists, name);
                return;
            }

            if (rbUseResultsData.Checked)
            {
                double?precursorFilter = null;
                bool   filterMargin    = Equals(comboIsolationWidth.SelectedItem, IsolationWidthType.RESULTS_WITH_MARGIN);
                if (!Equals(comboIsolationWidth.SelectedItem, IsolationWidthType.RESULTS))
                {
                    double minFilt = filterMargin ? 0 : TransitionFullScan.MIN_PRECURSOR_MULTI_FILTER;
                    double maxFilt = filterMargin
                        ? TransitionFullScan.MAX_PRECURSOR_MULTI_FILTER_MARGIN
                        : TransitionFullScan.MAX_PRECURSOR_MULTI_FILTER;
                    double precFilt;
                    if (!helper.ValidateDecimalTextBox(textPrecursorFilterMz,
                                                       minFilt, maxFilt, out precFilt))
                    {
                        return;
                    }
                    precursorFilter = precFilt;
                }
                try
                {
                    _isolationScheme = new IsolationScheme(name, SpecialHandling, precursorFilter, null, filterMargin);
                }
                catch (InvalidDataException exception)
                {
                    MessageDlg.ShowException(this, exception);
                    return;
                }
            }
            else
            {
                // Validate prespecified windows.
                List <IsolationWindow> windowList;
                if ((windowList = GetIsolationWindows()) == null)
                {
                    return;
                }


                // Must be at least one window.
                if (windowList.Count == 0)
                {
                    _gridViewDriver.SelectCell(COLUMN_START, 0);
                    MessageDlg.Show(this,
                                    Resources
                                    .EditIsolationSchemeDlg_OkDialog_Specify_Start_and_End_values_for_at_least_one_isolation_window);
                    gridIsolationWindows.Focus();
                    _gridViewDriver.EditCell();
                    return;
                }

                int?windowsPerScan = null;
                if (Equals(SpecialHandling, IsolationScheme.SpecialHandlingType.MULTIPLEXED))
                {
                    int x;
                    if (!helper.ValidateNumberTextBox(textWindowsPerScan,
                                                      IsolationScheme.MIN_MULTIPLEXED_ISOLATION_WINDOWS,
                                                      IsolationScheme.MAX_MULTIPLEXED_ISOLATION_WINDOWS,
                                                      out x))
                    {
                        return;
                    }
                    windowsPerScan = x;
                }
                // Check for overlap and gaps
                var          sortedWindowList = windowList.OrderBy(o => o.Start).ToList();
                bool         gapsOk           = false;
                bool         overlapsOk       = false;
                bool         overlap          = Overlap;
                int          increment        = overlap ? 2 : 1;
                int          subtraction      = overlap ? 3 : 1;
                const double tolerance        = 0.0001;
                for (int i = 0; i < sortedWindowList.Count - subtraction; i += increment)
                {
                    for (int j = 0; j < increment; j++)
                    {
                        IsolationWindow current = sortedWindowList.ElementAt(i + j);
                        IsolationWindow next    = sortedWindowList.ElementAt(i + j + increment);
                        if (!gapsOk && next.Start - current.End > tolerance)
                        {
                            if (MultiButtonMsgDlg.Show(this,
                                                       Resources
                                                       .EditIsolationSchemeDlg_OkDialog_There_are_gaps_in_a_single_cycle_of_your_extraction_windows__Do_you_want_to_continue_,
                                                       MultiButtonMsgDlg.BUTTON_YES, MultiButtonMsgDlg.BUTTON_NO, false) !=
                                DialogResult.Yes)
                            {
                                return;
                            }
                            gapsOk = true;
                        }
                        else if (!overlapsOk && current.End - next.Start > tolerance)
                        {
                            if (MultiButtonMsgDlg.Show(this,
                                                       Resources.EditIsolationSchemeDlgOkDialogThereAreOverlapsContinue,
                                                       MultiButtonMsgDlg.BUTTON_YES,
                                                       MultiButtonMsgDlg.BUTTON_NO, false) != DialogResult.Yes)
                            {
                                return;
                            }
                            overlapsOk = true;
                        }
                    }
                }
                try
                {
                    _isolationScheme = new IsolationScheme(name, windowList, SpecialHandling, windowsPerScan);
                }
                catch (InvalidDataException exception)
                {
                    MessageDlg.ShowException(this, exception);
                    return;
                }
            }

            DialogResult = DialogResult.OK;
        }
コード例 #9
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;
        }
コード例 #10
0
ファイル: AbstractDiaExporter.cs プロジェクト: rfellers/pwiz
 protected AbstractDiaExporter(IsolationScheme isolationScheme, int?maxInstrumentWindows)
 {
     IsolationScheme       = isolationScheme;
     _maxInstrumentWindows = maxInstrumentWindows;
 }