Beispiel #1
0
        private void ScanArriveHandler(object sender, MsScanEventArgs e)
        {
            IMsScan scan = e.GetScan();

            if (scan == null)
            {
                WriteLog("Empty scan");
            }
            else
            {
                string accessId = null;
                scan.Trailer.TryGetValue("Access id:", out accessId);
                WriteLog(string.Format("Received a new scan (scan number={0}, runningNumber={1}) containing {2} peaks",
                                       scan.Header["Scan"], accessId, scan.CentroidCount));

                // dump header
                foreach (KeyValuePair <string, string> kvp in scan.Header)
                {
                    string msg = string.Format("- Header\tKey = {0}, Value = {1}", kvp.Key, kvp.Value);
                    WriteLog(msg);
                }
            }

            // run user scan event handler
            scanHandler(scan);
        }
Beispiel #2
0
        void OnMsScanArrived(object sender, MsScanEventArgs e)
        {
            var lastScan1   = ias.InstMSScanContainer.GetLastMsScan();
            var currentScan = e.GetScan();

            UpdateScanNumber(currentScan);

            var header  = currentScan.Header;
            int msOrder = int.Parse(header["MSOrder"]);

            if (msOrder < 2)
            {
                return;
            }

            if (header.ContainsKey("PrecursorMass[0]"))
            {
                var precursorMass = decimal.Parse(currentScan.Header["PrecursorMass[0]"]);
                if (DBHelper.precursors.ContainsKey((int)precursorMass))
                {
                    //put the top 100 in the second table.
                    DBHelper.StoreScan(currentScan, maxTargets);
                }
            }
        }
Beispiel #3
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("==================================================");
                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;
                }
            }
        }
Beispiel #4
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);
            }
        }
Beispiel #5
0
 private void Orbitrap_MsScanArrived_TakeOver(object sender, MsScanEventArgs e)
 {
     using (IMsScan scan = (IMsScan)e.GetScan())
     {
         TakeOverInstrumentMessage(scan);
     }
 }
Beispiel #6
0
 //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);
     }
 }
Beispiel #7
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);
            }
        }
Beispiel #8
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);
            }
        }
Beispiel #9
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))));
            }
        }
        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();
            }
        }
Beispiel #11
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);
            }
        }
Beispiel #12
0
        void scanArrived_Response(object sender, MsScanEventArgs e)
        {
            try
            {
                Console.WriteLine("Scan arrived.");
                logfile.WriteLine("Scan arrived.");
                if (!authorized_for_run)
                {
                    Console.WriteLine("Ignoring pre-emptive scan.");
                    logfile.WriteLine("Ignoring pre-emptive scan.");
                    return;
                }
                else if (!accepting_scans)
                {
                    Console.WriteLine("Ignoring wait-time scan.");
                    logfile.WriteLine("Ignoring wait-time scan.");
                    return;
                }
                IMsScan scandata = e.GetScan();

                if (runTimeKeeper.Elapsed > intendedRunTime)
                {
                    Console.WriteLine("Ignoring extraneous scan.");
                    logfile.WriteLine("Ignoring extraneous scan.");
                }
                else
                {
                    Console.Write('<');
                    planner_MUT.WaitOne();
                    Console.Write('_');
                    runProgram.receiveScan(scandata);
                    scandata.Dispose();
                    planner_MUT.ReleaseMutex();
                    Console.Write('>');
                    logfile.Flush();
                }
            }
            catch (Exception err)
            {
                Console.WriteLine("Caught error in scanArrived_response!  Cancelling voltage.");
                change_voltage(0);
                Console.WriteLine(err.ToString());
                throw;
            }
        }
Beispiel #13
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);
#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
            }
        }
Beispiel #14
0
        void _instMSScanContainer_MsScanArrived(object sender, MsScanEventArgs e)
        {
            var lastScan1 = _instMSScanContainer.GetLastMsScan();
            var lastScan2 = e.GetScan();

            if (lastScan1 == lastScan2)
            {
                totalScansArrived++;
            }

            string accessID = "n/a";

            lastScan1.Trailer.TryGetValue("Access ID", out accessID);

            Invoke(new Action(
                       () =>
            {
                textBox1.Text = totalScansArrived.ToString();
                textBox3.Text = accessID;
            }));
        }
Beispiel #15
0
 private static void FusionScanContainer_MsScanArrived(object sender, MsScanEventArgs e)
 {
     // Print out the scan number of the scan received to console
     Console.WriteLine("[{0:HH:mm:ss.ffff}] Received MS Scan Number: {1}",
                       DateTime.Now, e.GetScan().Header["Scan"]);
 }