コード例 #1
0
        private void Orbitrap_MsScanArrived(object sender, MsScanEventArgs e)
        {
            string accessId;

            using (IMsScan scan = (IMsScan)e.GetScan())                 // caution! You must dispose this, or you block shared memory!
            {
                // The access ID gives a feedback about placed scans or scans generated by the instrument.
                scan.SpecificInformation.TryGetValue("Access Id:", out accessId);
                Console.WriteLine("{0:HH:mm:ss,fff} scan {1} arrived", DateTime.Now, accessId);

                ////// The common part is shared by all Thermo Fisher instruments, these settings mainly form the so called filter string
                ////// which also appears on top of each spectrum in many visualizers.
                //Console.WriteLine("----------------Common--------------");
                //Dump("Common", scan.CommonInformation);

                ////// The specific part is individual for each instrument type. Many values are shared by different Exactive Series models.
                //Console.WriteLine("----------------Specific--------------");
                // Dump("Specific", scan.SpecificInformation);

                //Dump(scan);

                var ib = IsBoxCarScan(scan);
                Console.WriteLine("IsBoxCar Scan: {0}", ib);

                FullScan.PlaceFullScan(m_scans, Parameters);

                //List<double> dynamicBoxCarRange = new List<double> { 600, 700, 800, 900, 1000 };
                //BoxCarScan.PlaceBoxCarScan(m_scans, Parameters, dynamicBoxCarRange);

                DataDependentScan.PlaceMS2Scan(m_scans, Parameters, 750);

                BoxCarScan.PlaceStaticBoxCarScan(m_scans, Parameters);
            }
        }
コード例 #2
0
ファイル: DataReceiver.cs プロジェクト: avcarr2/MetaDrive
        private List <IsoEnvelop> Deconvolute_BU(IMsScan scan)
        {
            var spectrum = new MzSpectrumXY(scan.Centroids.Select(p => p.Mz).ToArray(), scan.Centroids.Select(p => p.Intensity).ToArray(), false);
            List <IsoEnvelop> isoEnvelops = IsoDecon.MsDeconv_Deconvolute(spectrum, spectrum.Range, Parameters.DeconvolutionParameter);

            return(isoEnvelops);
        }
コード例 #3
0
ファイル: IMsScanParser.cs プロジェクト: lonelu/MealTimeMS
        public static Spectra Parse(IMsScan imsScan, int ID, double arrivalTime)
        {
            //As opposed to "StartTime" contained in the IMsScan information, arrival time uses the computer's own clock in milisecond rather than using the Mass spec's clock
            String temp;
            int    msLevel         = TryGetValue(imsScan, GlobalVar.MSLevelHeader, out temp) ? parseMSLevel(temp) : -1;
            int    scanNum         = TryGetValue(imsScan, GlobalVar.ScanNumHeader, out temp) ? int.Parse(temp) : ID;
            double startTime       = TryGetValue(imsScan, GlobalVar.ScanTimeHeader, out temp) ? double.Parse(temp) : -1;
            int    precursorCharge = TryGetValue(imsScan, GlobalVar.PrecursorChargeHeader, out temp) ? int.Parse(temp) : -1;
            double precursorMZ     = TryGetValue(imsScan, GlobalVar.PrecursorMZHeader, out temp) ? double.Parse(temp) : -1;
            int    centroidCount   = (int)imsScan.CentroidCount;

            double[] peakIntensity = new double[centroidCount];
            double[] peakMZ        = new double[centroidCount];

            int counter = 0;

            foreach (ICentroid2 cent in imsScan.Centroids)
            {
                peakIntensity[counter] = cent.Intensity;
                peakMZ[counter]        = cent.Mz;
                counter++;
            }
            Spectra spec = new Spectra(ID, scanNum, msLevel, centroidCount, peakMZ, peakIntensity, startTime, precursorMZ, precursorCharge, arrivalTime);

            return(spec);
        }
