コード例 #1
0
        public static SrmPairedResult ToPairedResult(this List <SrmTransition> transList)
        {
            SrmPairedResult result = new SrmPairedResult();

            //所有母离子有相同名称、相同质荷比认为是来自相同precursor,合并为一个peptide。
            var pepgroup = transList.GroupBy(m => m.PrecursorFormula + MyConvert.Format("{0:0.0000}", m.PrecursorMZ));
            var peptides = new List <SrmPeptideItem>();

            foreach (var g in pepgroup)
            {
                var pep = new SrmPeptideItem();
                pep.PrecursorMZ = g.First().PrecursorMZ;
                pep.ProductIons = new List <SrmTransition>(g);
                peptides.Add(pep);
            }

            //具有相同母离子名称和电荷的transition认为是轻重标。
            var lhgroup = peptides.GroupBy(m => m.ProductIons[0].PrecursorFormula + "_" + m.ProductIons[0].PrecursorCharge.ToString()).ToList();

//      var lhgroup = peptides.GroupBy(m => m.ProductIons[0].PrecursorFormula + "_" + m.ProductIons[0].PrecursorCharge.ToString()).ToList();
            foreach (var g in lhgroup)
            {
                if (g.Count() > 2)
                {
                    throw new Exception(string.Format("There are {0} transition with same precursor formula and precursor charge: {1}, {2}", g.Count(), g.First().ProductIons[0].PrecursorFormula, g.First().ProductIons[0].PrecursorCharge));
                }
                else if (g.Count() > 1)
                {
                    var items = g.ToList();
                    items.Sort((m1, m2) => m1.PrecursorMZ.CompareTo(m2.PrecursorMZ));
                    SrmPairedPeptideItem light = new SrmPairedPeptideItem(items[0]);
                    SrmPairedPeptideItem heavy = new SrmPairedPeptideItem(items[1]);

                    if (!string.IsNullOrEmpty(light.ProductIonPairs[0].Light.Ion))
                    {
                        light.SetHeavyPeptideItemByIon(heavy);
                    }
                    else
                    {
                        light.SetHeavyPeptideItem(heavy);
                    }
                    result.Add(light);
                }
                else
                {
                    SrmPairedPeptideItem light = new SrmPairedPeptideItem(g.First());
                    result.Add(light);
                }
            }

            return(result);
        }
コード例 #2
0
        private SrmPairedResult BuildResultBasedOnRealData(List <SrmTransition> mrms)
        {
            SrmPairedResult mrmPairs;
            //将Transaction转换为MRMPeptideItem
            var peptides = new List <SrmPeptideItem>();

            foreach (var mrm in mrms)
            {
                bool bFound = false;
                foreach (var pep in peptides)
                {
                    if (mrm.IsBrother(pep.ProductIons[0], this.options.RetentionTimeToleranceInSecond, 0.0001))
                    {
                        pep.ProductIons.Add(mrm);
                        bFound = true;
                        break;
                    }
                }

                if (!bFound)
                {
                    SrmPeptideItem item = new SrmPeptideItem();
                    item.PrecursorMZ = mrm.PrecursorMZ;
                    item.ProductIons.Add(mrm);
                    peptides.Add(item);
                }
            }

            //按照precursormz排序
            foreach (var pep in peptides)
            {
                pep.ProductIons.Sort((m1, m2) => m1.ProductIon.CompareTo(m2.ProductIon));
            }

            mrmPairs = new SrmPairedResult();
            mrmPairs.AddRange(from p in peptides
                              orderby p.PrecursorMZ
                              select new SrmPairedPeptideItem(p));

            //合并ProductIon完全一样或者差距相同的Item
            for (int i = 0; i < mrmPairs.Count; i++)
            {
                var iLight = mrmPairs[i];

                for (int j = i + 1; j < mrmPairs.Count; j++)
                {
                    var jLight = mrmPairs[j];

                    if (Math.Abs(iLight.LightPrecursorMZ - jLight.LightPrecursorMZ) > this.options.MaxPrecursorDistance)
                    {
                        continue;
                    }

                    if (iLight.AddPerfectPairedPeptideItem(jLight, this.options.AllowedGaps, this.options.MzTolerance, this.options.RetentionTimeToleranceInSecond))
                    {
                        mrmPairs.RemoveAt(j);
                        break;
                    }
                }
            }

            //容错情况下,合并ProductIon完全一样或者差距相同的Item
            for (int i = 0; i < mrmPairs.Count; i++)
            {
                var iLight = mrmPairs[i];
                if (iLight.IsPaired)
                {
                    continue;
                }

                for (int j = i + 1; j < mrmPairs.Count; j++)
                {
                    var jLight = mrmPairs[j];

                    if (jLight.IsPaired)
                    {
                        continue;
                    }

                    if (Math.Abs(iLight.LightPrecursorMZ - jLight.LightPrecursorMZ) > this.options.MaxPrecursorDistance)
                    {
                        continue;
                    }

                    if (iLight.AddErrorPairedPeptideItem(jLight, this.options.AllowedGaps, this.options.MzTolerance, this.options.RetentionTimeToleranceInSecond))
                    {
                        mrmPairs.RemoveAt(j);
                        break;
                    }
                }
            }
            return(mrmPairs);
        }
コード例 #3
0
 public SrmPairedPeptideItem(SrmPeptideItem light)
 {
     Enabled         = true;
     ProductIonPairs = (from p in light.ProductIons
                        select new SrmPairedProductIon(p)).ToList();
 }