public List <MatchedPeak> GetNeutralLossPeaks(IonType targetPeakType, MatchedPeak sourcePeak, List <INeutralLossType> nlCandidates, Func <INeutralLossType, bool> filter)
        {
            List <INeutralLossType> nlTypes = new NeutralLossGenerator().GetTotalCombinationValues(nlCandidates, NeutralLossLevel);

            nlTypes.RemoveAll(m => !filter(m));

            List <MatchedPeak> result = new List <MatchedPeak>();

            foreach (INeutralLossType nlType in nlTypes)
            {
                double nlMass = sourcePeak.Mz - nlType.Mass / sourcePeak.Charge;

                MatchedPeak nlPeak = new MatchedPeak(nlMass, 1.0, sourcePeak.Charge)
                {
                    PeakType  = targetPeakType,
                    PeakIndex = sourcePeak.PeakIndex
                };

                nlPeak.DisplayName = GetDisplayName(nlType, sourcePeak, nlPeak);

                result.Add(nlPeak);
            }

            result.Sort();

            return(result);
        }
示例#2
0
        public void TestGetPrecursorNeutralLossPeaks()
        {
            List <INeutralLossType> nls = new INeutralLossType[] { NeutralLossConstants.NL_H3PO4 }.ToList();

            MatchedPeak        precursor = new MatchedPeak(1000, 0, 2);
            List <MatchedPeak> pkls      = matcher.GetNeutralLossPeaks(IonType.PRECURSOR_NEUTRAL_LOSS_PHOSPHO, precursor, nls, (m => m.IsPhosphoNeutralLossType()));

            Assert.AreEqual("[MH2-H3PO4]", pkls[0].DisplayName);
            Assert.AreEqual(1000 - NeutralLossConstants.NL_H3PO4.Mass / 2, pkls[0].Mz, 0.01);

            precursor.Charge = 1;
            pkls             = matcher.GetNeutralLossPeaks(IonType.PRECURSOR_NEUTRAL_LOSS_PHOSPHO, precursor, nls, (m => m.IsPhosphoNeutralLossType()));
            Assert.AreEqual("[MH-H3PO4]", pkls[0].DisplayName);
            Assert.AreEqual(1000 - NeutralLossConstants.NL_H3PO4.Mass, pkls[0].Mz, 0.01);
        }
        private static Rectangle GetSpectrumRectangle(Graphics g2, PeakList <MatchedPeak> peaks, Rectangle rec)
        {
            MatchedPeak maxIntensityPeak = peaks.FindMaxIntensityPeak();

            MatchedPeak highestPeak = maxIntensityPeak;

            RectangleTransform rt = new RectangleTransform(rec, 1.0, highestPeak.Intensity);
            int top = rt.GetTransformY(highestPeak.Intensity);
            int highestTextLength = 0;

            if (highestPeak.Matched)
            {
                highestTextLength = 10 + (int)GetStringWidth(g2, bigFont, highestPeak.Information);
                top -= highestTextLength;
            }

            foreach (MatchedPeak peak in peaks)
            {
                if (!peak.Matched)
                {
                    continue;
                }

                int textLength  = 10 + (int)GetStringWidth(g2, bigFont, peak.Information);
                int totalLength = rt.GetTransformY(peak.Intensity) - textLength;

                if (totalLength < top)
                {
                    highestTextLength = textLength;
                    top         = totalLength;
                    highestPeak = peak;
                }
            }

            int peakIntensityLength = rec.Height - highestTextLength;
            int recHeight           = (int)(peakIntensityLength * maxIntensityPeak.Intensity / highestPeak.Intensity);

            return(new Rectangle(rec.Left, rec.Bottom - recHeight, rec.Width, recHeight));
        }
        public void TestInformation()
        {
            MatchedPeak p = new MatchedPeak(1000, 0.0, 2);

            p.DisplayName = "TEST";
            Assert.AreEqual("TEST++   1000.0000", p.Information);

            p.Charge = 1;
            Assert.AreEqual("TEST   1000.0000", p.Information);

            p.DisplayName = null;
            p.PeakType    = IonType.PRECURSOR;
            Assert.AreEqual("[MH]   1000.0000", p.Information);

            p.Charge = 2;
            Assert.AreEqual("[MH2]++   1000.0000", p.Information);

            p.PeakType  = IonType.B2;
            p.PeakIndex = 5;
            Assert.AreEqual("b5++   1000.0000", p.Information);

            p.Charge = 1;
            Assert.AreEqual("b5   1000.0000", p.Information);
        }
示例#5
0
 public static string GetBYIonDisplayName(INeutralLossType nlType, MatchedPeak sourcePeak, MatchedPeak targetPeak)
 {
     return(MyConvert.Format("[{0}{1}-{2}]", sourcePeak.PeakType.GetDisplayName(), sourcePeak.PeakIndex, nlType.Name));
 }
示例#6
0
 public static string GetPrecursorDisplayName(INeutralLossType nlType, MatchedPeak sourcePeak, MatchedPeak targetPeak)
 {
     return(MyConvert.Format("[MH{0}-{1}]", targetPeak.Charge == 1 ? "" : targetPeak.Charge.ToString(), nlType.Name));
 }
示例#7
0
 protected void AssertPeak(MatchedPeak p, string displayName, double mz)
 {
     Assert.AreEqual(displayName, p.DisplayName);
     Assert.AreEqual(mz, p.Mz, 0.01);
 }