protected void AppendScan(List <IsobaricItem> result, int scan, string mode, double isolationWidth)
        {
            IsobaricItem item = new IsobaricItem();

            PeakList <Peak> pkl = RawReader.GetPeakList(scan, MinMz, MaxMz);

            if (pkl.Count < MinPeakCount)
            {
                return;
            }

            var recordScan = GetIdentificationScan(scan);

            if (pkl.ScanTimes.Count == 0)
            {
                pkl.ScanTimes.Add(RawReader.GetScanTime(recordScan));
            }

            item.ScanMode = mode;
            item.RawPeaks = pkl;
            item.PeakInIsolationWindow = RawReader.GetPeakInIsolationWindow(scan, isolationWidth);
            item.PlexType = this.PlexType;

            result.Add(item);
        }
        public override List <IsobaricItem> ReadFromFile(string fileName)
        {
            var result = new List <IsobaricItem>();

            RawReader.Open(fileName);
            try
            {
                int startScan = RawReader.GetFirstSpectrumNumber();
                int endScan   = RawReader.GetLastSpectrumNumber();

                Progress.SetRange(startScan, endScan);

                for (int scan = startScan; scan <= endScan; scan++)
                {
                    if (Progress.IsCancellationPending())
                    {
                        throw new UserTerminatedException();
                    }

                    Progress.SetPosition(scan);

                    if (2 == RawReader.GetMsLevel(scan))
                    {
                        string scanMode = RawReader.GetScanMode(scan);
                        if (string.IsNullOrEmpty(scanMode))
                        {
                            AppendScan(result, scan, "UNKNOWN");
                            continue;
                        }

                        scanMode = scanMode.ToLower();
                        if (scanMode.Equals("pqd"))
                        {
                            AppendScan(result, scan, "PQD");
                        }
                        else if (scanMode.Equals("cid"))
                        {
                            //如果上一个scan是pqd,那么,现在这个cid的结果从该pqd读取。
                            if (result.Count > 0 && result[result.Count - 1].RawPeaks.ScanTimes[0].Scan == scan - 1 && result[result.Count - 1].RawPeaks.ScanMode == "PQD")
                            {
                                var lastItem = result[result.Count - 1];

                                var item = new IsobaricItem(lastItem);
                                item.Scan     = RawReader.GetScanTime(scan);
                                item.ScanMode = "CID";

                                result.Add(item);
                            }
                            else//否则,从自己的peaklist中读取。
                            {
                                AppendScan(result, scan, "CID");
                            }
                        }
                        else
                        {
                            Console.WriteLine("Scan {0} is skipped with mode {1}", scan, scanMode);
                        }
                    }
                }
            }
            finally
            {
                RawReader.Close();
            }

            return(result);
        }