コード例 #4
0
ファイル: DataReceiver.cs プロジェクト: avcarr2/MetaDrive
        private void Orbitrap_MsScanArrived(object sender, MsScanEventArgs e)
        {
            // If examining code takes longer, in particular for some scans, it is wise
            // to use a processing queue in order to get the system as responsive as possible.

            using (IMsScan scan = (IMsScan)e.GetScan())                 // caution! You must dispose this, or you block shared memory!
            {
                Console.WriteLine("==================================================");
                Console.WriteLine("\n{0:HH:mm:ss,fff} scan with {1} centroids arrived", DateTime.Now, scan.CentroidCount);

                //TO THINK: If the coming scan is MS2 scan, start the timing of the scan precursor into exclusion list. Currently, start when add the scan precursor.

                if (!IsTakeOverScan(scan))
                {
                    if (IsMS1Scan(scan))
                    {
                        Console.WriteLine("MS1 Scan arrived.");
                        if (!TimeIsOver)
                        {
                            AddScanIntoQueueAction(scan);
                        }
                    }
                    else
                    {
                        Console.WriteLine("MS2 Scan arrived.");
                    }
                }
                else if (!firstFullScanPlaced)
                {
                    FullScan.PlaceFullScan(m_scans, Parameters);
                    Console.WriteLine("Place First User defined Full Scan.");
                    firstFullScanPlaced = true;
                }
            }
        }
コード例 #5
0
 /// <summary>
 /// Dump all variables belonging to a scan
 /// </summary>
 /// <param name="scan"></param>
 private void DumpVars(IMsScan scan)
 {
     Console.WriteLine("  COMMON");
     DumpVars(scan.CommonInformation);
     Console.WriteLine("  SPECIFIC");
     DumpVars(scan.SpecificInformation);
 }
コード例 #6
0
ファイル: DataReceiver.cs プロジェクト: avcarr2/MetaDrive
 private void Orbitrap_MsScanArrived_TakeOver(object sender, MsScanEventArgs e)
 {
     using (IMsScan scan = (IMsScan)e.GetScan())
     {
         TakeOverInstrumentMessage(scan);
     }
 }
コード例 #7
0
        /// <summary>
        /// This routine accesses all centroids and profiles in the scan to show the usage.
        /// </summary>
        /// <param name="scan">the scan to deal with</param>
        private double AllProfInts(IMsScan scan)
        {
            // Access all profile information directly. Either use this way or that shown below.
            int pc = scan.ProfileCount ?? 0;

            if (pc > 0)
            {
                double[] mzs  = new double[pc];
                double[] ints = new double[pc];
                scan.GetProfileData(ref mzs, ref ints);
            }
            double retval = 0;

            m_scans++;

            // Access the centroids and, as part of each centroid, the list of profile elements.
            // Those may be omitted if the instrument only acquires centroids and no profile information.
            foreach (ICentroid centroid in scan.Centroids)
            {
                m_centroids++;
                foreach (IMassIntensity p in centroid.Profile)
                {
                    m_profiles++;
                    retval += p.Intensity;
                }
            }

            return(retval);
        }
コード例 #8
0
        /// <summary>
        /// Show the last acquired scan if that exists and cleanup.
        /// </summary>
        internal void CloseDown()
        {
            // Be tolerant to thread-switches
            IMsScanContainer scanContainer = ScanContainer;

            ScanContainer = null;

            if (!Arguments.Verbose)
            {
                // only acquired in non-verbose mode:
                Console.WriteLine("scans={0}, centroids={1}, profiles={2}", m_scans, m_centroids, m_profiles);
            }

            if (scanContainer != null)
            {
                scanContainer.MsScanArrived            -= new EventHandler <MsScanEventArgs>(ScanContainer_ScanArrived);
                scanContainer.AcquisitionStreamClosing -= new EventHandler(ScanContainer_AcquisitionEnded);
                scanContainer.AcquisitionStreamOpening -= new EventHandler <MsAcquisitionOpeningEventArgs>(ScanContainer_AcquisitionStarted);
                if (Arguments.Verbose)
                {
                    using (IMsScan scan = (/* V2 */ IMsScan)scanContainer.GetLastMsScan())
                    {
                        DumpScan("GetLastScan()", scan);
                    }
                }
            }
        }
