public void CalcCollisionEnergy(CollisionEnergyRegression regression) { CollisionEnergy = regression.GetCollisionEnergy(PrecursorCharge, PrecursorMZ); }
public void OkDialog() { var helper = new MessageBoxHelper(this); string name; if (!helper.ValidateNameTextBox(textName, out name)) { return; } if (_existing.Contains(r => !ReferenceEquals(_regression, r) && Equals(name, r.Name))) { helper.ShowTextBoxError(textName, Resources.EditCEDlg_OkDialog_The_collision_energy_regression__0__already_exists, name); return; } List <ChargeRegressionLine> conversions = new List <ChargeRegressionLine>(); foreach (DataGridViewRow row in gridRegression.Rows) { if (row.IsNewRow) { continue; } int charge; if (!ValidateCharge(row.Cells[0], out charge)) { return; } double slope; if (!ValidateSlope(row.Cells[1], out slope)) { return; } double intercept; if (!ValidateIntercept(row.Cells[2], out intercept)) { return; } conversions.Add(new ChargeRegressionLine(charge, slope, intercept)); } if (conversions.Count == 0) { MessageDlg.Show(this, Resources.EditCEDlg_OkDialog_Collision_energy_regressions_require_at_least_one_regression_function); return; } double stepSize; if (!helper.ValidateDecimalTextBox(textStepSize, CollisionEnergyRegression.MIN_STEP_SIZE, CollisionEnergyRegression.MAX_STEP_SIZE, out stepSize)) { return; } int stepCount; if (!helper.ValidateNumberTextBox(textStepCount, OptimizableRegression.MIN_OPT_STEP_COUNT, OptimizableRegression.MAX_OPT_STEP_COUNT, out stepCount)) { return; } _regression = new CollisionEnergyRegression(name, conversions, stepSize, stepCount); DialogResult = DialogResult.OK; Close(); }
private static double GetCollisionEnergy(SrmSettings settings, PeptideDocNode nodePep, TransitionGroupDocNode nodeGroup, CollisionEnergyRegression regression, int step) { var charge = nodeGroup.TransitionGroup.PrecursorAdduct; double mz = settings.GetRegressionMz(nodePep, nodeGroup); return(regression.GetCollisionEnergy(charge, mz) + regression.StepSize * step); }
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; }
public void ConsoleExportTrigger() { // The special mode for exercising non-proteomic molecules just doesn't make sense with this test TestSmallMolecules = false; var testFilesDir = new TestFilesDir(TestContext, ZIP_FILE); string docPath = testFilesDir.GetTestPath("BSA_Protea_label_free_20100323_meth3_multi.sky"); string failurePath = testFilesDir.GetTestPath("Failure_test.csv"); string output = RunCommand("--in=" + docPath, "--exp-translist-instrument=" + ExportInstrumentType.WATERS, "--exp-file=" + failurePath, "--exp-strategy=single", "--exp-method-type=triggered", "--exp-primary-count=x"); //check for warning and error Assert.AreEqual(2, CountInstances(Resources.CommandLineTest_ConsoleAddFastaTest_Warning, output)); // exp-primary-count and CE not Waters CheckRunCommandOutputContains(Resources.CommandLineTest_ConsoleAddFastaTest_Error, output); // Waters Assert.AreEqual(2, CountInstances(ExportInstrumentType.WATERS, output)); var commandFilesDir = new TestFilesDir(TestContext, COMMAND_FILE); string thermoTemplate = commandFilesDir.GetTestPath("20100329_Protea_Peptide_targeted.meth"); output = RunCommand("--in=" + docPath, "--exp-method-instrument=" + ExportInstrumentType.THERMO_TSQ, "--exp-template=" + thermoTemplate, "--exp-file=" + failurePath, "--exp-strategy=single", "--exp-method-type=triggered"); Assert.IsTrue(output.Contains(Resources.CommandLineTest_ConsoleAddFastaTest_Error)); // Thermo TSQ method Assert.IsFalse(output.Contains(Resources.CommandLineTest_ConsoleAddFastaTest_Warning)); Assert.AreEqual(2, CountInstances(ExportInstrumentType.THERMO, output)); // Thermo and Thermo TSQ Assert.AreEqual(1, CountInstances(ExportInstrumentType.THERMO_TSQ, output)); output = RunCommand("--in=" + docPath, "--exp-translist-instrument=" + ExportInstrumentType.AGILENT, "--exp-file=" + failurePath, "--exp-strategy=single", "--exp-method-type=triggered"); Assert.AreEqual(1, CountInstances(Resources.CommandLineTest_ConsoleAddFastaTest_Warning, output)); // exp-primary-count and CE not Agilent Assert.AreEqual(1, CountInstances(ExportInstrumentType.AGILENT, output)); // CE not Agilent Assert.IsTrue(output.Contains(Resources.CommandLine_ExportInstrumentFile_Error__triggered_acquistion_requires_a_spectral_library_or_imported_results_in_order_to_rank_transitions_)); // No library and no data // Successful export to Agilent transtion list string triggerPath = testFilesDir.GetTestPath("BSA_Protea_label_free_20100323_meth3_multi_triggered.sky"); string rawPath = testFilesDir.GetTestPath("ah_20101011y_BSA_MS-MS_only_5-2" + ExtensionTestContext.ExtThermoRaw); const string replicate = "Single"; string agilentTriggeredPath = testFilesDir.GetTestPath("AgilentTriggered.csv"); output = RunCommand("--in=" + docPath, "--import-file=" + rawPath, "--import-replicate-name=" + replicate, "--out=" + triggerPath, "--exp-translist-instrument=" + ExportInstrumentType.AGILENT, "--exp-file=" + agilentTriggeredPath, "--exp-strategy=single", "--exp-method-type=triggered"); Assert.AreEqual(1, CountInstances(Resources.CommandLineTest_ConsoleAddFastaTest_Warning, output)); // exp-primary-count and CE not Agilent Assert.AreEqual(1, CountInstances(ExportInstrumentType.AGILENT, output)); // CE not Agilent Assert.IsTrue(output.Contains(Resources.CommandLine_ExportInstrumentFile_Error__The_current_document_contains_peptides_without_enough_information_to_rank_transitions_for_triggered_acquisition_)); // peptides without enough information //check for success var doc = ResultsUtil.DeserializeDocument(triggerPath); var ceRegression = new CollisionEnergyRegression("Agilent", new[] {new ChargeRegressionLine(2, 2, 10)}); doc = doc.ChangeSettings(doc.Settings.ChangeTransitionPrediction( p => p.ChangeCollisionEnergy(ceRegression))); doc = (SrmDocument) doc.RemoveChild(doc.Children[1]); CommandLine.SaveDocument(doc, triggerPath, Console.Out); output = RunCommand("--in=" + triggerPath, "--exp-translist-instrument=" + ExportInstrumentType.AGILENT, "--exp-file=" + agilentTriggeredPath, "--exp-strategy=single", "--exp-method-type=triggered"); Assert.IsTrue(output.Contains(string.Format(Resources.CommandLine_ExportInstrumentFile_List__0__exported_successfully_, "AgilentTriggered.csv"))); Assert.IsFalse(output.Contains(Resources.CommandLineTest_ConsoleAddFastaTest_Error)); Assert.IsFalse(output.Contains(Resources.CommandLineTest_ConsoleAddFastaTest_Warning)); Assert.IsTrue(File.Exists(agilentTriggeredPath)); Assert.AreEqual(doc.PeptideTransitionCount + 1, File.ReadAllLines(agilentTriggeredPath).Length); }
public void CalcCollisionEnergy(CollisionEnergyRegression regression) { CollisionEnergy = regression.GetCollisionEnergy(PrecursorCharge, PrecursorMZ); }