コード例 #1
0
 private void CheckIfNumber(object sender, TextCompositionEventArgs e)
 {
     e.Handled = !GlobalGuiSettings.CheckIsNumber(e.Text);
 }
コード例 #2
0
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            string fieldNotUsed = "1";

            if (!GlobalGuiSettings.CheckTaskSettingsValidity(XLPrecusorMsTlTextBox.Text, productMassToleranceTextBox.Text, missedCleavagesTextBox.Text,
                                                             maxModificationIsoformsTextBox.Text, MinPeptideLengthTextBox.Text, MaxPeptideLengthTextBox.Text, maxThreadsTextBox.Text, minScoreAllowed.Text,
                                                             fieldNotUsed, fieldNotUsed, fieldNotUsed, TopNPeaksTextBox.Text, MinRatioTextBox.Text, null, null, numberOfDatabaseSearchesTextBox.Text, fieldNotUsed, fieldNotUsed, fieldNotUsed))
            {
                return;
            }

            DissociationType dissociationType         = GlobalVariables.AllSupportedDissociationTypes[DissociationTypeComboBox.SelectedItem.ToString()];
            string           separationType           = SeparationTypeComboBox.SelectedItem.ToString();
            DissociationType ms2childDissociationType = DissociationType.Unknown;

            if (MS2ChildScanDissociationTypeComboBox.SelectedItem.ToString() != "Null")
            {
                ms2childDissociationType = GlobalVariables.AllSupportedDissociationTypes[MS2ChildScanDissociationTypeComboBox.SelectedItem.ToString()];
            }
            DissociationType ms3childDissociationType = DissociationType.Unknown;

            if (MS3ChildScanDissociationTypeComboBox.SelectedItem.ToString() != "Null")
            {
                ms3childDissociationType = GlobalVariables.AllSupportedDissociationTypes[MS3ChildScanDissociationTypeComboBox.SelectedItem.ToString()];
            }

            CustomFragmentationWindow.Close();

            TheTask.XlSearchParameters.CrosslinkSearchTopNum   = int.Parse(txtXLTopNum.Text, CultureInfo.InvariantCulture);
            TheTask.XlSearchParameters.CrosslinkAtCleavageSite = ckbCrosslinkAtCleavageSite.IsChecked.Value;
            TheTask.XlSearchParameters.Crosslinker             = (Crosslinker)cbCrosslinkers.SelectedItem;

            TheTask.XlSearchParameters.XlQuench_H2O  = ckbQuenchH2O.IsChecked.Value;
            TheTask.XlSearchParameters.XlQuench_NH2  = ckbQuenchNH2.IsChecked.Value;
            TheTask.XlSearchParameters.XlQuench_Tris = ckbQuenchTris.IsChecked.Value;


            TheTask.XlSearchParameters.DecoyType = checkBoxDecoy.IsChecked.Value ? DecoyType.Reverse : DecoyType.None;

            Protease protease                = (Protease)proteaseComboBox.SelectedItem;
            int      MaxMissedCleavages      = string.IsNullOrEmpty(missedCleavagesTextBox.Text) ? int.MaxValue : (int.Parse(missedCleavagesTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture));
            int      MinPeptideLength        = (int.Parse(MinPeptideLengthTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture));
            int      MaxPeptideLength        = string.IsNullOrEmpty(MaxPeptideLengthTextBox.Text) ? int.MaxValue : (int.Parse(MaxPeptideLengthTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture));
            int      MaxModificationIsoforms = (int.Parse(maxModificationIsoformsTextBox.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);

            Tolerance ProductMassTolerance;

            if (productMassToleranceComboBox.SelectedIndex == 0)
            {
                ProductMassTolerance = new AbsoluteTolerance(double.Parse(productMassToleranceTextBox.Text, CultureInfo.InvariantCulture));
            }
            else
            {
                ProductMassTolerance = new PpmTolerance(double.Parse(productMassToleranceTextBox.Text, CultureInfo.InvariantCulture));
            }

            Tolerance PrecursorMassTolerance;

            if (cbbXLprecusorMsTl.SelectedIndex == 0)
            {
                PrecursorMassTolerance = new AbsoluteTolerance(double.Parse(XLPrecusorMsTlTextBox.Text, CultureInfo.InvariantCulture));
            }
            else
            {
                PrecursorMassTolerance = new PpmTolerance(double.Parse(XLPrecusorMsTlTextBox.Text, CultureInfo.InvariantCulture));
            }

            TheTask.XlSearchParameters.WritePepXml = ckbPepXML.IsChecked.Value;

            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.ModName)));
            }

            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.ModName)));
            }

            CommonParameters commonParamsToSave = new CommonParameters(
                precursorMassTolerance: PrecursorMassTolerance,
                taskDescriptor: OutputFileNameTextBox.Text != "" ? OutputFileNameTextBox.Text : "XLSearchTask",
                productMassTolerance: ProductMassTolerance,
                doPrecursorDeconvolution: deconvolutePrecursors.IsChecked.Value,
                useProvidedPrecursorInfo: useProvidedPrecursor.IsChecked.Value,
                digestionParams: digestionParamsToSave,
                trimMs1Peaks: trimMs1.IsChecked.Value,
                trimMsMsPeaks: trimMsMs.IsChecked.Value,
                numberOfPeaksToKeepPerWindow: int.Parse(TopNPeaksTextBox.Text),
                minimumAllowedIntensityRatioToBasePeak: double.Parse(MinRatioTextBox.Text, CultureInfo.InvariantCulture),
                dissociationType: dissociationType,
                separationType: separationType,

                ms2childScanDissociationType: ms2childDissociationType,
                ms3childScanDissociationType: ms3childDissociationType,
                scoreCutoff: double.Parse(minScoreAllowed.Text, CultureInfo.InvariantCulture),
                totalPartitions: int.Parse(numberOfDatabaseSearchesTextBox.Text, CultureInfo.InvariantCulture),
                listOfModsVariable: listOfModsVariable,
                listOfModsFixed: listOfModsFixed,
                assumeOrphanPeaksAreZ1Fragments: protease.Name != "top-down");

            TheTask.CommonParameters = commonParamsToSave;

            DialogResult = true;
        }
