コード例 #1
0
        public static void ExtractTrailerExtra(this RawDataCollection rawData, IRawDataPlus rawFile)
        {
            if (rawData.Performed.Contains(Operations.TrailerExtras))
            {
                return;
            }

            Log.Information("Extracting trailer extras");
            rawData.trailerExtras = new Dictionary <int, TrailerExtraData>();
            TrailerExtraIndices indices = new TrailerExtraIndices(rawFile);

            Double[]          spsMasses;
            IEnumerable <int> scans = rawData.scanIndex.ScanEnumerators[MSOrderType.Any];

            ProgressIndicator progress = new ProgressIndicator(scans.Count(), "Extracting trailer extra data");

            foreach (int scan in scans)
            {
                try
                {
                    rawData.trailerExtras.Add(scan, ExtractTrailerExtra(rawData, rawFile, scan, indices));
                }
                catch (Exception e)
                {
                    Log.Error(e, "Failed during extraction of trailer extra {Scan}", scan);
                    throw e;
                }

                progress.Update();
            }
            progress.Done();

            rawData.Performed.Add(Operations.TrailerExtras);
        }
コード例 #2
0
        public static void ExtractAll(this RawDataCollection rawData, IRawDataPlus rawFile)
        {
            Log.Information("Beginning extraction of all possible data");
            rawFile.SelectInstrument(Device.MS, 1);
            rawData.ExtractPrecursorScans(rawFile);
            ProgressIndicator   P       = new ProgressIndicator(rawData.scanIndex.allScans.Count(), "Extracting raw data");
            TrailerExtraIndices indices = new TrailerExtraIndices(rawFile);

            for (int i = 1; i <= rawData.scanIndex.allScans.Count(); i++)
            {
                try
                {
                    // first get out the mass spectrum
                    if (rawData.scanIndex.allScans[i].MassAnalyzer == MassAnalyzerType.MassAnalyzerFTMS)
                    {
                        rawData.centroidStreams.Add(i, new CentroidStreamData(rawFile.GetCentroidStream(i, false)));
                    }
                    else
                    {
                        rawData.segmentedScans.Add(i, new SegmentedScanData(rawFile.GetSegmentedScanFromScanNumber(i, null)));
                    }

                    // add the trailer extra data
                    rawData.trailerExtras.Add(i, TrailerExtras.ExtractTrailerExtra(rawData, rawFile, i, indices));
                    rawData.Performed.Add(Operations.TrailerExtras);

                    // add the retention time
                    rawData.retentionTimes.Add(i, rawFile.RetentionTimeFromScanNumber(i));
                    rawData.Performed.Add(Operations.RetentionTimes);

                    // add the precursor mass
                    PrecursorMasses.ExtractPrecursorMasses(rawData, rawFile, i);
                    rawData.Performed.Add(Operations.PrecursorMasses);

                    P.Update();
                }
                catch (Exception e)
                {
                    Log.Error("Extraction failed on scan {Scan}", i);
                    throw e;
                }
            }

            if (rawData.methodData.AnalysisOrder == MSOrderType.Ms2 | rawData.methodData.AnalysisOrder == MSOrderType.Ms3)
            {
                rawData.Performed.Add(Operations.Ms1CentroidStreams);
                if (rawData.methodData.MassAnalyzers[MSOrderType.Ms2] == MassAnalyzerType.MassAnalyzerFTMS)
                {
                    rawData.Performed.Add(Operations.Ms2CentroidStreams);
                }
                else
                {
                    rawData.Performed.Add(Operations.Ms2SegmentedScans);
                }
            }
            if (rawData.methodData.AnalysisOrder == MSOrderType.Ms3)
            {
                if (rawData.methodData.MassAnalyzers[MSOrderType.Ms3] == MassAnalyzerType.MassAnalyzerFTMS)
                {
                    rawData.Performed.Add(Operations.Ms3CentroidStreams);
                }
                else
                {
                    rawData.Performed.Add(Operations.Ms3SegmentedScans);
                }
            }

            P.Done();
        }
コード例 #3
0
        public static TrailerExtraData ExtractTrailerExtra(RawDataCollection rawData, IRawDataPlus rawFile, int scan, TrailerExtraIndices indices)
        {
            TrailerExtraData trailerExtra = new TrailerExtraData();

            Double[] spsMasses;

            if (indices.InjectionTime != -1)
            {
                trailerExtra.InjectionTime = Convert.ToDouble(rawFile.GetTrailerExtraValue(scan, indices.InjectionTime));
            }

            if (indices.ChargeState != -1)
            {
                trailerExtra.ChargeState = Convert.ToInt32(rawFile.GetTrailerExtraValue(scan, indices.ChargeState));
            }

            if (indices.MonoisotopicMZ != -1)
            {
                trailerExtra.MonoisotopicMZ = Convert.ToDouble(rawFile.GetTrailerExtraValue(scan, indices.MonoisotopicMZ));
            }

            if (indices.MasterScan != -1)
            {
                try
                {
                    trailerExtra.MasterScan = Convert.ToInt32(rawFile.GetTrailerExtraValue(scan, indices.MasterScan));
                }
                // if that doesn't work the master scan is (hopefully) not applicable, we can leave it at the defaule value of -1
                catch (FormatException)
                {
                }
            }

            if (indices.HCDEnergy != -1)
            {
                try
                {
                    trailerExtra.HCDEnergy = Convert.ToDouble(rawFile.GetTrailerExtraValue(scan, indices.HCDEnergy));
                }
                catch (FormatException)
                {
                }
            }

            if (indices.SPSMasses.Count > 2) // if so, this means with have all SPS masses listed individually
            {
                spsMasses = new double[indices.SPSMasses.Count];
                for (int i = 0; i < indices.SPSMasses.Count; i++)
                {
                    spsMasses[i] = Convert.ToDouble(rawFile.GetTrailerExtraValue(scan, indices.SPSMasses[i]));
                }
            }
            if (indices.SPSMasses.Count == 0) // there are no SPS masses
            {
                spsMasses = new double[0];
            }
            else // they are broken into two lists of strings, comma delimited
            {
                char[]   delimiter  = { ' ', ',' };
                string[] stringsps1 = rawFile.GetTrailerExtraValue(scan, indices.SPSMasses[0]).ToString().Split(delimiter, StringSplitOptions.RemoveEmptyEntries);
                string[] stringsps2 = rawFile.GetTrailerExtraValue(scan, indices.SPSMasses[1]).ToString().Split(delimiter, StringSplitOptions.RemoveEmptyEntries);
                double[] sps1       = Array.ConvertAll(stringsps1, Convert.ToDouble);
                double[] sps2       = Array.ConvertAll(stringsps2, Convert.ToDouble);
                spsMasses = new double[sps1.Length + sps2.Length];
                sps1.CopyTo(spsMasses, 0);
                sps2.CopyTo(spsMasses, sps1.Length);
            }
            trailerExtra.SPSMasses = spsMasses;
            return(trailerExtra);
        }