Пример #1
0
        private static void WritePScans(string fileName,
                                        IRawDataPlus raw,
                                        List <PScan> scans)
        {
            var enumerator = raw.GetFilteredScanEnumerator(" ");

            foreach (var scanNumber in enumerator) // note in my tests serial is faster than Parallel.Foreach() (this involves disk access, so it makes sense)
            {
                //trailer iinformation is extracted via index
                var    trailers      = raw.GetTrailerExtraValues(scanNumber);
                var    trailerLabels = raw.GetTrailerExtraInformation(scanNumber);
                object chargeState   = 0;
                for (int i = 0; i < trailerLabels.Labels.Length; i++)
                {
                    if (trailerLabels.Labels[i] == "Charge State:")
                    {
                        chargeState = raw.GetTrailerExtraValue(scanNumber, i);
                        break;
                    }
                }
                var scanFilter = raw.GetFilterForScanNumber(scanNumber);
                var scanStats  = raw.GetScanStatsForScanNumber(scanNumber);

                CentroidStream centroidStream = new CentroidStream();

                //check for FT mass analyzer data
                if (scanFilter.MassAnalyzer == MassAnalyzerType.MassAnalyzerFTMS)
                {
                    centroidStream = raw.GetCentroidStream(scanNumber, false);
                }
                //check for IT mass analyzer data
                if (scanFilter.MassAnalyzer == MassAnalyzerType.MassAnalyzerITMS)
                {
                    var scanData = raw.GetSimplifiedScan(scanNumber);
                    centroidStream.Masses      = scanData.Masses;
                    centroidStream.Intensities = scanData.Intensities;
                }

                var msOrder = raw.GetScanEventForScanNumber(scanNumber).MSOrder;

                if (msOrder == MSOrderType.Ms)
                {
                    var pscan = GetPScan(scanStats, centroidStream, 1, fileName, Convert.ToInt32(chargeState));
                    scans.Add(pscan);
                }
                if (msOrder == MSOrderType.Ms2)
                {
                    var precursorMz = raw.GetScanEventForScanNumber(scanNumber).GetReaction(0).PrecursorMass;
                    var pscan       = GetPScan(scanStats, centroidStream, 2, fileName, precursorMz, Convert.ToInt32(chargeState));
                    scans.Add(pscan);
                }

                var t = raw.GetTrailerExtraValues(scanNumber);
            }

            WriteScans(scans, fileName);
        }