コード例 #3
0
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            CleavageSpecificity searchModeType = CleavageSpecificity.Full; //classic and modern by default

            if (semiSpecificSearchRadioButton.IsChecked.Value)             //semi
            {
                searchModeType = CleavageSpecificity.Semi;
            }
            else if (nonSpecificSearchRadioButton.IsChecked.Value) //non
            {
                searchModeType = CleavageSpecificity.None;
            }
            //else it's the default of full

            if (searchModeType != CleavageSpecificity.Full)
            {
                if (((Protease)proteaseComboBox.SelectedItem).Name.Contains("non-specific"))
                {
                    searchModeType = CleavageSpecificity.None; //prevents an accidental semi attempt of a non-specific protease

                    if (cTerminalIons.IsChecked.Value)
                    {
                        Protease singleC = ProteaseDictionary.Dictionary["singleC"];
                        proteaseComboBox.SelectedItem = singleC;
                    }
                    else //we're not allowing no ion types. It must have N if it doesn't have C.
                    {
                        Protease singleN = ProteaseDictionary.Dictionary["singleN"];
                        proteaseComboBox.SelectedItem = singleN;
                    }
                }
                if (!addCompIonCheckBox.IsChecked.Value)
                {
                    MessageBox.Show("Warning: Complementary ions are strongly recommended when using this algorithm.");
                }
                //only use N or C termini, not both
                if (cTerminalIons.IsChecked.Value)
                {
                    nTerminalIons.IsChecked = false;
                }
                else
                {
                    nTerminalIons.IsChecked = true;
                }
            }

            if (!GlobalGuiSettings.CheckTaskSettingsValidity(precursorMassToleranceTextBox.Text, productMassToleranceTextBox.Text, missedCleavagesTextBox.Text,
                                                             maxModificationIsoformsTextBox.Text, MinPeptideLengthTextBox.Text, MaxPeptideLengthTextBox.Text, maxThreadsTextBox.Text, minScoreAllowed.Text,
                                                             peakFindingToleranceTextBox.Text, histogramBinWidthTextBox.Text, DeconvolutionMaxAssumedChargeStateTextBox.Text, NumberOfPeaksToKeepPerWindowTextBox.Text,
                                                             MinimumAllowedIntensityRatioToBasePeakTexBox.Text, WindowWidthThomsonsTextBox.Text, NumberOfWindowsTextBox.Text, numberOfDatabaseSearchesTextBox.Text, MaxModNumTextBox.Text, MaxFragmentMassTextBox.Text, QValueTextBox.Text))
            {
                return;
            }

            Protease protease = (Protease)proteaseComboBox.SelectedItem;

            DissociationType dissociationType = GlobalVariables.AllSupportedDissociationTypes[dissociationTypeComboBox.SelectedItem.ToString()];

            CustomFragmentationWindow.Close();

            FragmentationTerminus fragmentationTerminus = FragmentationTerminus.Both;

            if (nTerminalIons.IsChecked.Value && !cTerminalIons.IsChecked.Value)
            {
                fragmentationTerminus = FragmentationTerminus.N;
            }
            else if (!nTerminalIons.IsChecked.Value && cTerminalIons.IsChecked.Value)
            {
                fragmentationTerminus = FragmentationTerminus.C;
            }
            else if (!nTerminalIons.IsChecked.Value && !cTerminalIons.IsChecked.Value) //why would you want this
            {
                fragmentationTerminus = FragmentationTerminus.None;
                MessageBox.Show("Warning: No ion types were selected. MetaMorpheus will be unable to search MS/MS spectra.");
            }
            //else both

            int maxMissedCleavages           = string.IsNullOrEmpty(missedCleavagesTextBox.Text) ? int.MaxValue : (int.Parse(missedCleavagesTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture));
            int minPeptideLengthValue        = (int.Parse(MinPeptideLengthTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture));
            int maxPeptideLengthValue        = string.IsNullOrEmpty(MaxPeptideLengthTextBox.Text) ? int.MaxValue : (int.Parse(MaxPeptideLengthTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture));
            int MinVariantDepth              = int.Parse(MinVariantDepthTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture);
            int MaxHeterozygousVariants      = int.Parse(MaxHeterozygousVariantsTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture);
            int maxModificationIsoformsValue = (int.Parse(maxModificationIsoformsTextBox.Text, CultureInfo.InvariantCulture));
            int maxModsForPeptideValue       = (int.Parse(MaxModNumTextBox.Text, CultureInfo.InvariantCulture));
            InitiatorMethionineBehavior initiatorMethionineBehavior = ((InitiatorMethionineBehavior)initiatorMethionineBehaviorComboBox.SelectedIndex);

            DigestionParams digestionParamsToSave = new DigestionParams(
                protease: protease.Name,
                maxMissedCleavages: maxMissedCleavages,
                minPeptideLength: minPeptideLengthValue,
                maxPeptideLength: maxPeptideLengthValue,
                maxModificationIsoforms: maxModificationIsoformsValue,
                initiatorMethionineBehavior: initiatorMethionineBehavior,
                maxModsForPeptides: maxModsForPeptideValue,
                searchModeType: searchModeType,
                fragmentationTerminus: fragmentationTerminus,
                generateUnlabeledProteinsForSilac: CheckBoxQuantifyUnlabeledForSilac.IsChecked.Value);

            Tolerance ProductMassTolerance;

            if (productMassToleranceComboBox.SelectedIndex == 0)
            {
                ProductMassTolerance = new AbsoluteTolerance(double.Parse(productMassToleranceTextBox.Text, CultureInfo.InvariantCulture));
            }
            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
            {
                PrecursorMassTolerance = new PpmTolerance(double.Parse(precursorMassToleranceTextBox.Text, CultureInfo.InvariantCulture));
            }
            TheTask.SearchParameters.MaxFragmentSize = Double.Parse(MaxFragmentMassTextBox.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.ModName)));
            }

            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.ModName)));
            }

            if (!GlobalGuiSettings.VariableModCheck(listOfModsVariable))
            {
                return;
            }

            bool TrimMs1Peaks  = trimMs1.IsChecked.Value;
            bool TrimMsMsPeaks = trimMsMs.IsChecked.Value;

            int?numPeaksToKeep = null;

            if (int.TryParse(NumberOfPeaksToKeepPerWindowTextBox.Text, out int numberOfPeaksToKeeep))
            {
                numPeaksToKeep = numberOfPeaksToKeeep;
            }

            double?minimumAllowedIntensityRatioToBasePeak = null;

            if (double.TryParse(MinimumAllowedIntensityRatioToBasePeakTexBox.Text, out double minimumAllowedIntensityRatio))
            {
                minimumAllowedIntensityRatioToBasePeak = minimumAllowedIntensityRatio;
            }

            double?windowWidthThompsons = null;

            if (double.TryParse(WindowWidthThomsonsTextBox.Text, out double windowWidth))
            {
                windowWidthThompsons = windowWidth;
            }

            int?numberOfWindows = null;

            if (int.TryParse(NumberOfWindowsTextBox.Text, out int numWindows))
            {
                numberOfWindows = numWindows;
            }

            bool normalizePeaksAccrossAllWindows = normalizePeaksInWindowCheckBox.IsChecked.Value;

            bool parseMaxThreadsPerFile = !maxThreadsTextBox.Text.Equals("") && (int.Parse(maxThreadsTextBox.Text) <= Environment.ProcessorCount && int.Parse(maxThreadsTextBox.Text) > 0);

            CommonParameters commonParamsToSave = new CommonParameters(
                taskDescriptor: OutputFileNameTextBox.Text != "" ? OutputFileNameTextBox.Text : "SearchTask",
                maxThreadsToUsePerFile: parseMaxThreadsPerFile ? int.Parse(maxThreadsTextBox.Text, CultureInfo.InvariantCulture) : new CommonParameters().MaxThreadsToUsePerFile,
                useDeltaScore: deltaScoreCheckBox.IsChecked.Value,
                reportAllAmbiguity: allAmbiguity.IsChecked.Value,
                deconvolutionMaxAssumedChargeState: int.Parse(DeconvolutionMaxAssumedChargeStateTextBox.Text, CultureInfo.InvariantCulture),
                totalPartitions: int.Parse(numberOfDatabaseSearchesTextBox.Text, CultureInfo.InvariantCulture),
                doPrecursorDeconvolution: deconvolutePrecursors.IsChecked.Value,
                useProvidedPrecursorInfo: useProvidedPrecursor.IsChecked.Value,
                scoreCutoff: double.Parse(minScoreAllowed.Text, CultureInfo.InvariantCulture),
                listOfModsFixed: listOfModsFixed,
                listOfModsVariable: listOfModsVariable,
                dissociationType: dissociationType,
                precursorMassTolerance: PrecursorMassTolerance,
                productMassTolerance: ProductMassTolerance,
                digestionParams: digestionParamsToSave,
                trimMs1Peaks: TrimMs1Peaks,
                trimMsMsPeaks: TrimMsMsPeaks,
                numberOfPeaksToKeepPerWindow: numPeaksToKeep,
                minimumAllowedIntensityRatioToBasePeak: minimumAllowedIntensityRatioToBasePeak,
                windowWidthThomsons: windowWidthThompsons,
                numberOfWindows: numberOfWindows,                                 //maybe change this some day
                normalizePeaksAccrossAllWindows: normalizePeaksAccrossAllWindows, //maybe change this some day
                addCompIons: addCompIonCheckBox.IsChecked.Value,
                qValueOutputFilter: QValueCheckBox.IsChecked.Value ? double.Parse(QValueTextBox.Text, CultureInfo.InvariantCulture) : 1.0,
                assumeOrphanPeaksAreZ1Fragments: protease.Name != "top-down",
                minVariantDepth: MinVariantDepth,
                maxHeterozygousVariants: MaxHeterozygousVariants);

            if (classicSearchRadioButton.IsChecked.Value)
            {
                TheTask.SearchParameters.SearchType = SearchType.Classic;
            }
            else if (modernSearchRadioButton.IsChecked.Value)
            {
                TheTask.SearchParameters.SearchType = SearchType.Modern;
            }
            else //both semi and nonspecific are termed "nonspecific", because they both contain at least one nonspecific cleavage and they share the same algorithm
            {
                TheTask.SearchParameters.SearchType = SearchType.NonSpecific;
            }

            TheTask.SearchParameters.DoParsimony      = checkBoxParsimony.IsChecked.Value;
            TheTask.SearchParameters.NoOneHitWonders  = checkBoxNoOneHitWonders.IsChecked.Value;
            TheTask.SearchParameters.DoQuantification = !checkBoxNoQuant.IsChecked.Value;

            //SilacLabel deconvolution
            {
                if (StaticSilacLabelsObservableCollection.Count == 0)
                {
                    TheTask.SearchParameters.SilacLabels = null;
                }
                else
                {
                    List <Proteomics.SilacLabel> labelsToSave = new List <Proteomics.SilacLabel>();
                    foreach (SilacInfoForDataGrid info in StaticSilacLabelsObservableCollection)
                    {
                        Proteomics.SilacLabel labelToAdd = info.SilacLabel[0];

                        //This is needed to prevent double adding of additional labels.
                        //A quick test is to create a silac condition with two labels, save, reopen the task, save, and reopen again.
                        //Without this line, the second label will be doubled (K+8)&(R+10)&(R+10)
                        if (labelToAdd.AdditionalLabels != null)
                        {
                            labelToAdd.AdditionalLabels.Clear();
                        }

                        for (int infoIndex = 1; infoIndex < info.SilacLabel.Count; infoIndex++)
                        {
                            labelToAdd.AddAdditionalSilacLabel(info.SilacLabel[infoIndex]);
                        }
                        labelsToSave.Add(labelToAdd);
                    }
                    TheTask.SearchParameters.SilacLabels = labelsToSave;
                }
            }

            TheTask.SearchParameters.Normalize               = checkBoxNormalize.IsChecked.Value;
            TheTask.SearchParameters.MatchBetweenRuns        = checkBoxMatchBetweenRuns.IsChecked.Value;
            TheTask.SearchParameters.ModPeptidesAreDifferent = modPepsAreUnique.IsChecked.Value;
            TheTask.SearchParameters.QuantifyPpmTol          = double.Parse(peakFindingToleranceTextBox.Text, CultureInfo.InvariantCulture);
            TheTask.SearchParameters.SearchTarget            = checkBoxTarget.IsChecked.Value;
            TheTask.SearchParameters.WriteMzId               = ckbMzId.IsChecked.Value;
            TheTask.SearchParameters.WriteDecoys             = writeDecoyCheckBox.IsChecked.Value;
            TheTask.SearchParameters.WriteContaminants       = writeContaminantCheckBox.IsChecked.Value;
            //TheTask.SearchParameters.OutPepXML = ckbPepXML.IsChecked.Value;

            if (checkBoxDecoy.IsChecked.Value)
            {
                if (radioButtonReverseDecoy.IsChecked.Value)
                {
                    TheTask.SearchParameters.DecoyType = DecoyType.Reverse;
                }
                else //if (radioButtonSlideDecoy.IsChecked.Value)
                {
                    TheTask.SearchParameters.DecoyType = DecoyType.Slide;
                }
            }
            else
            {
                TheTask.SearchParameters.DecoyType = DecoyType.None;
            }

            if (massDiffAcceptExact.IsChecked.HasValue && massDiffAcceptExact.IsChecked.Value)
            {
                TheTask.SearchParameters.MassDiffAcceptorType = MassDiffAcceptorType.Exact;
            }
            if (massDiffAccept1mm.IsChecked.HasValue && massDiffAccept1mm.IsChecked.Value)
            {
                TheTask.SearchParameters.MassDiffAcceptorType = MassDiffAcceptorType.OneMM;
            }
            if (massDiffAccept2mm.IsChecked.HasValue && massDiffAccept2mm.IsChecked.Value)
            {
                TheTask.SearchParameters.MassDiffAcceptorType = MassDiffAcceptorType.TwoMM;
            }
            if (massDiffAccept3mm.IsChecked.HasValue && massDiffAccept3mm.IsChecked.Value)
            {
                TheTask.SearchParameters.MassDiffAcceptorType = MassDiffAcceptorType.ThreeMM;
            }
            if (massDiffAccept187.IsChecked.HasValue && massDiffAccept187.IsChecked.Value)
            {
                TheTask.SearchParameters.MassDiffAcceptorType = MassDiffAcceptorType.ModOpen;
            }
            if (massDiffAcceptOpen.IsChecked.HasValue && massDiffAcceptOpen.IsChecked.Value)
            {
                TheTask.SearchParameters.MassDiffAcceptorType = MassDiffAcceptorType.Open;
            }
            if (massDiffAcceptCustom.IsChecked.HasValue && massDiffAcceptCustom.IsChecked.Value)
            {
                try
                {
                    MassDiffAcceptor customMassDiffAcceptor = SearchTask.GetMassDiffAcceptor(null, MassDiffAcceptorType.Custom, customkMdacTextBox.Text);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Could not parse custom mass difference acceptor: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                TheTask.SearchParameters.MassDiffAcceptorType = MassDiffAcceptorType.Custom;
                TheTask.SearchParameters.CustomMdac           = customkMdacTextBox.Text;
            }

            //determine if semi or nonspecific with a specific protease.
            if (searchModeType == CleavageSpecificity.Semi || protease.CleavageSpecificity == CleavageSpecificity.Semi)
            {
                TheTask.SearchParameters.LocalFdrCategories = new List <FdrCategory> {
                    FdrCategory.FullySpecific, FdrCategory.SemiSpecific
                };
            }
            else if (searchModeType == CleavageSpecificity.None && protease.CleavageSpecificity != CleavageSpecificity.None)
            {
                TheTask.SearchParameters.LocalFdrCategories = new List <FdrCategory> {
                    FdrCategory.FullySpecific, FdrCategory.SemiSpecific, FdrCategory.NonSpecific
                };
            }
            else
            {
                TheTask.SearchParameters.LocalFdrCategories = new List <FdrCategory> {
                    FdrCategory.FullySpecific
                };
            }

            // displays warning if classic search is enabled with an open search mode
            if (TheTask.SearchParameters.SearchType == SearchType.Classic &&
                (TheTask.SearchParameters.MassDiffAcceptorType == MassDiffAcceptorType.ModOpen || TheTask.SearchParameters.MassDiffAcceptorType == MassDiffAcceptorType.Open))
            {
                MessageBoxResult result = MessageBox.Show("Modern Search mode is recommended when conducting open precursor mass searches to reduce search time.\n\n" +
                                                          "Continue anyway?", "Modern search recommended", MessageBoxButton.OKCancel);

                if (result == MessageBoxResult.Cancel)
                {
                    return;
                }
            }

            TheTask.SearchParameters.DoHistogramAnalysis      = checkBoxHistogramAnalysis.IsChecked.Value;
            TheTask.SearchParameters.HistogramBinTolInDaltons = double.Parse(histogramBinWidthTextBox.Text, CultureInfo.InvariantCulture);

            TheTask.SearchParameters.WritePrunedDatabase = writePrunedDBCheckBox.IsChecked.Value;

            SetModSelectionForPrunedDB();

            TheTask.CommonParameters = commonParamsToSave;

            DialogResult = true;
        }
