private void WriteToOutFiles(MassSpectrum spec)
        {
            // MS1 file;
            if (_ms1Writer != null && spec.MsLevel == 1)
            {
                if (_isFirstMS1Scan)
                {
                    TextFileWriter.WriteMSnHeader(_ms1Writer, "MS1", LastScanNum, spec);
                    _isFirstMS1Scan = false;
                }
                TextFileWriter.WriteToMS1(_ms1Writer, spec, mzDecimalPlace, intensityDecimalPlace, showPeakChargeState, showPeakResolution);
            }

            // MS2 file;
            if (_ms2Writer != null && spec.MsLevel == 2)
            {
                if (_isFirstMS2Scan)
                {
                    TextFileWriter.WriteMSnHeader(_ms2Writer, "MS2", LastScanNum, spec);
                    _isFirstMS2Scan = false;
                }
                //TextFileWriter.WriteToMSn(_ms2Writer, spec, mzDecimalPlace, intensityDecimalPlace, showPeakChargeState, showPeakResolution,_verifyWriter);
                if (expType == ExperimentType.DIA && predictPrecursors)
                {
                    TextFileWriter.WriteToMSnWithDuplicates(_ms2Writer, spec, mzDecimalPlace, intensityDecimalPlace, showPeakChargeState, showPeakResolution);
                }
                else
                {
                    TextFileWriter.WriteToMSn(_ms2Writer, spec, mzDecimalPlace, intensityDecimalPlace, showPeakChargeState, showPeakResolution);
                }
            }

            // MS3 file;
            if (_ms3Writer != null && spec.MsLevel == 3)
            {
                if (_isFirstMS3Scan)
                {
                    TextFileWriter.WriteMSnHeader(_ms3Writer, "MS3", LastScanNum, spec);
                    _isFirstMS3Scan = false;
                }
                TextFileWriter.WriteToMSn(_ms3Writer, spec, mzDecimalPlace, intensityDecimalPlace, showPeakChargeState, showPeakResolution);
            }

            // MGF file;
            if (_mgfWriter != null && spec.MsLevel == 2)
            {
                TextFileWriter.WriteToMGF(_mgfWriter, spec, rawFileName, mzDecimalPlace, intensityDecimalPlace, showPeakChargeState, showPeakResolution);
            }

            // mzXML file;
            if (_mzXMLWriter != null)
            {
                _mzXMLWriter.WriteScan(spec);
            }
        }
        private void WriteToOutFiles(MassSpectrum spec, bool isFirstScan)
        {
            // MS1 file;
            if (_ms1Writer != null && spec.MsLevel == 1)
            {
                if (_isFirstMS1Scan)
                {
                    TextFileWriter.WriteMSnHeader(_ms1Writer, "MS1", _scanCount, spec);
                    _isFirstMS1Scan = false;
                }
                TextFileWriter.WriteToMS1(_ms1Writer, spec, _mzDecimalPlace, _intensityDecimalPlace, false, false);
            }

            // MS2 file;
            if (_ms2Writer != null && spec.MsLevel == 2)
            {
                if (_isFirstMS2Scan)
                {
                    TextFileWriter.WriteMSnHeader(_ms2Writer, "MS2", _scanCount, spec);
                    _isFirstMS2Scan = false;
                }
                TextFileWriter.WriteToMSn(_ms2Writer, spec, _mzDecimalPlace, _intensityDecimalPlace, false, false);
            }

            // MS3 file;
            if (_ms3Writer != null && spec.MsLevel == 3)
            {
                if (_isFirstMS3Scan)
                {
                    TextFileWriter.WriteMSnHeader(_ms3Writer, "MS3", _scanCount, spec);
                    _isFirstMS3Scan = false;
                }
                TextFileWriter.WriteToMSn(_ms3Writer, spec, _mzDecimalPlace, _intensityDecimalPlace, false, false);
            }

            // MGF file;
            if (_mgfWriter != null && spec.MsLevel == 2)
            {
                TextFileWriter.WriteToMGF(_mgfWriter, spec, _mzxmlFileName, _mzDecimalPlace, _intensityDecimalPlace, false, false);
            }
        }