Exemplo n.º 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);
        }
Exemplo n.º 2
0
 private void UpdateScanNumber(IMsScan currentScan)
 {
     Invoke(new Action(
                () =>
     {
         lblScanNumber.Text = currentScan.Header["Scan"].ToString();
     }));
 }
Exemplo n.º 3
0
        private void OnSingleProcessingDelay(IMsScan msScan)
        {
            // send the scan arrived event
            MsScanEventArgs args = new MyMsScanEventArgs(msScan);

            this.myScanContainer.sendScan(args);

            // send the CanAcceptNextCustomScan event
            EventHandler handler = CanAcceptNextCustomScan;

            if (handler != null)
            {
                handler(this, null);
            }
        }
Exemplo n.º 4
0
        internal static void StoreScan(IMsScan currentScan, int maxTargets)
        {
            int precursorMass = (int)decimal.Parse(currentScan.Header["PrecursorMass[0]"]);

            if (precursors.ContainsKey(precursorMass))
            {
                using (SQLiteTransaction transaction = mConn.BeginTransaction())
                {
                    SQLiteCommand command = new SQLiteCommand("insert into Table_Product (ID, PrecursorID, mz, INT) values (@ID, @PrecursorID,@mz,@INT)", mConn);

                    List <Centroid> normalizedCentroids = new List <Centroid>();

                    //Do this for all the centroids.
                    foreach (var centroid in currentScan.Centroids)
                    {
                        Centroid c = new Centroid();
                        c.Mz        = Math.Round(centroid.Mz, 0);
                        c.Intensity = Normalize(centroid.Intensity, 0, 100);
                        normalizedCentroids.Add(c);
                    }

                    List <Centroid> binnedCentroids = normalizedCentroids.GroupBy(c => c.Mz).Select(g => g.First()).ToList();


                    var sortedAndBinnedCentroids = binnedCentroids.OrderByDescending(c => c.Intensity).Take(maxTargets);
                    foreach (var centroid in sortedAndBinnedCentroids)
                    {
                        if (centroid.Intensity > 0)
                        {
                            command.Parameters.Clear();
                            command.Parameters.Add(new SQLiteParameter("@ID", null));
                            command.Parameters.Add(new SQLiteParameter("@PrecursorID", precursors[precursorMass]));
                            command.Parameters.Add(new SQLiteParameter("@mz", centroid.Mz));
                            command.Parameters.Add(new SQLiteParameter("@INT", Math.Round(centroid.Intensity, 2)));
                            command.ExecuteNonQuery();
                        }
                    }
                    transaction.Commit();
                }
            }
        }
Exemplo n.º 5
0
 public MyMsScanEventArgs(IMsScan msScan)
 {
     this.msScan = msScan;
 }