コード例 #4
0
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            string fieldNotUsed = "1";

            if (!GlobalGuiSettings.CheckTaskSettingsValidity(PrecursorMassToleranceTextBox.Text, ProductMassToleranceTextBox.Text, MissedCleavagesTextBox.Text,
                                                             MaxModificationIsoformsTextBox.Text, MinPeptideLengthTextBox.Text, MaxPeptideLengthTextBox.Text, MaxThreadsTextBox.Text, MinScoreAllowed.Text,
                                                             fieldNotUsed, fieldNotUsed, DeconvolutionMaxAssumedChargeStateTextBox.Text, NumberOfPeaksToKeepPerWindowTextBox.Text, MinimumAllowedIntensityRatioToBasePeakTexBox.Text, null, null, fieldNotUsed, fieldNotUsed, fieldNotUsed, fieldNotUsed))
            {
                return;
            }

            Protease protease                = (Protease)ProteaseComboBox.SelectedItem;
            int      maxMissedCleavages      = string.IsNullOrEmpty(MissedCleavagesTextBox.Text) ? int.MaxValue : (int.Parse(MissedCleavagesTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture));
            int      minPeptideLength        = int.Parse(MinPeptideLengthTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture);
            int      maxPeptideLength        = string.IsNullOrEmpty(MaxPeptideLengthTextBox.Text) ? int.MaxValue : (int.Parse(MaxPeptideLengthTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture));
            int      minVariantDepth         = int.Parse(MinVariantDepthTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture);
            int      maxHeterozygousVariants = int.Parse(MaxHeterozygousVariantsTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture);
            int      maxModificationIsoforms = int.Parse(MaxModificationIsoformsTextBox.Text, CultureInfo.InvariantCulture);
            int      maxModsPerPeptide       = int.Parse(MaxModsPerPeptideTextBox.Text, CultureInfo.InvariantCulture);
            InitiatorMethionineBehavior initiatorMethionineBehavior = (InitiatorMethionineBehavior)InitiatorMethionineBehaviorComboBox.SelectedIndex;
            DissociationType            dissociationType            = GlobalVariables.AllSupportedDissociationTypes[DissociationTypeComboBox.SelectedItem.ToString()];

            CustomFragmentationWindow.Close();

            Tolerance productMassTolerance;

            if (ProductMassToleranceComboBox.SelectedIndex == 0)
            {
                productMassTolerance = new AbsoluteTolerance(double.Parse(ProductMassToleranceTextBox.Text, CultureInfo.InvariantCulture));
            }
            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
            {
                precursorMassTolerance = new PpmTolerance(double.Parse(PrecursorMassToleranceTextBox.Text, CultureInfo.InvariantCulture));
            }

            List <(string, string)> listOfModsVariable = new List <(string, string)>();

            foreach (var heh in variableModTypeForTreeViewObservableCollection)
            {
                listOfModsVariable.AddRange(heh.Children.Where(b => b.Use).Select(b => (b.Parent.DisplayName, b.ModName)));
            }

            if (!GlobalGuiSettings.VariableModCheck(listOfModsVariable))
            {
                return;
            }

            bool TrimMs1Peaks  = TrimMs1.IsChecked.Value;
            bool TrimMsMsPeaks = TrimMsMs.IsChecked.Value;

            int?numPeaksToKeep = null;

            if (!string.IsNullOrWhiteSpace(NumberOfPeaksToKeepPerWindowTextBox.Text))
            {
                if (int.TryParse(NumberOfPeaksToKeepPerWindowTextBox.Text, out int numberOfPeaksToKeeep))
                {
                    numPeaksToKeep = numberOfPeaksToKeeep;
                }
                else
                {
                    MessageBox.Show("The value that you entered for number of peaks to keep is not acceptable. Try again.");
                    return;
                }
            }

            double?minimumAllowedIntensityRatioToBasePeak = null;

            if (!string.IsNullOrWhiteSpace(MinimumAllowedIntensityRatioToBasePeakTexBox.Text))
            {
                if (double.TryParse(MinimumAllowedIntensityRatioToBasePeakTexBox.Text, out double minimumAllowedIntensityRatio))
                {
                    minimumAllowedIntensityRatioToBasePeak = minimumAllowedIntensityRatio;
                }
                else
                {
                    MessageBox.Show("The value that you entered for minimum allowed intensity ratio to keep is not acceptable. Try again.");
                    return;
                }
            }

            List <(string, string)> listOfModsFixed = new List <(string, string)>();

            foreach (var heh in fixedModTypeForTreeViewObservableCollection)
            {
                listOfModsFixed.AddRange(heh.Children.Where(b => b.Use).Select(b => (b.Parent.DisplayName, b.ModName)));
            }
            bool parseMaxThreadsPerFile = int.Parse(MaxThreadsTextBox.Text, CultureInfo.InvariantCulture) <= Environment.ProcessorCount && int.Parse(MaxThreadsTextBox.Text, CultureInfo.InvariantCulture) > 0;

            CommonParameters commonParamsToSave = new CommonParameters(
                useProvidedPrecursorInfo: UseProvidedPrecursor.IsChecked.Value,
                deconvolutionMaxAssumedChargeState: int.Parse(DeconvolutionMaxAssumedChargeStateTextBox.Text, CultureInfo.InvariantCulture),
                doPrecursorDeconvolution: DeconvolutePrecursors.IsChecked.Value,
                taskDescriptor: OutputFileNameTextBox.Text != "" ? OutputFileNameTextBox.Text : "GPTMDTask",
                maxThreadsToUsePerFile: parseMaxThreadsPerFile ? int.Parse(MaxThreadsTextBox.Text, CultureInfo.InvariantCulture) : new CommonParameters().MaxThreadsToUsePerFile,
                digestionParams: new DigestionParams(
                    protease: protease.Name,
                    maxMissedCleavages: maxMissedCleavages,
                    minPeptideLength: minPeptideLength,
                    maxPeptideLength: maxPeptideLength,
                    maxModificationIsoforms: maxModificationIsoforms,
                    maxModsForPeptides: maxModsPerPeptide,
                    initiatorMethionineBehavior: initiatorMethionineBehavior),
                dissociationType: dissociationType,
                scoreCutoff: double.Parse(MinScoreAllowed.Text, CultureInfo.InvariantCulture),
                precursorMassTolerance: precursorMassTolerance,
                productMassTolerance: productMassTolerance,
                trimMs1Peaks: TrimMs1Peaks,
                trimMsMsPeaks: TrimMsMsPeaks,
                numberOfPeaksToKeepPerWindow: numPeaksToKeep,
                minimumAllowedIntensityRatioToBasePeak: minimumAllowedIntensityRatioToBasePeak,
                listOfModsFixed: listOfModsFixed,
                listOfModsVariable: listOfModsVariable,
                assumeOrphanPeaksAreZ1Fragments: protease.Name != "top-down",
                addCompIons: AddCompIonCheckBox.IsChecked.Value,
                minVariantDepth: minVariantDepth,
                maxHeterozygousVariants: maxHeterozygousVariants);

            TheTask.GptmdParameters.ListOfModsGptmd = new List <(string, string)>();
            foreach (var heh in gptmdModTypeForTreeViewObservableCollection)
            {
                TheTask.GptmdParameters.ListOfModsGptmd.AddRange(heh.Children.Where(b => b.Use).Select(b => (b.Parent.DisplayName, b.ModName)));
            }

            TheTask.CommonParameters = commonParamsToSave;

            DialogResult = true;
        }