コード例 #9
0
        //parses the IMsScan into a spectra object so IMSscan object can be released to free memory
        public static void ParseIMsScan(IMsScan arrivedScan)
        {
            scanIDCounter++;


#if IGNORE
            if (Interlocked.Read(ref taskCounter) >= 25)
            {
                ignore = true;
            }
            else if (Interlocked.Read(ref taskCounter) < 10)
            {
                ignore = false;
            }

            if (ignore)
            {
                String scanNum = "";
                arrivedScan.CommonInformation.TryGetValue(GlobalVar.ScanNumHeader, out scanNum);
                spectraNotAdded.Add(new double[] { Double.Parse(scanNum), getCurrentMiliTime(), -1 });
                Console.WriteLine("ignoring scan " + scanNum);
                return;
            }
#endif
            Interlocked.Increment(ref taskCounter);
            //Spectra spectra = IMsScanParser.Parse(arrivedScan, scanIDCounter, getCurrentMiliTime());//Parses the IMsScan into a Spectra object
            Spectra spectra = IMsScanParser.Parse(arrivedScan, scanIDCounter, getCurrentMiliTime());

            parsedSpectra.Enqueue(spectra);
        }
コード例 #10
0
 /// <summary>
 /// Dump all variables belonging to a scan
 /// </summary>
 /// <param name="scan">the scan for which to dump all variables</param>
 public void DumpVars(IMsScan scan)
 {
     outputln("COMMON");
     DumpVars(scan.CommonInformation);
     outputln("SPECIFIC");
     DumpVars(scan.SpecificInformation);
 }
コード例 #11
0
ファイル: DataReceiver.cs プロジェクト: avcarr2/MetaDrive
        private void PlaceBU_MS2Scan(IMsScan scan, List <IsoEnvelop> isoEnvelops)
        {
            Console.WriteLine("\n{0:HH:mm:ss,fff} Deconvolute Dynamic BoxCar Start", DateTime.Now);

            int placeScanCount = 0;

            foreach (var iso in isoEnvelops.OrderByDescending(p => p.TotalIntensity))
            {
                if (placeScanCount >= Parameters.MS1IonSelecting.TopN)
                {
                    break;
                }

                if (DynamicExclusionList.isNotInExclusionList(iso.ExperimentIsoEnvelop.First().Mz, Parameters.MS1IonSelecting.ExclusionTolerance))
                {
                    var dataTime = DateTime.Now;
                    lock (lockerExclude)
                    {
                        DynamicExclusionList.exclusionList.Enqueue(new Tuple <double, int, DateTime>(iso.ExperimentIsoEnvelop.First().Mz, iso.Charge, dataTime));
                        Console.WriteLine("2 ExclusionList Enqueue: {0}", iso.ExperimentIsoEnvelop.First().Mz);
                    }

                    DataDependentScan.PlaceMS2Scan(m_scans, Parameters, iso.ExperimentIsoEnvelop.First().Mz);
                    placeScanCount++;
                }
            }
        }
コード例 #12
0
ファイル: IMsScanParser.cs プロジェクト: lonelu/MealTimeMS
        public static Spectra Parse(IMsScan imsScan, int ID)
        {
            //TODO to boost performance, hard code which table/container to search in "TryGetValue" instead of determining on runtime
            String temp;
            int    msLevel         = TryGetValue(imsScan, GlobalVar.MSLevelHeader, out temp) ? parseMSLevel(temp) : -1;
            int    scanNum         = TryGetValue(imsScan, GlobalVar.ScanNumHeader, out temp) ? int.Parse(temp) : ID;
            double startTime       = TryGetValue(imsScan, GlobalVar.ScanTimeHeader, out temp) ? double.Parse(temp) : -1;
            int    precursorCharge = TryGetValue(imsScan, GlobalVar.PrecursorChargeHeader, out temp) ? int.Parse(temp) : -1;
            double precursorMZ     = TryGetValue(imsScan, GlobalVar.PrecursorMZHeader, out temp) ? double.Parse(temp) : -1;
            int    centroidCount   = (int)imsScan.CentroidCount;

            double[] peakIntensity = new double[centroidCount];
            double[] peakMZ        = new double[centroidCount];

            int counter = 0;

            foreach (ICentroid2 cent in imsScan.Centroids)
            {
                peakIntensity[counter] = cent.Intensity;
                peakMZ[counter]        = cent.Mz;
                counter++;
            }
            Spectra spec = new Spectra(ID, scanNum, msLevel, centroidCount, peakMZ, peakIntensity, startTime, precursorMZ, precursorCharge);

            return(spec);
        }
