public PeakList <T> Process(PeakList <T> t)
        {
            if (t.PrecursorCharge > 0)
            {
                var isobaricList  = new List <T>();
                var mzPrecursor   = PrecursorUtils.ppm2mz(t.PrecursorMZ, options.PPMTolerance);
                var precursurIons = FindPeakConsideringCharge(t, t.PrecursorMZ, t.PrecursorCharge, mzPrecursor);

                //First of all, we need to find precursor
                if (precursurIons.Count > 0)
                {
                    precursurIons.ForEach(m => { t.Remove(m); });

                    isobaricList.Add(new T()
                    {
                        Mz        = t.PrecursorMZ,
                        Charge    = t.PrecursorCharge,
                        Intensity = mzPrecursor
                    });

                    if (options.RemoveChargeMinus1Precursor && t.PrecursorCharge > 1)
                    {
                        //Get charge-1 precursor
                        var p1mz     = PrecursorUtils.MHToMz(PrecursorUtils.MzToMH(t.PrecursorMZ, t.PrecursorCharge, true), t.PrecursorCharge - 1, true);
                        var p1Window = PrecursorUtils.ppm2mz(p1mz, options.PPMTolerance);
                        var p1Ions   = FindPeakConsideringCharge(t, p1mz, t.PrecursorCharge - 1, p1Window);
                        if (p1Ions.Count > 0)
                        {
                            p1Ions.ForEach(m => { t.Remove(m); });

                            isobaricList.Add(new T()
                            {
                                Mz        = p1mz,
                                Charge    = t.PrecursorCharge - 1,
                                Intensity = p1Window
                            });
                        }
                    }

                    if (options.RemoveIsotopicIons)
                    {
                        foreach (var ion in isobaricList)
                        {
                            RemoveIsotopicIons(t, ion);
                        }
                    }
                }

                foreach (var offset in offsets)
                {
                    var mz       = t.PrecursorMZ + offset / t.PrecursorCharge;
                    var mzWindow = PrecursorUtils.ppm2mz(mz, options.PPMTolerance);

                    var minMz = mz - mzWindow;
                    var maxMz = mz + mzWindow;

                    t.RemoveAll(m =>
                    {
                        if (m.Charge == t.PrecursorCharge || m.Charge == 0)
                        {
                            return(m.Mz >= minMz && m.Mz <= maxMz);
                        }
                        else
                        {
                            return(false);
                        }
                    });
                }

                if (options.RemoveIonLargerThanPrecursor)
                {
                    var pmass = PrecursorUtils.MzToMH(t.PrecursorMZ, t.PrecursorCharge, true);
                    t.RemoveAll(m =>
                    {
                        var mass = m.Charge > 0 ? PrecursorUtils.MzToMH(m.Mz, m.Charge, true) : m.Mz;
                        return(mass >= pmass);
                    });
                }
            }

            return(t);
        }
コード例 #2
0
 public double GetTheoreticalMz()
 {
     return(PrecursorUtils.MHToMz(TheoreticalMH, Query.Charge, IsPrecursorMonoisotopic));
 }
コード例 #3
0
        public PeakList <T> ReadFromFile(string dtaFilename)
        {
            var fi = new FileInfo(dtaFilename);

            if (!fi.Exists)
            {
                throw new FileNotFoundException("Cannot find the file " + dtaFilename);
            }

            var             result = new PeakList <T>();
            SequestFilename sf     = SequestFilename.Parse(fi.Name);

            result.Experimental = sf.Experimental;
            result.ScanTimes.Add(new ScanTime(sf.FirstScan, 0.0));
            if (sf.FirstScan != sf.LastScan)
            {
                result.ScanTimes.Add(new ScanTime(sf.LastScan, 0.0));
            }
            result.PrecursorCharge = sf.Charge;

            using (var filein = new StreamReader(new FileStream(dtaFilename, FileMode.Open, FileAccess.Read)))
            {
                string lastline;
                while ((lastline = filein.ReadLine()) != null)
                {
                    if (lastline.Trim().Length > 0)
                    {
                        break;
                    }
                }
                if (lastline == null)
                {
                    return(null);
                }

                string[] parts         = Regex.Split(lastline, @"\s+");
                double   precursorMass = MyConvert.ToDouble(parts[0]);
                result.PrecursorCharge = int.Parse(parts[1]);
                result.PrecursorMZ     = PrecursorUtils.MHToMz(precursorMass, result.PrecursorCharge, true);

                while ((lastline = filein.ReadLine()) != null)
                {
                    if (lastline.Length == 0)
                    {
                        continue;
                    }

                    if (lastline[0] == '>')
                    {
                        break;
                    }

                    string[] peakParts = Regex.Split(lastline, @"\s+");
                    var      peak      = new T();
                    peak.Mz        = MyConvert.ToDouble(peakParts[0]);
                    peak.Intensity = MyConvert.ToDouble(peakParts[1]);
                    if (peakParts.Length > 2)
                    {
                        peak.Charge = int.Parse(peakParts[2]);
                    }

                    result.Add(peak);
                }

                return(result);
            }
        }
コード例 #4
0
 public double GetPrecursorMz()
 {
     return(PrecursorUtils.MHToMz(ExperimentalMH, Query.Charge, IsPrecursorMonoisotopic));
 }