コード例 #5
0
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            string fieldNotUsed = "1";

            if (!GlobalGuiSettings.CheckTaskSettingsValidity(precursorMassToleranceTextBox.Text, productMassToleranceTextBox.Text, missedCleavagesTextBox.Text,
                                                             maxModificationIsoformsTextBox.Text, MinPeptideLengthTextBox.Text, MaxPeptideLengthTextBox.Text, maxThreadsTextBox.Text, minScoreAllowed.Text,
                                                             fieldNotUsed, fieldNotUsed, fieldNotUsed, fieldNotUsed, fieldNotUsed, fieldNotUsed, fieldNotUsed, fieldNotUsed, fieldNotUsed))
            {
                return;
            }

            Protease         protease                = (Protease)proteaseComboBox.SelectedItem;
            int              MaxMissedCleavages      = string.IsNullOrEmpty(missedCleavagesTextBox.Text) ? int.MaxValue : (int.Parse(missedCleavagesTextBox.Text, CultureInfo.InvariantCulture));
            int              MinPeptideLength        = int.Parse(MinPeptideLengthTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture);
            int              MaxPeptideLength        = string.IsNullOrEmpty(MaxPeptideLengthTextBox.Text) ? int.MaxValue : (int.Parse(MaxPeptideLengthTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture));
            int              MinVariantDepth         = int.Parse(MinVariantDepthTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture);
            int              MaxHeterozygousVariants = int.Parse(MaxHeterozygousVariantsTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture);
            int              MaxModificationIsoforms = int.Parse(maxModificationIsoformsTextBox.Text, CultureInfo.InvariantCulture);
            DissociationType dissociationType        = GlobalVariables.AllSupportedDissociationTypes[DissociationTypeComboBox.SelectedItem.ToString()];

            CustomFragmentationWindow.Close();

            DigestionParams digestionParamsToSave = new DigestionParams(
                protease: protease.Name,
                maxMissedCleavages: MaxMissedCleavages,
                minPeptideLength: MinPeptideLength,
                maxPeptideLength: MaxPeptideLength,
                maxModificationIsoforms: MaxModificationIsoforms);

            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.ModName)));
            }

            if (!GlobalGuiSettings.VariableModCheck(listOfModsVariable))
            {
                return;
            }

            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.ModName)));
            }
            Tolerance ProductMassTolerance;

            if (productMassToleranceComboBox.SelectedIndex == 0)
            {
                ProductMassTolerance = new AbsoluteTolerance(double.Parse(productMassToleranceTextBox.Text, CultureInfo.InvariantCulture));
            }
            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
            {
                PrecursorMassTolerance = new PpmTolerance(double.Parse(precursorMassToleranceTextBox.Text, CultureInfo.InvariantCulture));
            }

            bool parseMaxThreadsPerFile = int.Parse(maxThreadsTextBox.Text, CultureInfo.InvariantCulture) <= Environment.ProcessorCount && int.Parse(maxThreadsTextBox.Text, CultureInfo.InvariantCulture) > 0;

            CommonParameters commonParamsToSave = new CommonParameters(
                taskDescriptor: OutputFileNameTextBox.Text != "" ? OutputFileNameTextBox.Text : "CalibrateTask",
                maxThreadsToUsePerFile: parseMaxThreadsPerFile ? int.Parse(maxThreadsTextBox.Text, CultureInfo.InvariantCulture) : new CommonParameters().MaxThreadsToUsePerFile,
                digestionParams: digestionParamsToSave,
                dissociationType: dissociationType,
                scoreCutoff: double.Parse(minScoreAllowed.Text, CultureInfo.InvariantCulture),
                listOfModsFixed: listOfModsFixed,
                listOfModsVariable: listOfModsVariable,
                productMassTolerance: ProductMassTolerance,
                precursorMassTolerance: PrecursorMassTolerance,
                assumeOrphanPeaksAreZ1Fragments: protease.Name != "top-down",
                minVariantDepth: MinVariantDepth,
                maxHeterozygousVariants: MaxHeterozygousVariants);

            TheTask.CommonParameters = commonParamsToSave;

            DialogResult = true;
        }
