コード例 #1
0
        public bool IsValidFilter(string filter)
        {
            if (rawFile.GetFilterFromString(filter) == null)
            {
                return(false);
            }

            return(true);
        }
コード例 #2
0
 private static bool IsValidFilter(IRawDataPlus rawFile, string filter)
 {
     if (rawFile.GetFilterFromString(filter) == null)
     {
         return(false);
     }
     return(true);
 }
コード例 #3
0
        public static ScanIndex ScanIndices(IRawDataPlus rawFile)
        {
            rawFile.SelectInstrument(Device.MS, 1);
            Log.Information("Extracting scan indices");
            Dictionary <int, ScanData> allScans;

            allScans = new Dictionary <int, ScanData>();
            MSOrderType AnalysisOrder;

            List <int> ms1   = new List <int>();
            List <int> ms2   = new List <int>();
            List <int> ms3   = new List <int>();
            List <int> msAny = new List <int>();

            // populate the scan indices
            IEnumerable <int> scans = rawFile.GetFilteredScanEnumerator(rawFile.GetFilterFromString("")); // get all scans

            ProgressIndicator P = new ProgressIndicator(scans.Count(), "Extracting scan indices");

            foreach (int scan in scans)
            {
                IScanEvent scanEvent = rawFile.GetScanEventForScanNumber(scan);
                ScanData   scanData  = new ScanData();
                scanData.MassAnalyzer = scanEvent.MassAnalyzer;
                scanData.MSOrder      = scanEvent.MSOrder;

                allScans.Add(scan, scanData);
                msAny.Add(scan);

                if (allScans[scan].MSOrder == MSOrderType.Ms)
                {
                    ms1.Add(scan);
                }
                if (allScans[scan].MSOrder == MSOrderType.Ms2)
                {
                    ms2.Add(scan);
                }
                if (allScans[scan].MSOrder == MSOrderType.Ms3)
                {
                    ms3.Add(scan);
                }
                P.Update();
            }
            P.Done();

            // determine the msorder of the experiment
            if ((ms1.Count > 0) & (ms2.Count == 0) & (ms3.Count == 0))
            {
                AnalysisOrder = MSOrderType.Ms;
            }
            else
            {
                if ((ms1.Count > 0) & (ms2.Count > 0) & (ms3.Count == 0))
                {
                    AnalysisOrder = MSOrderType.Ms2;
                }
                else
                {
                    AnalysisOrder = MSOrderType.Ms3;
                }
            }

            ScanIndex scanIndex = new ScanIndex();

            scanIndex.allScans      = allScans;
            scanIndex.AnalysisOrder = AnalysisOrder;
            scanIndex.ScanEnumerators.Add(MSOrderType.Any, msAny.ToArray());
            scanIndex.ScanEnumerators.Add(MSOrderType.Ms, ms1.ToArray());
            scanIndex.ScanEnumerators.Add(MSOrderType.Ms2, ms2.ToArray());
            scanIndex.ScanEnumerators.Add(MSOrderType.Ms3, ms3.ToArray());

            return(scanIndex);
        }
コード例 #4
0
        public static void ExtractScanIndex(this RawDataCollection rawData, IRawDataPlus rawFile)
        {
            Log.Information("Extracting scan indices");
            Dictionary <int, (MSOrderType MSOrder, MassAnalyzerType MassAnalyzer)> allScans;

            allScans = new Dictionary <int, (MSOrderType MSOrder, MassAnalyzerType MassAnalyzer)>();
            MSOrderType AnalysisOrder;

            List <int> ms1   = new List <int>();
            List <int> ms2   = new List <int>();
            List <int> ms3   = new List <int>();
            List <int> msAny = new List <int>();

            // populate the scan indices
            IEnumerable <int> scans = rawFile.GetFilteredScanEnumerator(rawFile.GetFilterFromString("")); // get all scans

            foreach (int scan in scans)
            {
                IScanEvent scanEvent = rawFile.GetScanEventForScanNumber(scan);

                allScans.Add(scan, (scanEvent.MSOrder, scanEvent.MassAnalyzer));
                msAny.Add(scan);

                if (allScans[scan].MSOrder == MSOrderType.Ms)
                {
                    ms1.Add(scan);
                }
                if (allScans[scan].MSOrder == MSOrderType.Ms2)
                {
                    ms2.Add(scan);
                }
                if (allScans[scan].MSOrder == MSOrderType.Ms3)
                {
                    ms3.Add(scan);
                }
            }

            // determine the msorder of the experiment
            if ((ms1.Count > 0) & (ms2.Count == 0) & (ms3.Count == 0))
            {
                AnalysisOrder = MSOrderType.Ms;
            }
            else
            {
                if ((ms1.Count > 0) & (ms2.Count > 0) & (ms3.Count == 0))
                {
                    AnalysisOrder = MSOrderType.Ms2;
                }
                else
                {
                    AnalysisOrder = MSOrderType.Ms3;
                }
            }

            rawData.scanIndex               = new ScanIndex();
            rawData.scanIndex.allScans      = allScans;
            rawData.scanIndex.AnalysisOrder = AnalysisOrder;
            rawData.scanIndex.ScanEnumerators.Add(MSOrderType.Any, msAny.ToArray());
            rawData.scanIndex.ScanEnumerators.Add(MSOrderType.Ms, ms1.ToArray());
            rawData.scanIndex.ScanEnumerators.Add(MSOrderType.Ms2, ms2.ToArray());
            rawData.scanIndex.ScanEnumerators.Add(MSOrderType.Ms3, ms3.ToArray());

            // we need to check if it is a boxcar file because those have some scan index issues
            bool isBoxCar = rawFile.GetScanEventForScanNumber(1).MassRangeCount > 1;

            rawData.Performed.Add(Operations.ScanIndex);

            if (isBoxCar)
            {
                Log.Information("Raw file looks like a boxcar run. Scan indices being adjusted to account for missing scan dependents.");
                rawData.ExtractPrecursorScans(rawFile);
                rawData.scanIndex.ScanEnumerators[rawData.scanIndex.AnalysisOrder] = rawData.precursorScans.Keys.ToArray();
            }
        }