コード例 #13
0
ファイル: DataReceiver.cs プロジェクト: avcarr2/MetaDrive
        //It is possible to deconvolution only deconvolute TopN peaks to generate MS2 scans. Deconvolute one peak, add one MS2 scan.
        //There is no need to wait to deconvolute all peaks and then add all MS2 scans.
        private void DeconvoluteMS1ScanAddMS2Scan_TopN(IMsScan scan)
        {
            Console.WriteLine("\n{0:HH:mm:ss,fff} Deconvolute Start", DateTime.Now);

            List <IsoEnvelop> isoEnvelops = Deconvolute_BU(scan);

            PlaceBU_MS2Scan(scan, isoEnvelops);
        }
コード例 #14
0
ファイル: DataReceiver.cs プロジェクト: avcarr2/MetaDrive
        private List <IsoEnvelop> Deconvolute_TD(IMsScan scan, out List <ChargeEnvelop> chargeEnvelops)
        {
            var spectrum = new MzSpectrumXY(scan.Centroids.Select(p => p.Mz).ToArray(), scan.Centroids.Select(p => p.Intensity).ToArray(), false);
            List <IsoEnvelop> isoEnvelops;

            chargeEnvelops = ChargeDecon.ChargeDeconIsoForScan(spectrum, Parameters.DeconvolutionParameter, out isoEnvelops).OrderByDescending(p => p.ChargeDeconScore).Where(p => p.distributions_withIso.Count >= 2).ToList();
            return(isoEnvelops);
        }
コード例 #15
0
ファイル: DataReceiver.cs プロジェクト: lonelu/MealTimeMS
 //The IMsScan will arrive at this method
 //It will be sent to DataProcessor to be parsed into a Scan object, and the IMsScan will be disposed to prevent blocking shared memory
 private void Orbitrap_MsScanArrived(object sender, MsScanEventArgs e)
 {
     using (IMsScan scan = (IMsScan)e.GetScan())                 // caution! You must dispose this, or you block shared memory!
     {
         log.Debug("\n{0:HH:mm:ss,fff} scan with {1} centroids arrived", DateTime.Now, scan.CentroidCount);
         DataProcessor.ParseIMsScan(scan);
     }
 }
コード例 #16
0
ファイル: DataReceiver.cs プロジェクト: nigjeh/iapi
        private void Orbitrap_MsScanArrived(object sender, MsScanEventArgs e)
        {
            // If examining code takes longer, in particular for some scans, it is wise
            // to use a processing queue in order to get the system as responsive as possible.

            using (IMsScan scan = (IMsScan)e.GetScan())                 // caution! You must dispose this, or you block shared memory!
            {
                Console.WriteLine("\n{0:HH:mm:ss,fff} scan with {1} centroids arrived", DateTime.Now, scan.CentroidCount);
            }
        }
コード例 #17
0
        private void Orbitrap_MsScanArrived(object sender, MsScanEventArgs e)
        {
            string accessId;

            using (IMsScan scan = (IMsScan)e.GetScan())                 // caution! You must dispose this, or you block shared memory!
            {
                // The access ID gives a feedback about placed scans or scans generated by the instrument.
                scan.SpecificInformation.TryGetValue("Access Id:", out accessId);
                Console.WriteLine("{0:HH:mm:ss,fff} scan {1} arrived", DateTime.Now, accessId);
                PlaceScan();
            }
        }