コード例 #6
0
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            string fieldNotUsed = "1";

            if (!GlobalGuiSettings.CheckTaskSettingsValidity(PrecusorMsTlTextBox.Text, productMassToleranceTextBox.Text, missedCleavagesTextBox.Text,
                                                             maxModificationIsoformsTextBox.Text, MinPeptideLengthTextBox.Text, MaxPeptideLengthTextBox.Text, maxThreadsTextBox.Text, minScoreAllowed.Text,
                                                             fieldNotUsed, fieldNotUsed, fieldNotUsed, TopNPeaksTextBox.Text, MinRatioTextBox.Text, null, null, numberOfDatabaseSearchesTextBox.Text, TxtBoxMaxModPerPep.Text, fieldNotUsed, fieldNotUsed))
            {
                return;
            }

            DissociationType dissociationType = GlobalVariables.AllSupportedDissociationTypes[DissociationTypeComboBox.SelectedItem.ToString()];

            DissociationType childDissociationType = DissociationType.Unknown;

            if (ChildScanDissociationTypeComboBox.SelectedItem.ToString() != "Null")
            {
                childDissociationType = GlobalVariables.AllSupportedDissociationTypes[ChildScanDissociationTypeComboBox.SelectedItem.ToString()];
            }
            CustomFragmentationWindow.Close();


            if (RbtOGlycoSearch.IsChecked.Value)
            {
                TheTask._glycoSearchParameters.GlycoSearchType = EngineLayer.GlycoSearch.GlycoSearchType.OGlycanSearch;
            }
            else if (RbtNGlycoSearch.IsChecked.Value)
            {
                TheTask._glycoSearchParameters.GlycoSearchType = EngineLayer.GlycoSearch.GlycoSearchType.NGlycanSearch;
            }
            else if (Rbt_N_O_GlycoSearch.IsChecked.Value)
            {
                TheTask._glycoSearchParameters.GlycoSearchType = EngineLayer.GlycoSearch.GlycoSearchType.N_O_GlycanSearch;
            }


            TheTask._glycoSearchParameters.OGlycanDatabasefile   = CmbOGlycanDatabase.SelectedItem.ToString();
            TheTask._glycoSearchParameters.NGlycanDatabasefile   = CmbNGlycanDatabase.SelectedItem.ToString();
            TheTask._glycoSearchParameters.GlycoSearchTopNum     = int.Parse(txtTopNum.Text, CultureInfo.InvariantCulture);
            TheTask._glycoSearchParameters.MaximumOGlycanAllowed = int.Parse(TbMaxOGlycanNum.Text, CultureInfo.InvariantCulture);
            TheTask._glycoSearchParameters.OxoniumIonFilt        = CkbOxoniumIonFilt.IsChecked.Value;

            if (CheckBoxDecoy.IsChecked.Value)
            {
                if (RadioButtonReverseDecoy.IsChecked.Value)
                {
                    TheTask._glycoSearchParameters.DecoyType = DecoyType.Reverse;
                }
                else //if (radioButtonSlideDecoy.IsChecked.Value)
                {
                    TheTask._glycoSearchParameters.DecoyType = DecoyType.Slide;
                }
            }
            else
            {
                TheTask._glycoSearchParameters.DecoyType = DecoyType.None;
            }

            Protease protease                = (Protease)proteaseComboBox.SelectedItem;
            int      MaxMissedCleavages      = string.IsNullOrEmpty(missedCleavagesTextBox.Text) ? int.MaxValue : (int.Parse(missedCleavagesTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture));
            int      MinPeptideLength        = (int.Parse(MinPeptideLengthTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture));
            int      MaxPeptideLength        = string.IsNullOrEmpty(MaxPeptideLengthTextBox.Text) ? int.MaxValue : (int.Parse(MaxPeptideLengthTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture));
            int      MaxModificationIsoforms = (int.Parse(maxModificationIsoformsTextBox.Text, CultureInfo.InvariantCulture));
            int      MaxModPerPep            = (int.Parse(TxtBoxMaxModPerPep.Text, CultureInfo.InvariantCulture));
            InitiatorMethionineBehavior InitiatorMethionineBehavior = ((InitiatorMethionineBehavior)initiatorMethionineBehaviorComboBox.SelectedIndex);
            DigestionParams             digestionParamsToSave       = new DigestionParams(
                protease: protease.Name,
                maxMissedCleavages: MaxMissedCleavages,
                minPeptideLength: MinPeptideLength,
                maxPeptideLength: MaxPeptideLength,
                maxModificationIsoforms: MaxModificationIsoforms,
                maxModsForPeptides: MaxModPerPep,
                initiatorMethionineBehavior: InitiatorMethionineBehavior);

            Tolerance ProductMassTolerance;

            if (productMassToleranceComboBox.SelectedIndex == 0)
            {
                ProductMassTolerance = new AbsoluteTolerance(double.Parse(productMassToleranceTextBox.Text, CultureInfo.InvariantCulture));
            }
            else
            {
                ProductMassTolerance = new PpmTolerance(double.Parse(productMassToleranceTextBox.Text, CultureInfo.InvariantCulture));
            }

            Tolerance PrecursorMassTolerance;

            if (cbbPrecusorMsTl.SelectedIndex == 0)
            {
                PrecursorMassTolerance = new AbsoluteTolerance(double.Parse(PrecusorMsTlTextBox.Text, CultureInfo.InvariantCulture));
            }
            else
            {
                PrecursorMassTolerance = new PpmTolerance(double.Parse(PrecusorMsTlTextBox.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.ModName)));
            }

            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.ModName)));
            }

            CommonParameters commonParamsToSave = new CommonParameters(
                precursorMassTolerance: PrecursorMassTolerance,
                taskDescriptor: OutputFileNameTextBox.Text != "" ? OutputFileNameTextBox.Text : "GlycoSearchTask",
                productMassTolerance: ProductMassTolerance,
                doPrecursorDeconvolution: deconvolutePrecursors.IsChecked.Value,
                useProvidedPrecursorInfo: useProvidedPrecursor.IsChecked.Value,
                digestionParams: digestionParamsToSave,
                trimMs1Peaks: trimMs1.IsChecked.Value,
                trimMsMsPeaks: trimMsMs.IsChecked.Value,
                numberOfPeaksToKeepPerWindow: int.Parse(TopNPeaksTextBox.Text),
                minimumAllowedIntensityRatioToBasePeak: double.Parse(MinRatioTextBox.Text, CultureInfo.InvariantCulture),
                dissociationType: dissociationType,
                ms2childScanDissociationType: childDissociationType,
                scoreCutoff: double.Parse(minScoreAllowed.Text, CultureInfo.InvariantCulture),
                totalPartitions: int.Parse(numberOfDatabaseSearchesTextBox.Text, CultureInfo.InvariantCulture),
                maxThreadsToUsePerFile: int.Parse(maxThreadsTextBox.Text, CultureInfo.InvariantCulture),
                listOfModsVariable: listOfModsVariable,
                listOfModsFixed: listOfModsFixed,
                assumeOrphanPeaksAreZ1Fragments: protease.Name != "top-down");

            TheTask.CommonParameters = commonParamsToSave;

            DialogResult = true;
        }
