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); }
public PeptideSettings ChangeFilter(PeptideFilter prop) { return ChangeProp(ImClone(this), im => im.Filter = prop); }
public bool Equals(PeptideFilter obj) { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; return obj.ExcludeNTermAAs == ExcludeNTermAAs && obj.MinPeptideLength == MinPeptideLength && obj.MaxPeptideLength == MaxPeptideLength && obj.AutoSelect.Equals(AutoSelect) && ArrayUtil.EqualsDeep(obj._exclusions, _exclusions); }
public PeptideSettings(Enzyme enzyme, DigestSettings digestSettings, PeptidePrediction prediction, PeptideFilter filter, PeptideLibraries libraries, PeptideModifications modifications, PeptideIntegration integration, BackgroundProteome backgroundProteome ) { Enzyme = enzyme; DigestSettings = digestSettings; Prediction = prediction; Filter = filter; Libraries = libraries; Modifications = modifications; Integration = integration; BackgroundProteome = backgroundProteome; Quantification = QuantificationSettings.DEFAULT; }