public void PlotAnotatedSpectrum(MSLight msExperimental, double ppm, string peptide)
        {
            //Predict the spectrum
            //Find PTMs

            List <ModificationItem>      mods = SpectraPredictor.GetVMods(peptide);
            SpectralPredictionParameters spp  = new SpectralPredictionParameters(false, true, false, false, true, false, true, true, 2, true, mods);
            SpectraPredictor             sp   = new SpectraPredictor(spp);
            List <PredictedIon>          theoreticalSpectrum = sp.PredictPeaks(peptide, 2, 1950, msExperimental, 500);

            DataGridResultTable.ItemsSource = theoreticalSpectrum;



            SpectrumEye1.Plot(msExperimental.Ions, msExperimental.Ions[0].MZ, msExperimental.Ions.Last().MZ, ppm, theoreticalSpectrum);
        }
        private void buttonPlot_Click(object sender, RoutedEventArgs e)
        {
            Plot();

            //Evaluate the spectrum quality
            PatternTools.SpectraPrediction.SpectralPredictionParameters spm = new SpectralPredictionParameters(
                true,
                true,
                true,
                true,
                true,
                true,
                false,
                false,
                1,
                true,
                Modifications
                );

            PatternTools.SpectraPrediction.SpectraPredictor sp = new SpectraPredictor(spm);
            List <PredictedIon> theoretical = sp.PredictPeaks(textBoxSequence.Text, ChargeState, TheoreticalMH);

            List <Ion> filteredList = myMS.FindAll(a => a.Intensity > double.Parse(textBoxRelativeIntensityThreshold.Text));

            List <SpectralMatchEvaluator.TheTests> evaluationTests = new List <SpectralMatchEvaluator.TheTests>()
            {
                SpectralMatchEvaluator.TheTests.AllTests
            };

            PatternTools.SpectralMatchEvaluator.SpectrumComparisonResult spectrumEvaluationResult =
                PatternTools.SpectralMatchEvaluator.Compare.Do(
                    evaluationTests,
                    theoretical,
                    filteredList,
                    double.Parse(textBoxPPM.Text),
                    textBoxSequence.Text.Length,
                    RelativeIntensityThreshold
                    );

            PatternTools.SpectralMatchEvaluator.Compare.PrintResults(spectrumEvaluationResult);
        }
        public void Plot(List <PredictedIon> peaks = null)
        {
            myMS.Sort((a, b) => a.MZ.CompareTo(b.MZ));

            if (peaks == null)
            {
                SpectralPredictionParameters spp = new SpectralPredictionParameters
                                                       ((bool)checkBoxA.IsChecked,
                                                       (bool)checkBoxB.IsChecked,
                                                       (bool)checkBoxC.IsChecked,
                                                       (bool)checkBoxX.IsChecked,
                                                       (bool)checkBoxY.IsChecked,
                                                       (bool)checkBoxZ.IsChecked,
                                                       (bool)checkBoxNLH2O.IsChecked,
                                                       (bool)checkBoxNLNH3.IsChecked,
                                                       3,
                                                       (bool)checkBoxIsMonoisotopic.IsChecked,
                                                       Modifications
                                                       );

                if (Modifications == null)
                {
                    spp.MyModifications = new List <ModificationItem>();
                }
                PatternTools.SpectraPrediction.SpectraPredictor sp = new PatternTools.SpectraPrediction.SpectraPredictor(spp);

                if (textBoxSequence.Text.Length > 0)
                {
                    peaks = sp.PredictPeaks(textBoxSequence.Text, ChargeState, TheoreticalMH);
                    if (!(bool)checkBoxZ1.IsChecked)
                    {
                        peaks.RemoveAll(a => a.Charge == 1 && a.Series != IonSeries.Precursor);
                    }
                    if (!(bool)checkBoxZ2.IsChecked)
                    {
                        peaks.RemoveAll(a => a.Charge == 2 && a.Series != IonSeries.Precursor);
                    }
                    if (!(bool)checkBoxZ3.IsChecked)
                    {
                        peaks.RemoveAll(a => a.Charge == 3 && a.Series != IonSeries.Precursor);
                    }
                }
                else
                {
                    peaks = new List <PredictedIon>();
                }
            }

            dataGridPeakViewer.ItemsSource = peaks;

            try
            {
                if (textBoxSequence.Text.Length == 0)
                {
                    FuncPrintMS(myMS, IonsInDisplay[0].MZ, IonsInDisplay[IonsInDisplay.Count - 1].MZ, false);
                }
                else
                {
                    FuncPrintMS(myMS, IonsInDisplay[0].MZ, IonsInDisplay[IonsInDisplay.Count - 1].MZ, true);
                }
            }
            catch (Exception eee)
            {
                Console.WriteLine(eee.Message);
            }

            double matches = peaks.FindAll(a => a.Matched == true).Count;
            double total   = peaks.Count;

            labelPeaksProduced.Content = matches + " / " + total + " = " + Math.Round(matches / total, 1) * 100 + "%";


            // Plot the denovo
            canvasDenovo.Children.Clear();
            if ((bool)checkBoxB.IsChecked)
            {
                labelABC.Content = "B:";
                PlotSequence(peaks, IonSeries.B, 13, Brushes.Red);
            }
            else if ((bool)checkBoxC.IsChecked)
            {
                labelABC.Content = "C:";
                PlotSequence(peaks, IonSeries.C, 13, Brushes.Red);
            }
            else if ((bool)checkBoxA.IsChecked)
            {
                labelABC.Content = "A:";
                PlotSequence(peaks, IonSeries.A, 13, Brushes.Red);
            }
            else
            {
                labelABC.Content = "";
            }

            if ((bool)checkBoxY.IsChecked)
            {
                labelXYZ.Content = "Y:";
                PlotSequence(peaks, IonSeries.Y, 40, Brushes.Blue);
            }
            else if ((bool)checkBoxZ.IsChecked)
            {
                labelXYZ.Content = "Z:";
                PlotSequence(peaks, IonSeries.Z, 40, Brushes.Blue);
            }
            else if ((bool)checkBoxX.IsChecked)
            {
                labelXYZ.Content = "X:";
                PlotSequence(peaks, IonSeries.X, 40, Brushes.Blue);
            }
            else
            {
                labelXYZ.Content = "";
            }

            //Display peptide of theoretical spectrum
            Label peptideSequenceLabel = new Label();

            peptideSequenceLabel.FontSize   = 10;
            peptideSequenceLabel.Content    = textBoxSequence.Text + " (" + textBoxSequence.Text.Count() + ")";
            peptideSequenceLabel.FontWeight = FontWeights.Light;
            peptideSequenceLabel.Foreground = Brushes.Gray;

            canvasMS.Children.Add(peptideSequenceLabel);
            Canvas.SetLeft(peptideSequenceLabel, -2);
            Canvas.SetTop(peptideSequenceLabel, 0);
        }