コード例 #7
0
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            if (nonSpecificSearchRadioButton1.IsChecked.Value || semiSpecificSearchRadioButton.IsChecked.Value)
            {
                if ((bCheckBox.IsChecked.Value || cCheckBox.IsChecked.Value) && (yCheckBox.IsChecked.Value || zdotCheckBox.IsChecked.Value))
                {
                    //MessageBox.Show("Only ion types from a single terminus are allowed for this search algorithm. \ne.g. b- and/or c-ions OR y- and/or zdot-ions. \nC-terminal ions (y and/or zdot) will be chosen by default.");
                    bCheckBox.IsChecked = false;
                    cCheckBox.IsChecked = false;
                }
                if (((Protease)proteaseComboBox.SelectedItem).Name.Contains("non-specific"))
                {
                    proteaseComboBox.SelectedItem = proteaseComboBox.Items.CurrentItem;
                    if ((bCheckBox.IsChecked.Value || cCheckBox.IsChecked.Value))
                    {
                        for (int i = 0; i < proteaseComboBox.Items.Count; i++)
                        {
                            if (((Protease)proteaseComboBox.Items[i]).Name.Equals("singleN"))
                            {
                                proteaseComboBox.SelectedItem = proteaseComboBox.Items[i];
                                break;
                            }
                        }
                    }
                    else
                    {
                        for (int i = 0; i < proteaseComboBox.Items.Count; i++)
                        {
                            if (((Protease)proteaseComboBox.Items[i]).Name.Equals("singleC"))
                            {
                                proteaseComboBox.SelectedItem = proteaseComboBox.Items[i];
                                break;
                            }
                        }
                    }
                }
                if (((Protease)proteaseComboBox.SelectedItem).Name.Contains("semi-trypsin"))
                {
                    proteaseComboBox.Items.MoveCurrentToFirst();
                    proteaseComboBox.SelectedItem = proteaseComboBox.Items.CurrentItem;
                    while (!((Protease)proteaseComboBox.SelectedItem).Name.Equals("trypsin"))
                    {
                        proteaseComboBox.Items.MoveCurrentToNext();
                        proteaseComboBox.SelectedItem = proteaseComboBox.Items.CurrentItem;
                    }
                }
                if (!addCompIonCheckBox.IsChecked.Value)
                {
                    MessageBox.Show("Warning: Complementary ions are strongly recommended when using this algorithm.");
                }
            }

            if (!GlobalGuiSettings.CheckTaskSettingsValidity(precursorMassToleranceTextBox.Text, productMassToleranceTextBox.Text, missedCleavagesTextBox.Text,
                                                             maxModificationIsoformsTextBox.Text, MinPeptideLengthTextBox.Text, MaxPeptideLengthTextBox.Text, maxThreadsTextBox.Text, minScoreAllowed.Text,
                                                             peakFindingToleranceTextBox.Text, histogramBinWidthTextBox.Text, DeconvolutionMaxAssumedChargeStateTextBox.Text, TopNPeaksTextBox.Text,
                                                             MinRatioTextBox.Text, numberOfDatabaseSearchesTextBox.Text, MaxModNumTextBox.Text, MaxFragmentMassTextBox.Text, QValueTextBox.Text))
            {
                return;
            }

            Protease     protease = (Protease)proteaseComboBox.SelectedItem;
            bool         semiProteaseDigestion        = (semiSpecificSearchRadioButton.IsChecked.Value && ((Protease)proteaseComboBox.SelectedItem).CleavageSpecificity != CleavageSpecificity.SingleN && ((Protease)proteaseComboBox.SelectedItem).CleavageSpecificity != CleavageSpecificity.SingleC);
            TerminusType terminusTypeSemiProtease     = (bCheckBox.IsChecked.Value || cCheckBox.IsChecked.Value ? TerminusType.N : TerminusType.C);
            int          maxMissedCleavages           = string.IsNullOrEmpty(missedCleavagesTextBox.Text) ? int.MaxValue : (int.Parse(missedCleavagesTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture));
            int          minPeptideLengthValue        = (int.Parse(MinPeptideLengthTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture));
            int          maxPeptideLengthValue        = string.IsNullOrEmpty(MaxPeptideLengthTextBox.Text) ? int.MaxValue : (int.Parse(MaxPeptideLengthTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture));
            int          maxModificationIsoformsValue = (int.Parse(maxModificationIsoformsTextBox.Text, CultureInfo.InvariantCulture));
            int          maxModsForPeptideValue       = (int.Parse(MaxModNumTextBox.Text, CultureInfo.InvariantCulture));
            InitiatorMethionineBehavior initiatorMethionineBehavior = ((InitiatorMethionineBehavior)initiatorMethionineBehaviorComboBox.SelectedIndex);
            DigestionParams             digestionParamsToSave       = new DigestionParams(
                protease: protease.Name,
                semiProteaseDigestion: semiProteaseDigestion,
                terminusTypeSemiProtease: terminusTypeSemiProtease,
                maxMissedCleavages: maxMissedCleavages,
                minPeptideLength: minPeptideLengthValue,
                maxPeptideLength: maxPeptideLengthValue,
                maxModificationIsoforms: maxModificationIsoformsValue,
                initiatorMethionineBehavior: initiatorMethionineBehavior,
                maxModsForPeptides: maxModsForPeptideValue);

            Tolerance ProductMassTolerance;

            if (productMassToleranceComboBox.SelectedIndex == 0)
            {
                ProductMassTolerance = new AbsoluteTolerance(double.Parse(productMassToleranceTextBox.Text, CultureInfo.InvariantCulture));
            }
            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
            {
                PrecursorMassTolerance = new PpmTolerance(double.Parse(precursorMassToleranceTextBox.Text, CultureInfo.InvariantCulture));
            }
            TheTask.SearchParameters.MaxFragmentSize = Double.Parse(MaxFragmentMassTextBox.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)));
            }

            if (!GlobalGuiSettings.VariableModCheck(listOfModsVariable))
            {
                return;
            }

            bool   TrimMs1Peaks  = trimMs1.IsChecked.Value;
            bool   TrimMsMsPeaks = trimMsMs.IsChecked.Value;
            int    TopNpeaks     = int.Parse(TopNPeaksTextBox.Text);
            double MinRatio      = double.Parse(MinRatioTextBox.Text);

            bool parseMaxThreadsPerFile = !maxThreadsTextBox.Text.Equals("") && (int.Parse(maxThreadsTextBox.Text) <= Environment.ProcessorCount && int.Parse(maxThreadsTextBox.Text) > 0);

            CommonParameters commonParamsToSave = new CommonParameters(
                taskDescriptor: OutputFileNameTextBox.Text != "" ? OutputFileNameTextBox.Text : "SearchTask",
                maxThreadsToUsePerFile: parseMaxThreadsPerFile ? int.Parse(maxThreadsTextBox.Text, CultureInfo.InvariantCulture) : new CommonParameters().MaxThreadsToUsePerFile,
                useDeltaScore: deltaScoreCheckBox.IsChecked.Value,
                reportAllAmbiguity: allAmbiguity.IsChecked.Value,
                deconvolutionMaxAssumedChargeState: int.Parse(DeconvolutionMaxAssumedChargeStateTextBox.Text, CultureInfo.InvariantCulture),
                totalPartitions: int.Parse(numberOfDatabaseSearchesTextBox.Text, CultureInfo.InvariantCulture),
                doPrecursorDeconvolution: deconvolutePrecursors.IsChecked.Value,
                useProvidedPrecursorInfo: useProvidedPrecursor.IsChecked.Value,
                scoreCutoff: double.Parse(minScoreAllowed.Text, CultureInfo.InvariantCulture),
                calculateEValue: eValueCheckBox.IsChecked.Value,
                listOfModsFixed: listOfModsFixed,
                listOfModsVariable: listOfModsVariable,
                bIons: bCheckBox.IsChecked.Value,
                yIons: yCheckBox.IsChecked.Value,
                cIons: cCheckBox.IsChecked.Value,
                zDotIons: zdotCheckBox.IsChecked.Value,
                precursorMassTolerance: PrecursorMassTolerance,
                productMassTolerance: ProductMassTolerance,
                digestionParams: digestionParamsToSave,
                trimMs1Peaks: TrimMs1Peaks,
                trimMsMsPeaks: TrimMsMsPeaks,
                topNpeaks: TopNpeaks,
                minRatio: MinRatio,
                addCompIons: addCompIonCheckBox.IsChecked.Value,
                qValueOutputFilter: QValueCheckBox.IsChecked.Value ? double.Parse(QValueTextBox.Text, CultureInfo.InvariantCulture) : double.PositiveInfinity);

            if (classicSearchRadioButton.IsChecked.Value)
            {
                TheTask.SearchParameters.SearchType = SearchType.Classic;
            }
            else if (modernSearchRadioButton.IsChecked.Value)
            {
                TheTask.SearchParameters.SearchType = SearchType.Modern;
            }
            else //if (nonSpecificSearchRadioButton.IsChecked.Value)
            {
                TheTask.SearchParameters.SearchType = SearchType.NonSpecific;
            }

            TheTask.SearchParameters.DoParsimony             = checkBoxParsimony.IsChecked.Value;
            TheTask.SearchParameters.NoOneHitWonders         = checkBoxNoOneHitWonders.IsChecked.Value;
            TheTask.SearchParameters.DoQuantification        = checkBoxQuantification.IsChecked.Value;
            TheTask.SearchParameters.Normalize               = checkBoxNormalize.IsChecked.Value;
            TheTask.SearchParameters.MatchBetweenRuns        = checkBoxMatchBetweenRuns.IsChecked.Value;
            TheTask.SearchParameters.ModPeptidesAreDifferent = modPepsAreUnique.IsChecked.Value;
            TheTask.SearchParameters.QuantifyPpmTol          = double.Parse(peakFindingToleranceTextBox.Text, CultureInfo.InvariantCulture);
            TheTask.SearchParameters.SearchTarget            = checkBoxTarget.IsChecked.Value;
            TheTask.SearchParameters.WriteMzId               = ckbMzId.IsChecked.Value;
            //TheTask.SearchParameters.OutPepXML = ckbPepXML.IsChecked.Value;

            if (checkBoxDecoy.IsChecked.Value)
            {
                if (radioButtonReverseDecoy.IsChecked.Value)
                {
                    TheTask.SearchParameters.DecoyType = DecoyType.Reverse;
                }
                else //if (radioButtonSlideDecoy.IsChecked.Value)
                {
                    TheTask.SearchParameters.DecoyType = DecoyType.Slide;
                }
            }
            else
            {
                TheTask.SearchParameters.DecoyType = DecoyType.None;
            }

            if (massDiffAcceptExact.IsChecked.HasValue && massDiffAcceptExact.IsChecked.Value)
            {
                TheTask.SearchParameters.MassDiffAcceptorType = MassDiffAcceptorType.Exact;
            }
            if (massDiffAccept1mm.IsChecked.HasValue && massDiffAccept1mm.IsChecked.Value)
            {
                TheTask.SearchParameters.MassDiffAcceptorType = MassDiffAcceptorType.OneMM;
            }
            if (massDiffAccept2mm.IsChecked.HasValue && massDiffAccept2mm.IsChecked.Value)
            {
                TheTask.SearchParameters.MassDiffAcceptorType = MassDiffAcceptorType.TwoMM;
            }
            if (massDiffAccept3mm.IsChecked.HasValue && massDiffAccept3mm.IsChecked.Value)
            {
                TheTask.SearchParameters.MassDiffAcceptorType = MassDiffAcceptorType.ThreeMM;
            }
            if (massDiffAccept187.IsChecked.HasValue && massDiffAccept187.IsChecked.Value)
            {
                TheTask.SearchParameters.MassDiffAcceptorType = MassDiffAcceptorType.ModOpen;
            }
            if (massDiffAcceptOpen.IsChecked.HasValue && massDiffAcceptOpen.IsChecked.Value)
            {
                TheTask.SearchParameters.MassDiffAcceptorType = MassDiffAcceptorType.Open;
            }
            if (massDiffAcceptCustom.IsChecked.HasValue && massDiffAcceptCustom.IsChecked.Value)
            {
                TheTask.SearchParameters.MassDiffAcceptorType = MassDiffAcceptorType.Custom;
                TheTask.SearchParameters.CustomMdac           = customkMdacTextBox.Text;
            }

            // displays warning if classic search is enabled with an open search mode
            if (TheTask.SearchParameters.SearchType == SearchType.Classic &&
                (TheTask.SearchParameters.MassDiffAcceptorType == MassDiffAcceptorType.ModOpen || TheTask.SearchParameters.MassDiffAcceptorType == MassDiffAcceptorType.Open))
            {
                MessageBoxResult result = MessageBox.Show("We recommend using Modern Search mode when conducting open precursor mass searches to reduce search time.\n\n" +
                                                          "Continue anyway?", "Modern search recommended", MessageBoxButton.OKCancel);

                if (result == MessageBoxResult.Cancel)
                {
                    return;
                }
            }

            TheTask.SearchParameters.DoHistogramAnalysis      = checkBoxHistogramAnalysis.IsChecked.Value;
            TheTask.SearchParameters.HistogramBinTolInDaltons = double.Parse(histogramBinWidthTextBox.Text, CultureInfo.InvariantCulture);

            TheTask.SearchParameters.WritePrunedDatabase = writePrunedDBCheckBox.IsChecked.Value;

            SetModSelectionForPrunedDB();

            TheTask.CommonParameters = commonParamsToSave;

            DialogResult = true;
        }