コード例 #18
0
ファイル: DataReceiver.cs プロジェクト: avcarr2/MetaDrive
        //In bottom up, it is possible to change the BoxCar ranges based on the real full mass scan.
        //The workflow works, but the improvement is hard to evaluate so far.
        private void AddScanIntoQueue_BynamicBoxCar_BU(IMsScan scan)
        {
            try
            {
                //Is MS1 Scan
                if (scan.HasCentroidInformation && IsMS1Scan(scan))
                {
                    bool isBoxCarScan = IsBoxCarScan(scan);

                    //string scanNumber;
                    //scan.CommonInformation.TryGetValue("ScanNumber", out scanNumber);
                    Console.WriteLine("In DynamicBoxCar_BU method, MS1 Scan arrived. Is BoxCar Scan: {0}.", isBoxCarScan);

                    if (!isBoxCarScan)
                    {
                        List <IsoEnvelop> isoEnvelops = Deconvolute_BU(scan);

                        if (isoEnvelops.Count > 0)
                        {
                            if (Parameters.MS2ScanSetting.DoMS2)
                            {
                                PlaceBU_MS2Scan(scan, isoEnvelops);
                            }

                            BoxCarScan.GenerateDynamicBoxes_BU(isoEnvelops, Parameters, Boxes);

                            FullScan.PlaceFullScan(m_scans, Parameters);

                            //The nearby Full mass scans in the current DDA method are very similar, so it is possible to use the previous full scan to generate the current boxes.
                            if (Boxes.Count > 0)
                            {
                                BoxCarScan.PlaceDynamicBoxCarScan_BU(m_scans, Parameters, Boxes);

                                //To generate data for comparison
                                BoxCarScan.PlaceStaticBoxCarScan(m_scans, Parameters);

                                Boxes.Clear();
                            }
                        }

                        else
                        {
                            FullScan.PlaceFullScan(m_scans, Parameters);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("AddScanIntoQueue_DynamicBoxCar_Bu MS2FromFullScan Exception!");
                Console.WriteLine(e.ToString() + " " + e.Source);
            }
        }
コード例 #19
0
        private void Orbitrap_MsScanArrived(object sender, MsScanEventArgs e)
        {
            // If examining code takes longer, in particular for some scans, it is wise
            // to use a processing queue in order to get the system as responsive as possible.

            using (IMsScan scan = (IMsScan)e.GetScan())                 // caution! You must dispose this, or you block shared memory!
            {
                Console.WriteLine("\n{0:HH:mm:ss,fff} scan with {1} centroids arrived", DateTime.Now, scan.CentroidCount);
                Console.WriteLine("Noise: " + string.Join("; ", scan.NoiseBand.Take(5).Select(n => string.Format("{0:F2},{1:0.0e0}", n.Mz, n.Intensity))));
                Console.WriteLine("Centroids: " + string.Join("; ", scan.Centroids.Take(5).Select(n => string.Format("{0:F2},{1:0.0e0},z={2},R={3}", n.Mz, n.Intensity, n.Charge, n.Resolution))));
            }
        }
コード例 #20
0
ファイル: DataReceiver.cs プロジェクト: avcarr2/MetaDrive
        private bool IsMS1Scan(IMsScan scan)
        {
            string value;

            if (scan.CommonInformation.TryGetValue("MSOrder", out value))
            {
                if (value == "MS")
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #21
0
 private bool TryGetValue(IMsScan scan, String name, out String value)
 {
     value = null;
     if (TryGetValue(scan.CommonInformation, name, out value))
     {
         return(true);
     }
     else if (TryGetValue(scan.SpecificInformation, name, out value))
     {
         return(true);
     }
     Console.WriteLine("Warning, value with name: {0} not found", name);
     return(false);
 }
コード例 #22
0
        private void Orbitrap_MsScanArrived(object sender, MsScanEventArgs e)
        {
            using (IMsScan scan = (IMsScan)e.GetScan())                 // caution! You must dispose this, or you block shared memory!
            {
                Console.WriteLine("\n{0:HH:mm:ss,fff} scan with {1} centroids arrived", DateTime.Now, scan.CentroidCount);

                // The common part is shared by all Thermo Fisher instruments, these settings mainly form the so called filter string
                // which also appears on top of each spectrum in many visualizers.
                Dump("Common", scan.CommonInformation);

                // The specific part is individual for each instrument type. Many values are shared by different Exactive Series models.
                Dump("Specific", scan.SpecificInformation);
            }
        }
コード例 #23
0
        private void DumpScan(IMsScan scan)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("RT:");
            sb.Append(time);
            sb.Append(": ");
            sb.Append("scan ID: " + ID);
            sb.Append(", ");
            if (scan == null)
            {
                sb.Append("(empty_scan)");
                outputln(sb.ToString());
                return;
            }
            else
            {
                centroidCount = scan.CentroidCount ?? 0;
                sb.Append("detector=");
                sb.Append(scan.DetectorName);
                string id;
                if (scan.SpecificInformation.TryGetValue("Access Id:", out id))
                {
                    sb.Append(", id=");
                    sb.Append(id);
                }
                outputln(sb.ToString());
            }

            if (scan.NoiseBand != null)
            {
                output("  Noise: ");
                foreach (INoiseNode noise in scan.NoiseBand)
                {
                    output("[{0}, {1}], ", noise.Mz, noise.Intensity);
                }
                outputln();

                // Not so useful:
            }
            outputln("{0} centroids, {1} profile peaks", scan.CentroidCount ?? 0, scan.ProfileCount ?? 0);

            // Iterate over all centroids and access dump all profile elements for each.

            if (scan.CentroidCount > 0)
            {
                outputln(CentroidToString(GetTopPeak(scan.Centroids)));
            }
        }
コード例 #24
0
ファイル: DataReceiver.cs プロジェクト: avcarr2/MetaDrive
 //Used to manully decide scan placements. Generally for standard proteins.
 //For example in the following code we munally analyzed fragmentation of Myoglobin.
 //TO DO: it is possible to make this auto.
 private void AddScanIntoQueue_UserDefined(IMsScan scan)
 {
     try
     {
         //Is MS1 Scan
         if (scan.HasCentroidInformation)
         {
             PlaceUserDefined(scan);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine("AddScanIntoQueue_UserDefined Exception!");
         Console.WriteLine(e.ToString() + " " + e.Source);
     }
 }
コード例 #25
0
ファイル: DataReceiver.cs プロジェクト: avcarr2/MetaDrive
 private void TakeOverInstrumentMessage(IMsScan scan)
 {
     try
     {
         if (IsTakeOverScan(scan))
         {
             Console.WriteLine("Instrument take over Scan by IAPI is dectected.");
             isTakeOver = true;
             Console.WriteLine("Instrument take over duration time: {0} min", Parameters.GeneralSetting.TotalTimeInMinute);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine("TakeOver Execption!");
         Console.WriteLine(e.ToString() + " " + e.Source);
     }
 }
コード例 #26
0
ファイル: DataReceiver.cs プロジェクト: avcarr2/MetaDrive
        private bool IsBoxCarScan(IMsScan scan)
        {
            //TO DO: better way to check if is boxcar scan.
            string value;
            string valueHigh;

            if (scan.CommonInformation.TryGetValue("LowMass", out value) && scan.CommonInformation.TryGetValue("HighMass", out valueHigh))
            {
                Console.WriteLine("IsBoxCarScan: " + value + "," + Parameters.BoxCarScanSetting.BoxCarMzRangeLowBound.ToString());

                if (value == Parameters.BoxCarScanSetting.BoxCarMzRangeLowBound.ToString() || valueHigh == Parameters.BoxCarScanSetting.BoxCarMzRangeHighBound.ToString())
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #27
0
ファイル: DataReceiver.cs プロジェクト: avcarr2/MetaDrive
        private bool IsTakeOverScan(IMsScan scan)
        {
            object massRanges;

            ThermoFisher.Foundation.IO.Range[] x = new ThermoFisher.Foundation.IO.Range[] { };

            if (scan.CommonInformation.TryGetRawValue("MassRanges", out massRanges))
            {
                x = (ThermoFisher.Foundation.IO.Range[])massRanges;
                Console.WriteLine("Take Over scan: {0}, {1}", x.First().Low, x.First().High);

                if (x.First().Low == 374.0 && x.First().High == 1751.0)
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #28
0
ファイル: ProfileDataReceiver.cs プロジェクト: nigjeh/iapi
        private void Orbitrap_MsScanArrived(object sender, MsScanEventArgs e)
        {
            // If examining code takes longer, in particular for some scans, it is wise
            // to use a processing queue in order to get the system as responsive as possible.

            using (IMsScan scan = (IMsScan)e.GetScan())                 // caution! You must dispose this, or you block shared memory!
            {
                Console.WriteLine("\n{0:HH:mm:ss,fff} scan with {1} centroids arrived", DateTime.Now, scan.CentroidCount);
#if ProfileAccessInsideEnumeration
                int max = 5;
                foreach (ICentroid c in scan.Centroids)
                {
                    if (max-- == 0)
                    {
                        break;
                    }
                    Console.Write("{0:F4},{1:0.0e0},z={2}  :  ", c.Mz, c.Intensity, c.Charge);

                    // Access to profile information is done INSIDE the enumeration of centroids: profile is available:
                    Console.WriteLine(string.Join("; ", c.Profile.Take(5).Select(n => string.Format("{0:F4},{1:0.0e0}", n.Mz, n.Intensity))));
                }
#elif ProfileAccessOutsideEnumeration
                ICentroid[] list = scan.Centroids.ToArray();
                for (int i = 0; i < Math.Min(5, list.Length); i++)
                {
                    ICentroid c = list[i];
                    Console.Write("{0:F4},{1:0.0e0},z={2}  :  ", c.Mz, c.Intensity, c.Charge);                          // works

                    // Access to profile information is done OUTSIDE the enumeration of centroids, which is done by ToArray(), no profile is available:
                    Console.WriteLine(string.Join("; ", c.Profile.Take(5).Select(n => string.Format("{0:F4},{1:0.0e0}", n.Mz, n.Intensity))));                     // crashes
                }
#else
                // Create an array where the profile is copied on enumeration if the above solution with ProfileAccessInsideEnumeration
                // does not fit. The way of processing shown here requies more memory and is slower.
                Tuple <ICentroid, IMassIntensity[]>[] list = scan.Centroids.Select(n => new Tuple <ICentroid, IMassIntensity[]>(n, (IMassIntensity[])n.Profile.Clone())).ToArray();
                for (int i = 0; i < Math.Min(5, list.Length); i++)
                {
                    Tuple <ICentroid, IMassIntensity[]> tuple = list[i];
                    Console.Write("{0:F4},{1:0.0e0},z={2}  :  ", tuple.Item1.Mz, tuple.Item1.Intensity, tuple.Item1.Charge);                      // works
                    Console.WriteLine(string.Join("; ", tuple.Item2.Take(5).Select(n => string.Format("{0:F4},{1:0.0e0}", n.Mz, n.Intensity))));  // works
                }
#endif
            }
        }
コード例 #29
0
        /// <summary>
        /// When a new scan arrives we dump that information in verbose mode.
        /// </summary>
        /// <param name="sender">doesn't matter</param>
        /// <param name="e">used to access the scan information</param>
        private void ScanContainer_ScanArrived(object sender, MsScanEventArgs e)
        {
            if (!Arguments.Verbose)
            {
                Console.WriteLine("Scan arrived");
                // As an example we access all centroids
                using (IMsScan scan = (/* V2 */ IMsScan)e.GetScan())
                {
                    m_integral += AllProfInts(scan);
                }
                return;
            }

            // Dump the scan content.
            using (IMsScan scan = (/* V2 */ IMsScan)e.GetScan())
            {
                DumpScan("Scan arrived", scan);
            }
        }
コード例 #30
0
        private bool IsBoxCarScan(IMsScan scan)
        {
            string value;
            string valueHigh;

            if (scan.CommonInformation.TryGetValue("LowMass", out value) && scan.CommonInformation.TryGetValue("HighMass", out valueHigh))
            {
                Console.WriteLine("Scan LowMass: " + value);
            }

            object massRanges;

            ThermoFisher.Foundation.IO.Range[] x = new ThermoFisher.Foundation.IO.Range[] { };
            if (scan.CommonInformation.TryGetRawValue("MassRanges", out massRanges))
            {
                x = (ThermoFisher.Foundation.IO.Range[])massRanges;
                Console.WriteLine("MassRanges:  {0}, {1}", x.First().Low, x.First().High);

                Console.WriteLine("Mass Ranges count: {0}", x.Count());
            }

            string msorder;

            if (scan.CommonInformation.TryGetValue("MSOrder", out msorder))
            {
                Console.WriteLine("Mass Order: " + msorder);
            }


            string massRangeCount;

            if (scan.CommonInformation.TryGetValue("MassRangeCount", out massRangeCount))
            {
                Console.WriteLine("BoxCar Scan Boxes: {0}.", int.Parse(massRangeCount));

                if (int.Parse(massRangeCount) > 1)
                {
                    return(true);
                }
            }

            return(false);
        }