예제 #1
0
파일: Form1.cs 프로젝트: fcyu/ECLViewer2
        private AnnotatedPeak matchXLIon(KeyValuePair <float, int> peak, int charge)
        {
            int tempSite1 = 0;
            int tempSite2 = 0;

            if (currentSite1 > 0)
            {
                tempSite1 = currentSite1 - 1;
            }
            if (currentSite2 > 0)
            {
                tempSite2 = currentSite2 - 1;
            }

            AnnotatedPeak annotatedPeak = null;
            bool          matched       = false;
            int           bIonIdx       = (charge - 1) * 2;
            int           yIonIdx       = bIonIdx + 1;

            for (int i = tempSite1; i < currentPeptideClIon1.GetLength(1); ++i)
            {
                if (Math.Abs(peak.Key - currentPeptideClIon1[bIonIdx, i]) <= ms2Tolerance)
                {
                    annotatedPeak = new AnnotatedPeak(peak.Value, "\u03B1", i + 1, charge, "b");
                    matched       = true;
                    break;
                }
            }

            if (!matched)
            {
                for (int i = 0; i < tempSite1 + 1; ++i)
                {
                    if (Math.Abs(peak.Key - currentPeptideClIon1[yIonIdx, i]) <= ms2Tolerance)
                    {
                        annotatedPeak = new AnnotatedPeak(peak.Value, "\u03B1", currentPeptideClIon1.GetLength(1) - i, charge, "y");
                        matched       = true;
                        break;
                    }
                }
            }

            if (!matched)
            {
                for (int i = tempSite2; i < currentPeptideClIon2.GetLength(1); ++i)
                {
                    if (Math.Abs(peak.Key - currentPeptideClIon2[bIonIdx, i]) <= ms2Tolerance)
                    {
                        annotatedPeak = new AnnotatedPeak(peak.Value, "\u03B2", i + 1, charge, "b");
                        matched       = true;
                        break;
                    }
                }
            }

            if (!matched)
            {
                for (int i = 0; i < currentSite2 + 1; ++i)
                {
                    if (Math.Abs(peak.Key - currentPeptideClIon2[yIonIdx, i]) <= ms2Tolerance)
                    {
                        annotatedPeak = new AnnotatedPeak(peak.Value, "\u03B2", currentPeptideClIon2.GetLength(1) - i, charge, "y");
                        matched       = true;
                        break;
                    }
                }
            }

            return(annotatedPeak);
        }
예제 #2
0
파일: Form1.cs 프로젝트: fcyu/ECLViewer2
        private void plotSpectrum()
        {
            SortedDictionary <float, float>         unmatchedPeaks = new SortedDictionary <float, float>();
            SortedDictionary <float, AnnotatedPeak> matchedPeak    = new SortedDictionary <float, AnnotatedPeak>();
            float smallestMz   = 99999;
            float maxIntensity = 0;

            foreach (KeyValuePair <float, int> peak in currentPeakList)
            {
                if (peak.Key < smallestMz)
                {
                    smallestMz = peak.Key;
                }

                if (peak.Value > maxIntensity)
                {
                    maxIntensity = peak.Value;
                }

                AnnotatedPeak annotatedPeak = null;

                if (checkBox1.Checked)
                {
                    annotatedPeak = matchLinearIon(peak, 1);
                }

                if ((annotatedPeak == null) && checkBox2.Checked)
                {
                    annotatedPeak = matchLinearIon(peak, 2);
                }

                if ((annotatedPeak == null) && checkBox3.Checked)
                {
                    annotatedPeak = matchLinearIon(peak, 3);
                }

                if ((annotatedPeak == null) && checkBox4.Checked)
                {
                    annotatedPeak = matchXLIon(peak, 2);
                }

                if ((annotatedPeak == null) && checkBox5.Checked)
                {
                    annotatedPeak = matchXLIon(peak, 3);
                }

                if ((annotatedPeak == null) && checkBox6.Checked)
                {
                    annotatedPeak = matchXLIon(peak, 4);
                }

                if ((annotatedPeak == null) && checkBox7.Checked)
                {
                    annotatedPeak = matchXLIon(peak, 5);
                }

                if (annotatedPeak == null)
                {
                    unmatchedPeaks[peak.Key] = peak.Value;
                }
                else
                {
                    matchedPeak[peak.Key] = annotatedPeak;
                }
            }

            PlotModel plotModel = new PlotModel {
                Title = String.Format("Spectrum: {0}.{1}", currentScanNum, currentCharge)
            };

            // make the y-axis limit bigger.
            DataPointSeries transparntSeries = new StemSeries {
                MarkerType = MarkerType.None, Color = OxyColors.Transparent
            };

            transparntSeries.Points.Add(new DataPoint(smallestMz - 1, maxIntensity * 1.1));
            plotModel.Series.Add(transparntSeries);

            // unmatched peaks
            DataPointSeries unmatchedSeries = new StemSeries {
                MarkerType = MarkerType.None, Color = OxyColors.Gray, StrokeThickness = 0.5
            };

            foreach (KeyValuePair <float, float> peak in unmatchedPeaks)
            {
                unmatchedSeries.Points.Add(new DataPoint(peak.Key, peak.Value));
            }
            plotModel.Series.Add(unmatchedSeries);

            // matched peaks
            DataPointSeries matchedSeries = new StemSeries {
                MarkerType = MarkerType.None, Color = OxyColors.Blue, StrokeThickness = 0.5
            };

            foreach (KeyValuePair <float, AnnotatedPeak> peak in matchedPeak)
            {
                matchedSeries.Points.Add(new DataPoint(peak.Key, peak.Value.intensity));
                AnnotatedPeak annotatedPeak = peak.Value;
                string        annotateText  = annotatedPeak.chainType + annotatedPeak.byType + annotatedPeak.fragmentLocation;
                for (int i = 0; i < annotatedPeak.charge; ++i)
                {
                    annotateText += "+";
                }
                Annotation ann = new PointAnnotation {
                    Shape = MarkerType.None, Size = 0, TextVerticalAlignment = VerticalAlignment.Bottom, X = peak.Key, Y = annotatedPeak.intensity, Text = annotateText
                };
                plotModel.Annotations.Add(ann);
            }
            plotModel.Series.Add(matchedSeries);
            plotViewSpectrum.Model = plotModel;
        }