private void SaveButton_Click(object sender, RoutedEventArgs e) { #region Check Task Validity if (!int.TryParse(maxCandidatesPerSpectrumTextBox.Text, out int mcps) || mcps <= 0) { MessageBox.Show("The number of maximum candidates per spectra contains unrecognized characters. \n You entered " + '"' + maxCandidatesPerSpectrumTextBox.Text + '"' + "\n Please enter a positive number."); return; } if (!int.TryParse(maxMissedConsecutiveTextBox.Text, out int mmc) || mmc < 0) { MessageBox.Show("The number of maximum missed consecutive cleavages contains unrecognized characters. \n You entered " + '"' + maxMissedConsecutiveTextBox.Text + '"' + "\n Please enter a positive number."); return; } if (!int.TryParse(maxMissedTextBox.Text, out int mm) || mm <= 0) { MessageBox.Show("The number of maximum missed cleavages contains unrecognized characters. \n You entered " + '"' + maxMissedTextBox.Text + '"' + "\n Please enter a positive number."); return; } if (missedCleavagesTextBox.Text.Length == 0) { MessageBox.Show("The number of missed cleavages was left empty. For no missed cleavages, please enter zero."); return; } if ((!double.TryParse(productMassToleranceTextBox.Text, out double pmt) || pmt <= 0) && productMassToleranceTextBox.Text.Length != 0) { MessageBox.Show("The product mass tolerance contains unrecognized characters. \n You entered " + '"' + productMassToleranceTextBox.Text + '"' + "\n Please enter a positive number."); return; } if ((!double.TryParse(precursorMassToleranceTextBox.Text, out double premt) || premt <= 0) && precursorMassToleranceTextBox.Text.Length != 0) { MessageBox.Show("The precursor mass tolerance contains unrecognized characters. \n You entered " + '"' + precursorMassToleranceTextBox.Text + '"' + "\n Please enter a positive number."); return; } #endregion Check Task Validity #region Save Parameters CommonParameters CommonParamsToSave = new CommonParameters(); if (OutputFileNameTextBox.Text != "") { CommonParamsToSave.TaskDescriptor = OutputFileNameTextBox.Text; } else { CommonParamsToSave.TaskDescriptor = "NeoSearchTask"; } //Code for determining SemiSpecific NeoParameters neoParameters = new NeoParameters(); neoParameters.Calibrate = calibrate.IsChecked.Value; neoParameters.GPTMD = gptmd.IsChecked.Value; neoParameters.TargetSearch = searchTarget.IsChecked.Value; neoParameters.DecoySearch = searchDecoy.IsChecked.Value; neoParameters.SearchNTerminus = searchN.IsChecked.Value; neoParameters.SearchCTerminus = searchC.IsChecked.Value; neoParameters.MaxMissedConsecutiveCleavages = int.Parse(maxMissedConsecutiveTextBox.Text); neoParameters.MaxMissedCleavages = int.Parse(maxMissedConsecutiveTextBox.Text); neoParameters.MaxCandidatesPerSpectrum = int.Parse(maxMissedConsecutiveTextBox.Text); neoParameters.MinDistanceAllowed = int.Parse(minCisLengthTextBox.Text); neoParameters.MaxDistanceAllowed = int.Parse(maxCisLengthTextBox.Text); neoParameters.NormalCis = searchNormalCis.IsChecked.Value; neoParameters.ReverseCis = searchReverseCis.IsChecked.Value; if (!searchTarget.IsChecked.Value) { neoParameters.TargetFilePath = targetPath.Text; } if (!searchDecoy.IsChecked.Value) { neoParameters.DecoyFilePath = decoyPath.Text; } if (!searchN.IsChecked.Value) { neoParameters.NFilePath = NPath.Text; } if (!searchC.IsChecked.Value) { neoParameters.CFilePath = CPath.Text; } DigestionParams digestionParamsToSave = new DigestionParams(); digestionParamsToSave.MaxMissedCleavages = int.Parse(missedCleavagesTextBox.Text, CultureInfo.InvariantCulture); digestionParamsToSave.MinPeptideLength = int.TryParse(txtMinPeptideLength.Text, NumberStyles.Any, CultureInfo.InvariantCulture, out int temp) ? (int?)temp : null; digestionParamsToSave.MaxPeptideLength = int.TryParse(txtMaxPeptideLength.Text, NumberStyles.Any, CultureInfo.InvariantCulture, out temp) ? (int?)temp : null; digestionParamsToSave.Protease = (Protease)proteaseComboBox.SelectedItem; digestionParamsToSave.MaxModificationIsoforms = int.Parse(maxModificationIsoformsTextBox.Text, CultureInfo.InvariantCulture); digestionParamsToSave.MaxModsForPeptide = int.Parse(txtMaxModNum.Text, CultureInfo.InvariantCulture); digestionParamsToSave.InitiatorMethionineBehavior = (InitiatorMethionineBehavior)initiatorMethionineBehaviorComboBox.SelectedIndex; CommonParamsToSave.DigestionParams = digestionParamsToSave; CommonParamsToSave.BIons = bCheckBox.IsChecked.Value; CommonParamsToSave.YIons = yCheckBox.IsChecked.Value; CommonParamsToSave.CIons = cCheckBox.IsChecked.Value; CommonParamsToSave.ZdotIons = zdotCheckBox.IsChecked.Value; if (productMassToleranceComboBox.SelectedIndex == 0) { CommonParamsToSave.ProductMassTolerance = new AbsoluteTolerance(double.Parse(productMassToleranceTextBox.Text, CultureInfo.InvariantCulture)); } else if (productMassToleranceTextBox.Text.Length == 0 || precursorMassToleranceTextBox.Text.Length == 0) { CommonParamsToSave.ProductMassTolerance = new PpmTolerance(25); } else { CommonParamsToSave.ProductMassTolerance = new PpmTolerance(double.Parse(productMassToleranceTextBox.Text, CultureInfo.InvariantCulture)); } if (precursorMassToleranceComboBox.SelectedIndex == 0) { CommonParamsToSave.PrecursorMassTolerance = new AbsoluteTolerance(double.Parse(precursorMassToleranceTextBox.Text, CultureInfo.InvariantCulture)); } else if (productMassToleranceTextBox.Text.Length == 0 || precursorMassToleranceTextBox.Text.Length == 0) { CommonParamsToSave.PrecursorMassTolerance = new PpmTolerance(15); } else { CommonParamsToSave.PrecursorMassTolerance = new PpmTolerance(double.Parse(precursorMassToleranceTextBox.Text, CultureInfo.InvariantCulture)); } var listOfModsVariable = new List <(string, string)>(); foreach (var heh in variableModTypeForTreeViewObservableCollection) { listOfModsVariable.AddRange(heh.Children.Where(b => b.Use).Select(b => (b.Parent.DisplayName, b.DisplayName))); } CommonParamsToSave.ListOfModsVariable = listOfModsVariable; var listOfModsFixed = new List <(string, string)>(); foreach (var heh in fixedModTypeForTreeViewObservableCollection) { listOfModsFixed.AddRange(heh.Children.Where(b => b.Use).Select(b => (b.Parent.DisplayName, b.DisplayName))); } CommonParamsToSave.ListOfModsFixed = listOfModsFixed; if (localizeAllCheckBox.IsChecked.Value) { CommonParamsToSave.ListOfModTypesLocalize = null; CommonParamsToSave.LocalizeAll = true; } else { CommonParamsToSave.LocalizeAll = false; CommonParamsToSave.ListOfModTypesLocalize = localizeModTypeForTreeViewObservableCollection.Where(b => b.Use.HasValue && b.Use.Value).Select(b => b.DisplayName).ToList(); } TheTask.NeoParameters = neoParameters; TheTask.CommonParameters = CommonParamsToSave; #endregion Save Parameters DialogResult = true; }
private void SaveButton_Click(object sender, RoutedEventArgs e) { if (!int.TryParse(maxCandidatesPerSpectrumTextBox.Text, out int mcps) || mcps <= 0) { MessageBox.Show("The number of maximum candidates per spectra contains unrecognized characters. \n You entered " + '"' + maxCandidatesPerSpectrumTextBox.Text + '"' + "\n Please enter a positive number."); return; } if (!int.TryParse(maxMissedConsecutiveTextBox.Text, out int mmc) || mmc < 0) { MessageBox.Show("The number of maximum missed consecutive cleavages contains unrecognized characters. \n You entered " + '"' + maxMissedConsecutiveTextBox.Text + '"' + "\n Please enter a positive number."); return; } if (!int.TryParse(maxMissedTextBox.Text, out int mm) || mm <= 0) { MessageBox.Show("The number of maximum missed cleavages contains unrecognized characters. \n You entered " + '"' + maxMissedTextBox.Text + '"' + "\n Please enter a positive number."); return; } if (missedCleavagesTextBox.Text.Length == 0) { MessageBox.Show("The number of missed cleavages was left empty. For no missed cleavages, please enter zero."); return; } if ((!double.TryParse(productMassToleranceTextBox.Text, out double pmt) || pmt <= 0) && productMassToleranceTextBox.Text.Length != 0) { MessageBox.Show("The product mass tolerance contains unrecognized characters. \n You entered " + '"' + productMassToleranceTextBox.Text + '"' + "\n Please enter a positive number."); return; } if ((!double.TryParse(precursorMassToleranceTextBox.Text, out double premt) || premt <= 0) && precursorMassToleranceTextBox.Text.Length != 0) { MessageBox.Show("The precursor mass tolerance contains unrecognized characters. \n You entered " + '"' + precursorMassToleranceTextBox.Text + '"' + "\n Please enter a positive number."); return; } //Code for determining SemiSpecific NeoParameters neoParameters = new NeoParameters { Calibrate = calibrate.IsChecked.Value, GPTMD = gptmd.IsChecked.Value, TargetSearch = searchTarget.IsChecked.Value, DecoySearch = searchDecoy.IsChecked.Value, SearchNTerminus = searchN.IsChecked.Value, SearchCTerminus = searchC.IsChecked.Value, MaxMissedConsecutiveCleavages = int.Parse(maxMissedConsecutiveTextBox.Text), MaxMissedCleavages = int.Parse(maxMissedConsecutiveTextBox.Text), MaxCandidatesPerSpectrum = int.Parse(maxMissedConsecutiveTextBox.Text), MinDistanceAllowed = int.Parse(minCisLengthTextBox.Text), MaxDistanceAllowed = int.Parse(maxCisLengthTextBox.Text), NormalCis = searchNormalCis.IsChecked.Value, ReverseCis = searchReverseCis.IsChecked.Value }; if (!searchTarget.IsChecked.Value) { neoParameters.TargetFilePath = targetPath.Text; } if (!searchDecoy.IsChecked.Value) { neoParameters.DecoyFilePath = decoyPath.Text; } if (!searchN.IsChecked.Value) { neoParameters.NFilePath = NPath.Text; } if (!searchC.IsChecked.Value) { neoParameters.CFilePath = CPath.Text; } Protease protease = (Protease)proteaseComboBox.SelectedItem; int maxMissedCleavages = (int.Parse(missedCleavagesTextBox.Text, CultureInfo.InvariantCulture)); int minPeptideLength = (int.Parse(txtMinPeptideLength.Text, NumberStyles.Any, CultureInfo.InvariantCulture)); int maxPeptideLength = (int.Parse(txtMaxPeptideLength.Text, NumberStyles.Any, CultureInfo.InvariantCulture)); int maxModificationIsoforms = (int.Parse(maxModificationIsoformsTextBox.Text, CultureInfo.InvariantCulture)); int maxModsForPeptide = (int.Parse(txtMaxModNum.Text, CultureInfo.InvariantCulture)); InitiatorMethionineBehavior initiatorMethionineBehavior = (InitiatorMethionineBehavior)initiatorMethionineBehaviorComboBox.SelectedIndex; DigestionParams digestionParamsToSave = new DigestionParams( protease: protease.Name, maxMissedCleavages: maxMissedCleavages, minPeptideLength: minPeptideLength, maxPeptideLength: maxPeptideLength, maxModificationIsoforms: maxModificationIsoforms, initiatorMethionineBehavior: initiatorMethionineBehavior, maxModsForPeptides: maxModsForPeptide); Tolerance ProductMassTolerance; if (productMassToleranceComboBox.SelectedIndex == 0) { ProductMassTolerance = new AbsoluteTolerance(double.Parse(productMassToleranceTextBox.Text, CultureInfo.InvariantCulture)); } else if (productMassToleranceTextBox.Text.Length == 0 || precursorMassToleranceTextBox.Text.Length == 0) { ProductMassTolerance = new PpmTolerance(25); } else { ProductMassTolerance = new PpmTolerance(double.Parse(productMassToleranceTextBox.Text, CultureInfo.InvariantCulture)); } Tolerance PrecursorMassTolerance; if (precursorMassToleranceComboBox.SelectedIndex == 0) { PrecursorMassTolerance = new AbsoluteTolerance(double.Parse(precursorMassToleranceTextBox.Text, CultureInfo.InvariantCulture)); } else if (productMassToleranceTextBox.Text.Length == 0 || precursorMassToleranceTextBox.Text.Length == 0) { PrecursorMassTolerance = new PpmTolerance(15); } else { PrecursorMassTolerance = new PpmTolerance(double.Parse(precursorMassToleranceTextBox.Text, CultureInfo.InvariantCulture)); } var listOfModsVariable = new List <(string, string)>(); foreach (var heh in VariableModTypeForTreeViewObservableCollection) { listOfModsVariable.AddRange(heh.Children.Where(b => b.Use).Select(b => (b.Parent.DisplayName, b.DisplayName))); } var listOfModsFixed = new List <(string, string)>(); foreach (var heh in FixedModTypeForTreeViewObservableCollection) { listOfModsFixed.AddRange(heh.Children.Where(b => b.Use).Select(b => (b.Parent.DisplayName, b.DisplayName))); } CommonParameters commonParamsToSave = new CommonParameters( taskDescriptor: OutputFileNameTextBox.Text != "" ? OutputFileNameTextBox.Text : "NeoSearchTask", digestionParams: digestionParamsToSave, bIons: bCheckBox.IsChecked.Value, yIons: yCheckBox.IsChecked.Value, cIons: cCheckBox.IsChecked.Value, zDotIons: zdotCheckBox.IsChecked.Value, productMassTolerance: ProductMassTolerance, precursorMassTolerance: PrecursorMassTolerance, listOfModsFixed: listOfModsFixed, listOfModsVariable: listOfModsVariable); TheTask.NeoParameters = neoParameters; TheTask.CommonParameters = commonParamsToSave; DialogResult = true; }