コード例 #8
0
        // write the toml settings file on clicking "save"
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            var parametersToWrite = new FileSpecificParameters();

            // parse the file-specific parameters to text
            int paramsToSaveCount = 0;

            if (fileSpecificPrecursorMassTolEnabled.IsChecked.Value)
            {
                paramsToSaveCount++;
                if (GlobalGuiSettings.CheckPrecursorMassTolerance(precursorMassToleranceTextBox.Text))
                {
                    double value = double.Parse(precursorMassToleranceTextBox.Text, CultureInfo.InvariantCulture);
                    if (precursorMassToleranceComboBox.SelectedIndex == 0)
                    {
                        parametersToWrite.PrecursorMassTolerance = new AbsoluteTolerance(value);
                    }
                    else
                    {
                        parametersToWrite.PrecursorMassTolerance = new PpmTolerance(value);
                    }
                }
                else
                {
                    return;
                }
            }
            if (fileSpecificProductMassTolEnabled.IsChecked.Value)
            {
                paramsToSaveCount++;
                if (GlobalGuiSettings.CheckProductMassTolerance(productMassToleranceTextBox.Text))
                {
                    double value = double.Parse(productMassToleranceTextBox.Text, CultureInfo.InvariantCulture);
                    if (productMassToleranceComboBox.SelectedIndex == 0)
                    {
                        parametersToWrite.ProductMassTolerance = new AbsoluteTolerance(value);
                    }
                    else
                    {
                        parametersToWrite.ProductMassTolerance = new PpmTolerance(value);
                    }
                }
                else
                {
                    return;
                }
            }
            if (fileSpecificProteaseEnabled.IsChecked.Value)
            {
                paramsToSaveCount++;
                parametersToWrite.Protease = (Protease)fileSpecificProtease.SelectedItem;
            }
            if (fileSpecificMinPeptideLengthEnabled.IsChecked.Value)
            {
                paramsToSaveCount++;
                if (int.TryParse(MinPeptideLengthTextBox.Text, out int i) && i > 0)
                {
                    parametersToWrite.MinPeptideLength = i;
                }
                else
                {
                    MessageBox.Show("The minimum peptide length must be a positive integer");
                    return;
                }
            }
            if (fileSpecificMaxPeptideLengthEnabled.IsChecked.Value)
            {
                paramsToSaveCount++;
                string lengthMaxPeptide = GlobalGuiSettings.MaxValueConversion(MaxPeptideLengthTextBox.Text);
                if (GlobalGuiSettings.CheckPeptideLength(MinPeptideLengthTextBox.Text, lengthMaxPeptide))
                {
                    parametersToWrite.MaxPeptideLength = int.Parse(lengthMaxPeptide);
                }
                else
                {
                    return;
                }
            }
            if (fileSpecificMissedCleavagesEnabled.IsChecked.Value)
            {
                paramsToSaveCount++;
                string lengthCleavage = GlobalGuiSettings.MaxValueConversion(missedCleavagesTextBox.Text);
                if (GlobalGuiSettings.CheckMaxMissedCleavages(lengthCleavage))
                {
                    parametersToWrite.MaxMissedCleavages = int.Parse(lengthCleavage);
                }
                else
                {
                    return;
                }
            }
            if (fileSpecificMaxModNumEnabled.IsChecked.Value)
            {
                paramsToSaveCount++;
                if (GlobalGuiSettings.CheckMaxModsPerPeptide(MaxModNumTextBox.Text))
                {
                    parametersToWrite.MaxModsForPeptide = int.Parse(MaxModNumTextBox.Text);
                }
                else
                {
                    return;
                }
            }
            //if (fileSpecificIonTypesEnabled.IsChecked.Value)
            //{
            //    paramsToSaveCount++;

            //    // don't think there's any way to mess up checkboxes... no error message needed
            //    parametersToWrite.BIons = bCheckBox.IsChecked;
            //    parametersToWrite.YIons = yCheckBox.IsChecked;
            //    parametersToWrite.CIons = cCheckBox.IsChecked;
            //    parametersToWrite.ZdotIons = zdotCheckBox.IsChecked;
            //}

            // write parameters to toml files for the selected spectra files


            var tomlPathsForSelectedFiles = SelectedSpectra.Select(p => Path.Combine(Directory.GetParent(p.FilePath).ToString(), Path.GetFileNameWithoutExtension(p.FileName)) + ".toml");

            foreach (var tomlToWrite in tomlPathsForSelectedFiles)
            {
                if (paramsToSaveCount > 0)
                {
                    Toml.WriteFile(parametersToWrite, tomlToWrite, MetaMorpheusTask.tomlConfig);

                    // make sure the settings are able to be parsed...
                    var tempTomlTable = Toml.ReadFile(tomlToWrite, MetaMorpheusTask.tomlConfig);
                    FileSpecificParameters tempParams = new FileSpecificParameters(tempTomlTable);
                }
                else
                {
                    // user has specified that no file-specific settings should be used; delete the file-specific toml if it exists
                    File.Delete(tomlToWrite);
                }
            }

            // done
            DialogResult = true;
        }
コード例 #9
0
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            string fieldNotUsed = "1";

            if (!GlobalGuiSettings.CheckTaskSettingsValidity(XLPrecusorMsTlTextBox.Text, productMassToleranceTextBox.Text, missedCleavagesTextBox.Text,
                                                             maxModificationIsoformsTextBox.Text, MinPeptideLengthTextBox.Text, MaxPeptideLengthTextBox.Text, maxThreadsTextBox.Text, minScoreAllowed.Text,
                                                             fieldNotUsed, fieldNotUsed, fieldNotUsed, TopNPeaksTextBox.Text, MinRatioTextBox.Text, numberOfDatabaseSearchesTextBox.Text, fieldNotUsed, fieldNotUsed, fieldNotUsed))
            {
                return;
            }

            TheTask.XlSearchParameters.CrosslinkSearchTop    = ckbXLTopNum.IsChecked.Value;
            TheTask.XlSearchParameters.CrosslinkSearchTopNum = int.Parse(txtXLTopNum.Text, CultureInfo.InvariantCulture);
            //TheTask.XlSearchParameters.CrosslinkSearchWithAllBeta = ckbSearchWithXLAllBeta.IsChecked.Value;
            TheTask.XlSearchParameters.CrosslinkerType = (CrosslinkerType)cbCrosslinker.SelectedIndex;
            //TheTask.XlSearchParameters.FragmentationType = (FragmentaionType)cbFragmentation.SelectedIndex;
            if (cbbXLprecusorMsTl.SelectedIndex == 0)
            {
                TheTask.XlSearchParameters.XlPrecusorMsTl = new AbsoluteTolerance(double.Parse(XLPrecusorMsTlTextBox.Text, CultureInfo.InvariantCulture));
            }
            else
            {
                TheTask.XlSearchParameters.XlPrecusorMsTl = new PpmTolerance(double.Parse(XLPrecusorMsTlTextBox.Text, CultureInfo.InvariantCulture));
            }
            TheTask.XlSearchParameters.XlCharge_2_3 = ckbCharge_2_3.IsChecked.Value;
            TheTask.XlSearchParameters.XlCharge_2_3_PrimeFragment = ckbCharge_2_3_PrimeFragments.IsChecked.Value;
            TheTask.XlSearchParameters.XlQuench_H2O  = ckbQuenchH2O.IsChecked.Value;
            TheTask.XlSearchParameters.XlQuench_NH2  = ckbQuenchNH2.IsChecked.Value;
            TheTask.XlSearchParameters.XlQuench_Tris = ckbQuenchTris.IsChecked.Value;

            if (TheTask.XlSearchParameters.CrosslinkerType == CrosslinkerType.UserDefined)
            {
                TheTask.XlSearchParameters.UdXLkerName            = txtUdXLKerName.Text;
                TheTask.XlSearchParameters.UdXLkerCleavable       = ckbUdXLkerCleavable.IsChecked.Value;
                TheTask.XlSearchParameters.UdXLkerResidues        = txtUdXLkerAminoAcids.Text;
                TheTask.XlSearchParameters.UdXLkerResidues2       = txtUdXLkerAminoAcids2.Text;
                TheTask.XlSearchParameters.UdXLkerLongMass        = string.IsNullOrEmpty(txtUdXLkerLongMass.Text) ? (double?)null : double.Parse(txtUdXLkerLongMass.Text, CultureInfo.InvariantCulture);
                TheTask.XlSearchParameters.UdXLkerShortMass       = string.IsNullOrEmpty(txtUdXLkerShortMass.Text) ? (double?)null : double.Parse(txtUdXLkerShortMass.Text, CultureInfo.InvariantCulture);
                TheTask.XlSearchParameters.UdXLkerTotalMass       = string.IsNullOrEmpty(txtUdXLkerTotalMs.Text) ? (double?)null : double.Parse(txtUdXLkerTotalMs.Text, CultureInfo.InvariantCulture);
                TheTask.XlSearchParameters.UdXLkerLoopMass        = string.IsNullOrEmpty(txtUdXLkerLoopMass.Text) ? (double?)null : double.Parse(txtUdXLkerLoopMass.Text, CultureInfo.InvariantCulture);
                TheTask.XlSearchParameters.UdXLkerDeadendMassH2O  = string.IsNullOrEmpty(txtUdXLkerDeadendH2O.Text) ? (double?)null : double.Parse(txtUdXLkerDeadendH2O.Text, CultureInfo.InvariantCulture);
                TheTask.XlSearchParameters.UdXLkerDeadendMassNH2  = string.IsNullOrEmpty(txtUdXLkerDeadendNH2.Text) ? (double?)null : double.Parse(txtUdXLkerDeadendNH2.Text, CultureInfo.InvariantCulture);
                TheTask.XlSearchParameters.UdXLkerDeadendMassTris = string.IsNullOrEmpty(txtUdXLkerDeadendTris.Text) ? (double?)null : double.Parse(txtUdXLkerDeadendTris.Text, CultureInfo.InvariantCulture);
            }

            TheTask.XlSearchParameters.DecoyType = checkBoxDecoy.IsChecked.Value ? DecoyType.Reverse : DecoyType.None;

            Protease protease                = (Protease)proteaseComboBox.SelectedItem;
            int      MaxMissedCleavages      = string.IsNullOrEmpty(missedCleavagesTextBox.Text) ? int.MaxValue : (int.Parse(missedCleavagesTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture));
            int      MinPeptideLength        = (int.Parse(MinPeptideLengthTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture));
            int      MaxPeptideLength        = string.IsNullOrEmpty(MaxPeptideLengthTextBox.Text) ? int.MaxValue : (int.Parse(MaxPeptideLengthTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture));
            int      MaxModificationIsoforms = (int.Parse(maxModificationIsoformsTextBox.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);

            Tolerance ProductMassTolerance;

            if (productMassToleranceComboBox.SelectedIndex == 0)
            {
                ProductMassTolerance = new AbsoluteTolerance(double.Parse(productMassToleranceTextBox.Text, CultureInfo.InvariantCulture));
            }
            else
            {
                ProductMassTolerance = new PpmTolerance(double.Parse(productMassToleranceTextBox.Text, CultureInfo.InvariantCulture));
            }

            TheTask.XlSearchParameters.XlOutPercolator = ckbPercolator.IsChecked.Value;
            TheTask.XlSearchParameters.XlOutPepXML     = ckbPepXML.IsChecked.Value;
            TheTask.XlSearchParameters.XlOutAll        = ckbAllResults.IsChecked.Value;
            TheTask.XlSearchParameters.XlOutCrosslink  = ckbCrosslink.IsChecked.Value;
            //TheTask.UseProvidedPrecursorInfo = useProvidedPrecursor.IsChecked.Value;

            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 : "XLSearchTask",
                productMassTolerance: ProductMassTolerance,
                doPrecursorDeconvolution: deconvolutePrecursors.IsChecked.Value,
                useProvidedPrecursorInfo: useProvidedPrecursor.IsChecked.Value,
                digestionParams: digestionParamsToSave,
                trimMs1Peaks: trimMs1.IsChecked.Value,
                trimMsMsPeaks: trimMsMs.IsChecked.Value,
                topNpeaks: int.Parse(TopNPeaksTextBox.Text),
                minRatio: double.Parse(MinRatioTextBox.Text),
                bIons: bCheckBox.IsChecked.Value,
                yIons: yCheckBox.IsChecked.Value,
                cIons: cCheckBox.IsChecked.Value,
                zDotIons: zdotCheckBox.IsChecked.Value,
                scoreCutoff: double.Parse(minScoreAllowed.Text, CultureInfo.InvariantCulture),
                totalPartitions: int.Parse(numberOfDatabaseSearchesTextBox.Text, CultureInfo.InvariantCulture),
                listOfModsVariable: listOfModsVariable,
                listOfModsFixed: listOfModsFixed);

            TheTask.CommonParameters = commonParamsToSave;

            DialogResult = true;
        }
