/// <summary>
        /// ParallelMS3: MS1->MS2->MS2->MS3->MS3->MS1->...
        /// Otherwise:   MS1->MS2->MS3->MS2->MS3->MS1->...
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="isParallelMS3">True:MS1->MS2->MS2->MS3->MS3->MS1</param>
        /// <returns></returns>
        public static IRawFile2 GetRawFileReader(string fileName, bool isParallelMS3 = false)
        {
            IRawFile2 result = DoGetRawFileReader(fileName, isParallelMS3);

            result.Open(fileName);

            return(result);
        }
        protected List <PeakList <Peak> > ReadTandemMassFromRaw(FileInfo rawFilename, List <int> ignoreScans)
        {
            string experimental = FileUtils.ChangeExtension(rawFilename.Name, "");

            var result = new List <PeakList <Peak> >();

            bool bReadAgain = false;

            rawReader.Open(rawFilename.FullName);
            try
            {
                int firstSpectrumNumber = rawReader.GetFirstSpectrumNumber();
                int lastSpectrumNumber  = rawReader.GetLastSpectrumNumber();

                Progress.SetRange(firstSpectrumNumber, lastSpectrumNumber);
                Progress.Begin();
                try
                {
                    for (int scan = firstSpectrumNumber; scan <= lastSpectrumNumber; scan++)
                    {
                        if (Progress.IsCancellationPending())
                        {
                            throw new UserTerminatedException();
                        }

                        if (ignoreScans.Contains(scan))
                        {
                            continue;
                        }

                        Progress.SetPosition(scan);

                        int msLevel = rawReader.GetMsLevel(scan);

                        if (msLevel > 1)
                        {
                            PeakList <Peak> pkl;
                            try
                            {
                                pkl = rawReader.GetPeakList(scan);
                            }
                            catch (RawReadException ex)
                            {
                                ignoreScans.Add(ex.Scan);
                                File.WriteAllLines(GetIgnoreScanFile(rawFilename), (from i in ignoreScans
                                                                                    let s = i.ToString()
                                                                                            select s).ToArray());
                                bReadAgain = true;
                                break;
                            }
                            pkl.Precursor    = rawReader.GetPrecursorPeakWithMasterScan(scan);
                            pkl.MsLevel      = msLevel;
                            pkl.Experimental = experimental;
                            pkl.ScanTimes.Add(new ScanTime(scan, rawReader.ScanToRetentionTime(scan)));
                            pkl.ScanMode = rawReader.GetScanMode(scan);

                            if (pkl.PrecursorCharge == 0)
                            {
                                pkl.PrecursorCharge = PrecursorUtils.GuessPrecursorCharge(pkl, pkl.PrecursorMZ);
                            }

                            PeakList <Peak> pklProcessed = this.pklProcessor.Process(pkl);
                            if (null != pklProcessed && pklProcessed.Count > 0)
                            {
                                result.Add(pklProcessed);
                            }
                        }
                    }
                }
                finally
                {
                    Progress.End();
                }
            }
            finally
            {
                rawReader.Close();
            }

            if (bReadAgain)
            {
                return(ReadTandemMassFromRaw(rawFilename, ignoreScans));
            }
            else
            {
                return(result);
            }
        }
 public void Open(string fileName)
 {
     rawFile.Open(fileName);
 }