コード例 #10
0
        // write the toml settings file on clicking "save"
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            var  parametersToWrite           = new FileSpecificParameters();
            bool fileSpecificParameterExists = false;

            // parse the file-specific parameters to text
            if (fileSpecificPrecursorMassTolEnabled.IsChecked.Value)
            {
                fileSpecificParameterExists = true;
                if (GlobalGuiSettings.CheckPrecursorMassTolerance(precursorMassToleranceTextBox.Text))
                {
                    double value = double.Parse(precursorMassToleranceTextBox.Text, CultureInfo.InvariantCulture);
                    if (precursorMassToleranceComboBox.SelectedIndex == 0)
                    {
                        parametersToWrite.PrecursorMassTolerance = new AbsoluteTolerance(value);
                    }
                    else
                    {
                        parametersToWrite.PrecursorMassTolerance = new PpmTolerance(value);
                    }
                }
                else
                {
                    return;
                }
            }
            if (fileSpecificProductMassTolEnabled.IsChecked.Value)
            {
                fileSpecificParameterExists = true;
                if (GlobalGuiSettings.CheckProductMassTolerance(productMassToleranceTextBox.Text))
                {
                    double value = double.Parse(productMassToleranceTextBox.Text, CultureInfo.InvariantCulture);
                    if (productMassToleranceComboBox.SelectedIndex == 0)
                    {
                        parametersToWrite.ProductMassTolerance = new AbsoluteTolerance(value);
                    }
                    else
                    {
                        parametersToWrite.ProductMassTolerance = new PpmTolerance(value);
                    }
                }
                else
                {
                    return;
                }
            }
            if (fileSpecificProteaseEnabled.IsChecked.Value)
            {
                fileSpecificParameterExists = true;
                parametersToWrite.Protease  = (Protease)fileSpecificProtease.SelectedItem;
            }
            if (fileSpecificSeparationTypesEnabled.IsChecked.Value)
            {
                fileSpecificParameterExists      = true;
                parametersToWrite.SeparationType = (string)fileSpecificSeparationType.SelectedItem;
            }
            if (fileSpecificMinPeptideLengthEnabled.IsChecked.Value)
            {
                fileSpecificParameterExists = true;
                if (int.TryParse(MinPeptideLengthTextBox.Text, out int i) && i > 0)
                {
                    parametersToWrite.MinPeptideLength = i;
                }
                else
                {
                    MessageBox.Show("The minimum peptide length must be a positive integer");
                    return;
                }
            }
            if (fileSpecificMaxPeptideLengthEnabled.IsChecked.Value)
            {
                fileSpecificParameterExists = true;
                string lengthMaxPeptide = GlobalGuiSettings.MaxValueConversion(MaxPeptideLengthTextBox.Text);
                if (GlobalGuiSettings.CheckPeptideLength(MinPeptideLengthTextBox.Text, lengthMaxPeptide))
                {
                    parametersToWrite.MaxPeptideLength = int.Parse(lengthMaxPeptide);
                }
                else
                {
                    return;
                }
            }
            if (fileSpecificMissedCleavagesEnabled.IsChecked.Value)
            {
                fileSpecificParameterExists = true;
                string lengthCleavage = GlobalGuiSettings.MaxValueConversion(missedCleavagesTextBox.Text);
                if (GlobalGuiSettings.CheckMaxMissedCleavages(lengthCleavage))
                {
                    parametersToWrite.MaxMissedCleavages = int.Parse(lengthCleavage);
                }
                else
                {
                    return;
                }
            }
            if (fileSpecificMaxModNumEnabled.IsChecked.Value)
            {
                fileSpecificParameterExists = true;
                if (GlobalGuiSettings.CheckMaxModsPerPeptide(MaxModNumTextBox.Text))
                {
                    parametersToWrite.MaxModsForPeptide = int.Parse(MaxModNumTextBox.Text);
                }
                else
                {
                    return;
                }
            }
            //if (fileSpecificIonTypesEnabled.IsChecked.Value)
            //{
            //    paramsToSaveCount++;

            //    // don't think there's any way to mess up checkboxes... no error message needed
            //    parametersToWrite.BIons = bCheckBox.IsChecked;
            //    parametersToWrite.YIons = yCheckBox.IsChecked;
            //    parametersToWrite.CIons = cCheckBox.IsChecked;
            //    parametersToWrite.ZdotIons = zdotCheckBox.IsChecked;
            //}

            // write parameters to toml files for the selected spectra files

            foreach (var spectra in SelectedSpectra)
            {
                string directoryForThisMsFile = Directory.GetParent(spectra.FilePath).ToString();
                string filename    = Path.GetFileNameWithoutExtension(spectra.FileName) + ".toml";
                string tomlToWrite = Path.Combine(directoryForThisMsFile, filename);

                //check if a toml file already exists
                if (File.Exists(tomlToWrite))
                {
                    //store the previous file-specific tomls (if any) in a folder for reproducibility
                    AccomodateNewFileSpecificToml(directoryForThisMsFile, filename);
                    //check that an old toml doesn't already exist. If it does, move it to another nested folder.
                }

                if (fileSpecificParameterExists)
                {
                    Toml.WriteFile(parametersToWrite, tomlToWrite, MetaMorpheusTask.tomlConfig);

                    // make sure the settings are able to be parsed...
                    var tempTomlTable = Toml.ReadFile(tomlToWrite, MetaMorpheusTask.tomlConfig);
                    FileSpecificParameters tempParams = new FileSpecificParameters(tempTomlTable);
                }
                else
                {
                    // user has specified that no file-specific settings should be used; delete the file-specific toml if it exists
                    File.Delete(tomlToWrite);
                }
            }

            // done
            DialogResult = true;
        }