예제 #1
0
        public static void PlaceFullScan(IScans m_scans, Parameters parameters)
        {
            if (m_scans.PossibleParameters.Length == 0)
            {
                return;
            }
            ICustomScan scan = m_scans.CreateCustomScan();

            scan.Values["FirstMass"]          = parameters.FullScanSetting.MzRangeLowBound.ToString();
            scan.Values["LastMass"]           = parameters.FullScanSetting.MzRangeHighBound.ToString();
            scan.Values["IsolationRangeLow"]  = parameters.FullScanSetting.MzRangeLowBound.ToString();
            scan.Values["IsolationRangeHigh"] = parameters.FullScanSetting.MzRangeHighBound.ToString();
            scan.Values["MaxIT"]             = parameters.FullScanSetting.MaxInjectTimeInMillisecond.ToString();
            scan.Values["Resolution"]        = parameters.FullScanSetting.Resolution.ToString();
            scan.Values["Polarity"]          = parameters.GeneralSetting.Polarity.ToString();
            scan.Values["NCE"]               = "0.0";
            scan.Values["NCE_NormCharge"]    = parameters.MS1IonSelecting.NormCharge.ToString();
            scan.Values["NCE_SteppedEnergy"] = "0";
            scan.Values["NCE_Factors"]       = "[]";
            scan.Values["SourceCID"]         = parameters.GeneralSetting.SourceCID.ToString();
            scan.Values["Microscans"]        = parameters.FullScanSetting.Microscans.ToString();
            scan.Values["AGC_Target"]        = parameters.FullScanSetting.AgcTarget.ToString();
            scan.Values["AGC_Mode"]          = parameters.GeneralSetting.AGC_Mode.ToString();

            scan.Values["MsxInjectRanges"]    = "[]";
            scan.Values["MsxInjectTargets"]   = "[]";
            scan.Values["MsxInjectMaxITs"]    = "[]";
            scan.Values["MsxInjectNCEs"]      = "[]";
            scan.Values["MsxInjectDirectCEs"] = "[]";

            Console.WriteLine("{0:HH:mm:ss,fff} placing Full MS1 scan", DateTime.Now);
            m_scans.SetCustomScan(scan);
        }
예제 #2
0
        /// <summary>
        /// Start a new custom scan.
        /// </summary>
        private void StartNewScan()
        {
            ICustomScan cs = m_scans.CreateCustomScan();

            cs.RunningNumber = m_runningNumber++;

            // Allow an extra delay of 500 ms, we will answer as fast as possible, so this is a maximum value.
            cs.SingleProcessingDelay = 0.50D;

            // Toggle the polarity:
            m_polarity            = (m_polarity == 0) ? 1 : 0;
            cs.Values["Polarity"] = m_polarity.ToString(NumberFormatInfo.InvariantInfo);

            try
            {
                DateTime now = Instrument.Now;
                if (!m_scans.SetCustomScan(cs))
                {
                    Console.WriteLine("NEW CUSTOM SCAN HAS NOT BEEN PLACED, CONNECTION TO SERVICE BROKEN.");
                }
                Console.WriteLine(now.ToString(Program.TimeFormat) + ": Placed a new custom scan(" + cs.RunningNumber + ")");
            }
            catch (Exception e)
            {
                Console.WriteLine("PLACING A NEW SCAN: " + e.Message);
            }
        }
예제 #3
0
        public FusionBridge(string debugMzML, string logDir, bool showConsoleLogs)
        {
            Logs            = new List <string>();
            LogDir          = logDir;
            ShowConsoleLogs = showConsoleLogs;

            IFusionInstrumentAccessContainer fusionContainer = null;

            if (!String.IsNullOrEmpty(debugMzML)) // create fake Fusion container that reads from mzML file
            {
                WriteLog("FusionBridge constructor called in debug mode");
                WriteLog(string.Format("Reading scans from {0}", debugMzML));
                fusionContainer = new MzMLFusionContainer(debugMzML);
            }
            else // needs license to connect to the real instrument
            {
                //// Use the Factory creation method to create a Fusion Access Container
                WriteLog("FusionBridge constructor called");
                fusionContainer = getIFusionInstrumentAccessContainer();
            }


            // Connect to the service by going 'online'
            fusionContainer.StartOnlineAccess();

            // Wait until the service is connected
            // (better through the event, but this is nice and simple)
            while (!fusionContainer.ServiceConnected)
            {
                ;
            }

            // From the instrument container, get access to a particular instrument
            InstrumentAccess = fusionContainer.Get(1);
            ScanContainer    = InstrumentAccess.GetMsScanContainer(0);
            WriteLog("Detector class: " + ScanContainer.DetectorClass);

            // Dump key-value pairs in cs.Values
            WriteLog("Custom scan parameters: ");
            InstrumentControl = InstrumentAccess.Control;
            ScanControl       = InstrumentControl.GetScans(false);
            ICustomScan cs = ScanControl.CreateCustomScan();

            foreach (KeyValuePair <string, string> kvp in cs.Values)
            {
                string kvpString = string.Format("- cs.Values\tKey = {0}, Value = {1}", kvp.Key, kvp.Value);
                WriteLog(kvpString);
            }

            // Print instrument state
            WriteLog("FusionBridge constructor initialised");
            IState state = InstrumentControl.Acquisition.State;
            string msg   = string.Format("System mode = {0}, system state = {1}", state.SystemMode,
                                         state.SystemState);

            WriteLog(msg);
        }
예제 #4
0
        public bool SetCustomScan(ICustomScan cs)
        {
            // select whether to generate ms1 or msn spectra from the read mzML data
            List <SimpleSpectrum> spectraList = null;

            if (cs.Values["ScanType"] == "Full")
            {
                // if empty, copy ms1 spectra from the original list
                if (this.myScanContainer.ms1Spectra.Count == 0)
                {
                    this.myScanContainer.ms1Spectra = new List <SimpleSpectrum>(this.myScanContainer.originalMs1Spectra);
                }
                spectraList = this.myScanContainer.ms1Spectra;
            }
            else if (cs.Values["ScanType"] == "MSn")
            {
                // if empty, copy msn spectra from the original list
                if (this.myScanContainer.msnSpectra.Count == 0)
                {
                    this.myScanContainer.msnSpectra = new List <SimpleSpectrum>(this.myScanContainer.originalMsnSpectra);
                }
                spectraList = this.myScanContainer.msnSpectra;
            }

            // if we can actually generate a custom scan ...
            if (spectraList.Count > 0)
            {
                // pop a spectrum from the list
                SimpleSpectrum current = spectraList[0];
                spectraList.RemoveAt(0);

                // pretend to do a scan for some time
                double scanDuration = this.myScanContainer.scanDurations.ContainsKey(current.ScanNumber) ?
                                      this.myScanContainer.scanDurations[current.ScanNumber] : 0.25;
                //Console.WriteLine("Scan number={0} duration={1}", current.ScanNumber, scanDuration);

                // delay for scan duration + half of single processing delay
                //double spdDelay = cs.SingleProcessingDelay / 2;
                //double totalDelay = scanDuration + spdDelay;

                // delay for scan duration only
                double totalDelay = scanDuration;

                // send the scan and trigger canAcceptNextCustomScan event some time later
                int     milliSecondDelay = ((int)totalDelay) * 1000;
                IMsScan msScan           = new MyMsScan(current, cs.RunningNumber, this.startTime);
                Task.Delay(milliSecondDelay).ContinueWith(t => OnSingleProcessingDelay(msScan));
                return(true);
            }
            return(false);
        }
예제 #5
0
        private void PlaceScan()
        {
            // If no information about possible settings are available yet or if we finished our job, we bail out.
            if ((m_scanId > 10) || (m_scans.PossibleParameters.Length == 0))
            {
                return;
            }
            ICustomScan scan = m_scans.CreateCustomScan();

            scan.RunningNumber      = m_scanId++;
            scan.Values["Polarity"] = "1";
            Console.WriteLine("{0:HH:mm:ss,fff} placing scan {1}", DateTime.Now, scan.RunningNumber);
            m_scans.SetCustomScan(scan);
        }
예제 #6
0
파일: Form1.cs 프로젝트: 5ggg/vimms
 private void SubmitScan()
 {
     if (radioButton5.Checked)
     {
         IRepeatingScan rs = _scans.CreateRepeatingScan();
         UpdateScan(rs);
         _scans.SetRepetitionScan(rs);
     }
     else if (radioButton6.Checked)
     {
         ICustomScan cs = _scans.CreateCustomScan();
         cs.SingleProcessingDelay = (double)numericUpDown4.Value;
         UpdateScan(cs);
         _scans.SetCustomScan(cs);
     }
 }
        private ICustomScan baseMS1()
        {
            ICustomScan newscan = ScanManager.CreateCustomScan();

            newscan.SingleProcessingDelay = 10.0D;
            newscan.Values["FirstMass"]   = Parameters["MS1_FirstMass"];
            newscan.Values["LastMass"]    = Parameters["MS1_LastMass"];
            newscan.Values["Polarity"]    = Parameters["MS1_Polarity"];
            newscan.Values["NCE"]         = "0"; // Whether this is set seems to control whether its an MS1 or MS2.
            newscan.Values["Resolution"]  = Parameters["MS1_Resolution"];
            newscan.Values["AGC_Target"]  = Parameters["MS1_AGC_Target"];
            newscan.Values["MaxIT"]       = Parameters["MS1_MaxIT"];
            newscan.Values["Microscans"]  = Parameters["MS1_Microscans"];
            newscan.RunningNumber         = ScanCount++;

            return(newscan);
        }
예제 #8
0
        public static void PlaceMS2Scan(IScans m_scans, Parameters parameters, List <double> dynamicBox)
        {
            if (m_scans.PossibleParameters.Length == 0)
            {
                return;
            }

            double      Range = parameters.MS1IonSelecting.IsolationWindow;
            ICustomScan scan  = m_scans.CreateCustomScan();

            scan.Values["FirstMass"]          = parameters.MS2ScanSetting.MS2MzRangeLowBound.ToString();
            scan.Values["LastMass"]           = parameters.MS2ScanSetting.MS2MzRangeHighBound.ToString(); //TO THINK: Dynamic range as MqLive?
            scan.Values["IsolationRangeLow"]  = parameters.MS2ScanSetting.MS2MzRangeLowBound.ToString();
            scan.Values["IsolationRangeHigh"] = parameters.MS2ScanSetting.MS2MzRangeLowBound.ToString();
            scan.Values["Resolution"]         = parameters.MS2ScanSetting.MS2Resolution.ToString();

            scan.Values["MaxIT"]             = parameters.MS2ScanSetting.MS2MaxInjectTimeInMillisecond.ToString();
            scan.Values["Resolution"]        = parameters.MS2ScanSetting.MS2Resolution.ToString();
            scan.Values["Polarity"]          = parameters.GeneralSetting.Polarity.ToString();
            scan.Values["NCE"]               = parameters.MS2ScanSetting.NCE.ToString();
            scan.Values["NCE_NormCharge"]    = parameters.MS1IonSelecting.NormCharge.ToString();
            scan.Values["NCE_SteppedEnergy"] = "0";
            if (parameters.MS2ScanSetting.NCE_factors != "null")
            {
                scan.Values["NCE_Factors"] = parameters.MS2ScanSetting.NCE_factors;
            }
            scan.Values["SourceCID"]  = parameters.GeneralSetting.SourceCID.ToString("0.00");
            scan.Values["Microscans"] = parameters.MS2ScanSetting.MS2MicroScans.ToString();
            scan.Values["AGC_Target"] = parameters.MS2ScanSetting.MS2AgcTarget.ToString();
            scan.Values["AGC_Mode"]   = parameters.GeneralSetting.AGC_Mode.ToString();


            string dynamicTargets;
            string dynamicMaxIts;
            var    dynamicBoxString = BuildDynamicBoxInclusionString(parameters, dynamicBox, out dynamicTargets, out dynamicMaxIts);

            scan.Values["MsxInjectRanges"]  = dynamicBoxString;
            scan.Values["MsxInjectTargets"] = dynamicTargets;
            scan.Values["MsxInjectMaxITs"]  = dynamicMaxIts;

            scan.Values["MsxInjectNCEs"]      = "[]";
            scan.Values["MsxInjectDirectCEs"] = "[]";

            Console.WriteLine("{0:HH:mm:ss,fff} placing data dependent ms2 scan {1}", DateTime.Now, dynamicBoxString);
            m_scans.SetCustomScan(scan);
        }
예제 #9
0
        private void PlaceScan()
        {
            if (m_scanId > 10)
            {
                return;
            }
            ICustomScan scan = m_scans.CreateCustomScan();

            scan.RunningNumber      = m_scanId++;
            scan.Values["Polarity"] = "1";
            if (m_scanId == 5)
            {
                // Let the instrument wait for a maximum of 500 seconds, which will not happen under normal circumstances.
                // Within that time, the instrument waits for placing a new scan
                scan.SingleProcessingDelay = 500;
            }
            Console.WriteLine("{0:HH:mm:ss,fff} placing scan {1}", DateTime.Now, scan.RunningNumber);
            m_scans.SetCustomScan(scan);
        }
예제 #10
0
        //parameter Tuple<double, double, double> for each box start m/z, end m/z, m/z length
        public static void PlaceDynamicBoxCarScan(IScans m_scans, Parameters parameters, Tuple <double, double, double>[] dynamicBox)
        {
            if (m_scans.PossibleParameters.Length == 0)
            {
                return;
            }

            ICustomScan scan = m_scans.CreateCustomScan();

            scan.Values["FirstMass"]          = parameters.BoxCarScanSetting.BoxCarMzRangeLowBound.ToString();
            scan.Values["LastMass"]           = parameters.BoxCarScanSetting.BoxCarMzRangeHighBound.ToString();
            scan.Values["IsolationRangeLow"]  = (parameters.BoxCarScanSetting.BoxCarMzRangeLowBound - 200).ToString();
            scan.Values["IsolationRangeHigh"] = (parameters.BoxCarScanSetting.BoxCarMzRangeHighBound + 200).ToString();

            scan.Values["MaxIT"]             = parameters.BoxCarScanSetting.BoxCarMaxInjectTimeInMillisecond.ToString();
            scan.Values["Resolution"]        = parameters.BoxCarScanSetting.BoxCarResolution.ToString();
            scan.Values["Polarity"]          = parameters.GeneralSetting.Polarity.ToString();
            scan.Values["NCE"]               = "0.0";
            scan.Values["NCE_NormCharge"]    = parameters.BoxCarScanSetting.BoxCarNormCharge.ToString();
            scan.Values["NCE_SteppedEnergy"] = "0";
            scan.Values["NCE_Factors"]       = "[]";

            scan.Values["SourceCID"]  = parameters.GeneralSetting.SourceCID.ToString("0.00");
            scan.Values["Microscans"] = parameters.BoxCarScanSetting.BoxCarMicroScans.ToString();
            scan.Values["AGC_Target"] = parameters.BoxCarScanSetting.BoxCarAgcTarget.ToString();
            scan.Values["AGC_Mode"]   = parameters.GeneralSetting.AGC_Mode.ToString();



            string dynamicTargets;
            string dynamicMaxIts;
            var    dynamicBoxString = BuildDynamicBoxString(parameters, dynamicBox, out dynamicTargets, out dynamicMaxIts);

            scan.Values["MsxInjectRanges"]  = dynamicBoxString;
            scan.Values["MsxInjectTargets"] = dynamicTargets;
            scan.Values["MsxInjectMaxITs"]  = dynamicMaxIts;

            scan.Values["MsxInjectNCEs"]      = "[]";
            scan.Values["MsxInjectDirectCEs"] = "[]";

            Console.WriteLine("{0:HH:mm:ss,fff} placing Dynamic BoxCar MS1 scan {1}", DateTime.Now, dynamicBoxString);
            m_scans.SetCustomScan(scan);
        }
        private void GenerateMS1()
        {
            ICustomScan basic_ms1 = baseMS1();

            ScanID.Add(basic_ms1.RunningNumber, ScanType.MS1);

            ICustomScan box_1 = baseMS1();

            box_1.Values["MsxInjectRanges"] = Parameters["Box_1_Ranges"];
            box_1.Values["MsxInjectTarget"] = Parameters["Box_InjectTargets"];
            box_1.Values["MsxInjectMaxITs"] = Parameters["Box_MaxITs"];
            box_1.Values["MsxInjectNCEs"]   = Parameters["Box_InjectNCEs"];
            ScanID.Add(box_1.RunningNumber, ScanType.BoxMS1_1);

            ICustomScan box_2 = baseMS1();

            box_2.Values["MsxInjectRanges"] = Parameters["Box_2_Ranges"];
            box_2.Values["MsxInjectTarget"] = Parameters["Box_InjectTargets"];
            box_2.Values["MsxInjectMaxITs"] = Parameters["Box_MaxITs"];
            box_2.Values["MsxInjectNCEs"]   = Parameters["Box_InjectNCEs"];
            ScanID.Add(box_2.RunningNumber, ScanType.BoxMS1_2);

            ICustomScan box_3 = baseMS1();

            box_3.Values["MsxInjectRanges"] = Parameters["Box_3_Ranges"];
            box_3.Values["MsxInjectTarget"] = Parameters["Box_InjectTargets"];
            box_3.Values["MsxInjectMaxITs"] = Parameters["Box_MaxITs"];
            box_3.Values["MsxInjectNCEs"]   = Parameters["Box_InjectNCEs"];
            ScanID.Add(box_3.RunningNumber, ScanType.BoxMS1_3);

            Console.WriteLine("BOXED." + " " + basic_ms1.RunningNumber.ToString()
                              + " " + box_1.RunningNumber.ToString()
                              + " " + box_2.RunningNumber.ToString()
                              + " " + box_2.RunningNumber.ToString());

            scan_queue.Enqueue(basic_ms1);
            scan_queue.Enqueue(box_1);
            scan_queue.Enqueue(box_2);
            scan_queue.Enqueue(box_3);

            MS1_outstanding = true;
        }
예제 #12
0
        public override bool assignScan(out ICustomScan newscan)
        {
            newscan = null;
            //Console.WriteLine("Attempting assignment; " + MS1_outstanding.ToString());

            if (scan_queue.IsEmpty && MS1_tardiness.Elapsed > MS1_expiration_span)
            {
                //Debug.Assert(false);
                Console.WriteLine("ERRANT MS1, resubmitting MS1.");
                log_write("MS1 TIMEOUT AT " + RunTimer.Elapsed.ToString());
                MS1_outstanding = false;
            }

            //ICustomScan newscan;
            if (!scan_queue.TryDequeue(out newscan) && !MS1_outstanding)
            {
                GenerateMS1();
                MS1_outstanding = true;
                MS1_tardiness.Restart();
                Debug.Assert(scan_queue.Count == 1);
                Debug.Assert(scan_queue.TryDequeue(out newscan));
                Console.WriteLine("Generated MS1.");
                log_write("Generated MS1.");
            }
            if (newscan == null)
            {
                Console.Write(".");
                //log_write("Waiting for assignment. " + MS1_tardiness.Elapsed.ToString());
                logfile.Flush();
                return(false);
            }
            else
            {
                ScanType scantype = ScanType.Unknown;
                ScanID.TryGetValue(newscan.RunningNumber, out scantype);
                Console.WriteLine("Assigning " + scantype.ToString() + " " + newscan.RunningNumber.ToString());
                log_write("Assigning " + scantype.ToString() + " " + newscan.RunningNumber.ToString());
                logfile.Flush();
                return(true);
            }
        }
예제 #13
0
        void send_inaugural_scan()
        {
            ICustomScan scan = scanner.CreateCustomScan();

            scan.SingleProcessingDelay = 5.0D;
            scan.Values["FirstMass"]   = "345";
            scan.Values["LastMass"]    = "789";
            scan.Values["Polarity"]    = "0";
            scan.Values["NCE"]         = "0"; // Whether this is set seems to control whether its an MS1 or MS2.
            scan.Values["Resolution"]  = "15000";
            scan.Values["AGC_Target"]  = "10000";
            scan.Values["MaxIT"]       = "10";
            scan.Values["Microscans"]  = "1";

            can_submit_scan.WaitOne();
            while (!scanner.SetCustomScan(scan))
            {
                Thread.Sleep(5);
            }
            Console.WriteLine("Submitted starting scan.");
        }
예제 #14
0
        private void GenerateMS1()
        {
            ICustomScan newscan = ScanManager.CreateCustomScan();

            newscan.SingleProcessingDelay = 10.0D;
            newscan.Values["FirstMass"]   = Parameters["MS1_FirstMass"];
            newscan.Values["LastMass"]    = Parameters["MS1_LastMass"];
            newscan.Values["Polarity"]    = Parameters["MS1_Polarity"];
            newscan.Values["NCE"]         = "0"; // Whether this is set seems to control whether its an MS1 or MS2.
            newscan.Values["Resolution"]  = Parameters["MS1_Resolution"];
            newscan.Values["AGC_Target"]  = Parameters["MS1_AGC_Target"];
            newscan.Values["MaxIT"]       = Parameters["MS1_MaxIT"];
            newscan.Values["Microscans"]  = Parameters["MS1_Microscans"];
            newscan.RunningNumber         = ScanCount++;
            ScanID.Add(newscan.RunningNumber, ScanType.MS1);

            //Console.WriteLine("Submitting |" + scanlabel + "| starting from " + sweep_mz.ToString() + " scan number " + current_scan_number);

            scan_queue.Enqueue(newscan);
            //log_write("Submitting MS1.");
        }
예제 #15
0
        public static void PlaceStaticBoxCarScan(IScans m_scans, Parameters parameters)
        {
            if (m_scans.PossibleParameters.Length == 0)
            {
                return;
            }

            ICustomScan scan = m_scans.CreateCustomScan();

            scan.Values["FirstMass"]          = parameters.BoxCarScanSetting.BoxCarMzRangeLowBound.ToString();
            scan.Values["LastMass"]           = parameters.BoxCarScanSetting.BoxCarMzRangeHighBound.ToString();
            scan.Values["IsolationRangeLow"]  = (parameters.BoxCarScanSetting.BoxCarMzRangeLowBound).ToString();
            scan.Values["IsolationRangeHigh"] = (parameters.BoxCarScanSetting.BoxCarMzRangeHighBound).ToString();

            scan.Values["MaxIT"]             = parameters.BoxCarScanSetting.BoxCarMaxInjectTimeInMillisecond.ToString();
            scan.Values["Resolution"]        = parameters.BoxCarScanSetting.BoxCarResolution.ToString();
            scan.Values["Polarity"]          = parameters.GeneralSetting.Polarity.ToString();
            scan.Values["NCE"]               = "0.0";
            scan.Values["NCE_NormCharge"]    = parameters.BoxCarScanSetting.BoxCarNormCharge.ToString();
            scan.Values["NCE_SteppedEnergy"] = "0";
            scan.Values["NCE_Factors"]       = "[]";

            scan.Values["SourceCID"]  = parameters.GeneralSetting.SourceCID.ToString("0.00");
            scan.Values["Microscans"] = parameters.BoxCarScanSetting.BoxCarMicroScans.ToString();
            scan.Values["AGC_Target"] = parameters.BoxCarScanSetting.BoxCarAgcTarget.ToString();
            scan.Values["AGC_Mode"]   = parameters.GeneralSetting.AGC_Mode.ToString();

            scan.Values["MsxInjectTargets"]   = StaticBoxCarScanTargets;
            scan.Values["MsxInjectMaxITs"]    = StaticBoxCarScanMaxIts;
            scan.Values["MsxInjectNCEs"]      = "[]";
            scan.Values["MsxInjectDirectCEs"] = "[]";
            for (int i = 0; i < parameters.BoxCarScanSetting.NumberOfBoxCarScans; i++)
            {
                scan.Values["MsxInjectRanges"] = StaticBoxCarScanRanges[i];

                Console.WriteLine("{0:HH:mm:ss,fff} placing BoxCar MS1 scan", DateTime.Now);
                m_scans.SetCustomScan(scan);
            }
        }
예제 #16
0
 void submitScan() // Separate from readyForScan_Response so that it can be called directly to begin custom scans.
 {
     try
     {
         acquisition.WaitFor(TimeSpan.FromSeconds(0.5), SystemMode.On, SystemMode.DirectControl);
         ICustomScan newscan = null;
         while (accepting_scans && newscan == null)
         {
             //Console.WriteLine("Entering mutex2.");
             planner_MUT.WaitOne();
             //Console.WriteLine("Got mutex2.");
             runProgram.assignScan(out newscan);
             //Console.WriteLine("Leaving mutex2.");
             planner_MUT.ReleaseMutex();
             //Console.WriteLine("Out of mutex2.");
             Thread.Sleep(5);
         }
         //bool result = scanner.SetCustomScan(newscan);
         //Console.WriteLine("Waiting to submit.");
         logfile.WriteLine("Waiting to submit.");
         can_submit_scan.WaitOne(); // WaitOne also grabs a semaphore-unit, apparently.
                                    //Console.WriteLine("Initiating submission.");
         logfile.WriteLine("Initiating submission.");
         while (accepting_scans && !scanner.SetCustomScan(newscan))
         {
             Thread.Sleep(5);
         }
         //Console.WriteLine("Submitted.");
         logfile.WriteLine("Submitted.");
     }
     catch (Exception err)
     {
         Console.WriteLine("Caught exception in submitScan!  Cancelling voltage.");
         change_voltage(0);
         Console.WriteLine(err.ToString());
         throw;
     }
 }
예제 #17
0
        private void GenerateMS2s(IEnumerable <Tuple <int, Tuple <double, double> > > mz_sites)
        {
            HashSet <double> unexclude_mzs = new HashSet <double>();

            foreach (var mz in mz_exclusion_intervals.Keys)
            {
                if (mz_exclusion_intervals[mz] + exclusion_time_interval < RunTimer.Elapsed)
                {
                    unexclude_mzs.Add(mz);
                }
            }
            Console.WriteLine("Unexcluding " + unexclude_mzs.Count.ToString() + " of " + mz_exclusion_intervals.Count.ToString());
            foreach (var mz in unexclude_mzs)
            {
                mz_exclusion_intervals.Remove(mz);
            }

            int  assigned_scan_count = 0;
            int  MS1_after_number    = scan_limit_per_cycle - 4;
            bool MS1_submitted       = false;

            foreach (var precursor in mz_sites)
            {
                double mz_site = precursor.Item2.Item1;
                int    charge  = precursor.Item1;

                if (assigned_scan_count > scan_limit_per_cycle)
                {
                    break;
                }

                if (mz_site == 0)
                {
                    continue;
                }

                if (precursor.Item2.Item2 < PrecursorIntensityThreshold)
                {
                    continue;
                }

                bool excluded = false;
                foreach (var mz in mz_exclusion_intervals.Keys)
                {
                    if (Math.Abs(mz - mz_site) < mz_tolerance)
                    {
                        excluded = true;
                        break;
                    }
                }
                if (excluded)
                {
                    continue;
                }

                // Setting charge above 5 seems to cause an error; higher-charge
                // peptides can still be found if the charge is set to 5.
                if (charge > 5)
                {
                    charge = 5;
                }

                mz_exclusion_intervals[mz_site] = RunTimer.Elapsed;



                ICustomScan newscan = ScanManager.CreateCustomScan();
                newscan.SingleProcessingDelay        = 10.0D;
                newscan.Values["IsolationRangeLow"]  = (mz_site - (isolation_width / 2)).ToString();
                newscan.Values["IsolationRangeHigh"] = (mz_site + (isolation_width / 2)).ToString();
                newscan.Values["FirstMass"]          = Parameters["MS2_FirstMass"];
                newscan.Values["LastMass"]           = Parameters["MS2_LastMass"];
                newscan.Values["Polarity"]           = Parameters["MS2_Polarity"];
                newscan.Values["NCE"]            = Parameters["MS2_NCE"]; // Whether this is set seems to control whether its an MS1 or MS2.
                newscan.Values["NCE_NormCharge"] = charge.ToString();
                newscan.Values["Resolution"]     = Parameters["MS2_Resolution"];

                newscan.Values["AGC_Target"] = Parameters["MS2_AGC_Target"];
                newscan.Values["MaxIT"]      = Parameters["MS2_MaxIT"]; // Is this in ms???????


                newscan.Values["Microscans"] = Parameters["MS2_Microscans"];
                newscan.RunningNumber        = ScanCount++;
                ScanID.Add(newscan.RunningNumber, ScanType.MS2);
                //Console.WriteLine("Normcharge: " + charge.ToString());
                assigned_scan_count += 1;
                scan_queue.Enqueue(newscan);
                scaninfo_file.WriteLine(newscan.RunningNumber.ToString() + " " + mz_site.ToString() + " " + charge.ToString() + " " + precursor.Item2.Item2 + "__");

                if ((!MS1_submitted) && assigned_scan_count >= MS1_after_number)
                {
                    GenerateMS1();
                    Console.WriteLine("MS1 submitted midcycle.");
                    log_write("MS1 submitted midcycle.");
                    MS1_submitted   = true;
                    MS1_outstanding = true;
                    MS1_tardiness.Restart();
                }
            }
            if (!MS1_submitted)
            {
                GenerateMS1();
                Console.WriteLine("MS1 submitted postcycle.");
                log_write("MS1 submitted postcycle.");
                MS1_submitted   = true;
                MS1_outstanding = true;
                MS1_tardiness.Restart();
            }
            Console.WriteLine("MS2s: Submitted " + assigned_scan_count.ToString() + " out of " + mz_sites.Count() + " " + scan_queue.Count());
            log_write("MS2s: Submitted " + assigned_scan_count.ToString() + " out of " + mz_sites.Count() + " " + scan_queue.Count());
        }
예제 #18
0
        public static void PlaceMS2Scan(IScans m_scans, Parameters parameters, double mz)
        {
            if (m_scans.PossibleParameters.Length == 0)
            {
                return;
            }

            double Range = parameters.MS1IonSelecting.IsolationWindow;
            string xl    = (mz - Range).ToString("0.000");
            string xh    = (mz + Range).ToString("0.000");

            if (mz - Range < 50.0)
            {
                Console.WriteLine("placing data dependent ms2 scan wrong, the Ms2MzRangeLowBound should larger than 50!!!");

                return;
            }
            ICustomScan scan = m_scans.CreateCustomScan();

            scan.Values["FirstMass"]          = parameters.MS2ScanSetting.MS2MzRangeLowBound.ToString();
            scan.Values["LastMass"]           = parameters.MS2ScanSetting.MS2MzRangeHighBound.ToString(); //TO THINK: Dynamic range as MqLive?
            scan.Values["IsolationRangeLow"]  = xl;
            scan.Values["IsolationRangeHigh"] = xh;
            scan.Values["Resolution"]         = parameters.MS2ScanSetting.MS2Resolution.ToString();

            scan.Values["MaxIT"]             = parameters.MS2ScanSetting.MS2MaxInjectTimeInMillisecond.ToString();
            scan.Values["Resolution"]        = parameters.MS2ScanSetting.MS2Resolution.ToString();
            scan.Values["Polarity"]          = parameters.GeneralSetting.Polarity.ToString();
            scan.Values["NCE"]               = parameters.MS2ScanSetting.NCE.ToString();
            scan.Values["NCE_NormCharge"]    = parameters.MS1IonSelecting.NormCharge.ToString();
            scan.Values["NCE_SteppedEnergy"] = "0";
            if (parameters.MS2ScanSetting.NCE_factors != "null")
            {
                scan.Values["NCE_Factors"] = parameters.MS2ScanSetting.NCE_factors;
            }
            scan.Values["SourceCID"]  = parameters.GeneralSetting.SourceCID.ToString("0.00");
            scan.Values["Microscans"] = parameters.MS2ScanSetting.MS2MicroScans.ToString();
            scan.Values["AGC_Target"] = parameters.MS2ScanSetting.MS2AgcTarget.ToString();
            scan.Values["AGC_Mode"]   = parameters.GeneralSetting.AGC_Mode.ToString();


            scan.Values["MsxInjectRanges"]    = "[]";
            scan.Values["MsxInjectTargets"]   = "[]";
            scan.Values["MsxInjectMaxITs"]    = "[]";
            scan.Values["MsxInjectNCEs"]      = "[]";
            scan.Values["MsxInjectDirectCEs"] = "[]";

            //Console.WriteLine("++++++++++++++++++");
            //Console.WriteLine("Target Isolation Mass: {0}, {1}", xl, xh);
            //foreach (var v in scan.Values)
            //{
            //    Console.WriteLine(v);
            //}

            ////This is the code where we find all the scan settings.
            ////foreach (var item in m_scans.PossibleParameters)
            ////{
            ////    Console.WriteLine(item.Name + "----" + item.DefaultValue + "----" + item.Help + "----" + item.Selection);
            ////}

            Console.WriteLine("{0:HH:mm:ss,fff} placing data dependent ms2 scan {1}", DateTime.Now, mz);
            m_scans.SetCustomScan(scan);
        }
예제 #19
0
 public abstract bool assignScan(out ICustomScan newscan);
예제 #20
0
        public bool CreateCustomScan(long runningNumber, double precursorMass, double isolationWidth, double collisionEnergy, int msLevel,
                                     string polarity, double firstMass, double lastMass, double singleProcessingDelay)
        {
            WriteLog(String.Format("Placing a custom scan (runningNumber={0}, singleProcessingDelay={1})", runningNumber, singleProcessingDelay));

            // TODO: validate input

            if (ScanControl.PossibleParameters.Length > 0)
            {
                ICustomScan cs = ScanControl.CreateCustomScan();
                cs.RunningNumber = runningNumber;

                // Allow an extra delay of 500 ms, we will answer as fast as possible, so this is a maximum value.
                cs.SingleProcessingDelay = singleProcessingDelay;

                // Set the custom scan parameters
                cs.Values["CollisionEnergy"] = collisionEnergy.ToString();
                cs.Values["FirstMass"]       = firstMass.ToString();
                cs.Values["LastMass"]        = lastMass.ToString();
                cs.Values["Analyzer"]        = "Orbitrap";
                cs.Values["Polarity"]        = polarity;
                cs.Values["IsolationWidth"]  = isolationWidth.ToString();
                cs.Values["PrecursorMass"]   = precursorMass.ToString();
                if (msLevel == 1)
                {
                    cs.Values["ScanType"]           = "Full";
                    cs.Values["OrbitrapResolution"] = "120000";
                }
                else
                {
                    cs.Values["ScanType"]           = "MSn";
                    cs.Values["OrbitrapResolution"] = "7500";
                }
                cs.Values["ActivationType"] = "HCD";
                cs.Values["DataType"]       = "Centroid";
                cs.Values["AGCTarget"]      = "30000";
                cs.Values["MaxIT"]          = "100";
                cs.Values["Microscans"]     = "3";

                // Dump key-value pairs in cs.Values
                foreach (KeyValuePair <string, string> kvp in cs.Values)
                {
                    string msg = string.Format("- cs.Values\tKey = {0}, Value = {1}", kvp.Key, kvp.Value);
                    WriteLog(msg);
                }

                try
                {
                    if (!ScanControl.SetCustomScan(cs))
                    {
                        WriteLog(String.Format("FAILED to place a custom scan (runningNumber={0}): connection to service broken!!", cs.RunningNumber));
                        return(false);
                    }
                    else
                    {
                        if (cs.Values["ScanType"] == "Full")
                        {
                            WriteLog(String.Format("Successfully placed a custom fullscan scan (runningNumber={0})", cs.RunningNumber));
                        }
                        else if (cs.Values["ScanType"] == "MSn")
                        {
                            WriteLog(String.Format("Successfully placed a custom MSn scan (runningNumber={0})", cs.RunningNumber));
                        }
                        return(true);
                    }
                }
                catch (Exception e)
                {
                    WriteLog(String.Format("FAILED to place a custom scan (runningNumber={0}): {1}", cs.RunningNumber, e.Message));
                    WriteLog(String.Format("Stacktrace: {0}", e.StackTrace));
                    throw;
                }
            }
            else
            {
                WriteLog(String.Format("FAILED to place a custom scan (runningNumber={0}): no parameters available!!", runningNumber));
                return(false);
            }
        }
        private void GenerateMS2s(IEnumerable <Peak> mz_sites)
        {
            exclusion_list.Unexclude(RunTimer.Elapsed);

            int  assigned_scan_count = 0;
            int  MS1_after_number    = scan_limit_per_cycle - 4;
            bool MS1_submitted       = false;

            foreach (var precursor in mz_sites)
            {
                double mz_site = precursor.Item1;
                int    charge;
                if (precursor.Item3 != null)
                {
                    charge = (int)precursor.Item3;
                }
                else
                {
                    charge = 2;
                }


                if (assigned_scan_count > scan_limit_per_cycle)
                {
                    break;
                }

                if (mz_site == 0)
                {
                    continue;
                }

                if (precursor.Item2 < PrecursorIntensityThreshold)
                {
                    continue;
                }

                if (exclusion_list.Is_Excluded(RunTimer.Elapsed, precursor))
                {
                    continue;
                }

                // Setting charge above 5 seems to cause an error; higher-charge
                // peptides can still be found if the charge is set to 5.
                if (charge > 5)
                {
                    charge = 5;
                }

                exclusion_list.Exclude(RunTimer.Elapsed, precursor);

                //double injection_time = (65000000.0 / precursor.Item2.Item2) + 0.03;
                double prec_int       = precursor.Item2;
                double injection_time = -1;
                if (prec_int < PrecursorAGCThreshold)
                {
                    injection_time = 50.0;
                }
                //else
                //{
                //    injection_time = (Convert.ToDouble(Parameters["INJ_Constant"]) / precursor.Item2.Item2) + 0.03;
                //    if (injection_time > 50.0)
                //    {
                //        injection_time = 50.0;
                //    }
                //}


                ICustomScan newscan = ScanManager.CreateCustomScan();
                newscan.SingleProcessingDelay        = 10.0D;
                newscan.Values["IsolationRangeLow"]  = (mz_site - (isolation_width / 2)).ToString();
                newscan.Values["IsolationRangeHigh"] = (mz_site + (isolation_width / 2)).ToString();
                newscan.Values["FirstMass"]          = Parameters["MS2_FirstMass"];
                newscan.Values["LastMass"]           = Parameters["MS2_LastMass"];
                newscan.Values["Polarity"]           = Parameters["MS2_Polarity"];
                newscan.Values["NCE"]            = Parameters["MS2_NCE"]; // Whether this is set seems to control whether its an MS1 or MS2.
                newscan.Values["NCE_NormCharge"] = charge.ToString();
                newscan.Values["Resolution"]     = Parameters["MS2_Resolution"];
                newscan.Values["Microscans"]     = Parameters["MS2_Microscans"];

                if (injection_time > 0)
                {
                    newscan.Values["AGC_Mode"] = "0";
                    newscan.Values["MaxIT"]    = injection_time.ToString();
                }
                else
                {
                    newscan.Values["AGC_Target"] = Parameters["MS2_AGC_Target"];
                    newscan.Values["MaxIT"]      = Parameters["MS2_MaxIT"];
                }

                newscan.RunningNumber = ScanCount++;
                ScanID.Add(newscan.RunningNumber, ScanType.MS2);
                //Console.WriteLine("Normcharge: " + charge.ToString());
                assigned_scan_count += 1;
                scan_queue.Enqueue(newscan);
                scaninfo_file.WriteLine(newscan.RunningNumber.ToString() + " " + mz_site.ToString() + " " + charge.ToString() + " " + injection_time.ToString() + " " + prec_int.ToString() + "__");

                if ((!MS1_submitted) && assigned_scan_count >= MS1_after_number)
                {
                    GenerateMS1();
                    Console.WriteLine("MS1 submitted midcycle.");
                    log_write("MS1 submitted midcycle.");
                    MS1_submitted   = true;
                    MS1_outstanding = true;
                    MS1_tardiness.Restart();
                }
            }
            if (!MS1_submitted)
            {
                GenerateMS1();
                Console.WriteLine("MS1 submitted postcycle.");
                log_write("MS1 submitted postcycle.");
                MS1_submitted   = true;
                MS1_outstanding = true;
                MS1_tardiness.Restart();
            }
            Console.WriteLine("MS2s: Submitted " + assigned_scan_count.ToString() + " out of " + mz_sites.Count() + " " + scan_queue.Count());
            log_write("MS2s: Submitted " + assigned_scan_count.ToString() + " out of " + mz_sites.Count() + " " + scan_queue.Count());
            scaninfo_file.Flush();
        }
        private void GenerateMS2s(IEnumerable <Peak> mz_sites)
        {
            HashSet <double> unexclude_mzs = new HashSet <double>();

            foreach (var mz in mz_exclusion_intervals.Keys)
            {
                if (mz_exclusion_intervals[mz] + exclusion_time_interval < RunTimer.Elapsed)
                {
                    unexclude_mzs.Add(mz);
                }
            }
            Console.WriteLine("Unexcluding " + unexclude_mzs.Count.ToString() + " of " + mz_exclusion_intervals.Count.ToString());
            foreach (var mz in unexclude_mzs)
            {
                mz_exclusion_intervals.Remove(mz);
            }

            int assigned_scan_count = 0;

            foreach (var precursor in mz_sites)
            {
                //Tuple<double, double> precursor = charge_precursor.Item2;
                //double mz_site = precursor.Item1;
                //int charge = charge_precursor.Item1;
                double mz_site = precursor.Item1;
                int    charge;
                if (precursor.Item3 != null)
                {
                    charge = (int)precursor.Item3;
                }
                else
                {
                    charge = 2;
                }


                if (assigned_scan_count > scan_limit_per_cycle)
                {
                    break;
                }
                // Setting charge above 5 seems to cause an error; higher-charge
                // peptides can still be found if the charge is set to 5.
                if (mz_site == 0 || charge > 5)
                {
                    continue;
                }
                bool excluded = false;
                foreach (var mz in mz_exclusion_intervals.Keys)
                {
                    if (Math.Abs(mz - mz_site) < mz_tolerance)
                    {
                        excluded = true;
                        break;
                    }
                }
                if (excluded)
                {
                    continue;
                }

                mz_exclusion_intervals[mz_site] = RunTimer.Elapsed;

                ICustomScan newscan = ScanManager.CreateCustomScan();



                newscan.SingleProcessingDelay        = 10.0D;
                newscan.Values["IsolationRangeLow"]  = (mz_site - (isolation_width / 2)).ToString();
                newscan.Values["IsolationRangeHigh"] = (mz_site + (isolation_width / 2)).ToString();
                newscan.Values["FirstMass"]          = "100";
                newscan.Values["LastMass"]           = "2000";
                newscan.Values["Polarity"]           = "0";
                newscan.Values["NCE"]            = "27"; // Whether this is set seems to control whether its an MS1 or MS2.
                newscan.Values["NCE_NormCharge"] = charge.ToString();
                newscan.Values["Resolution"]     = "15000";
                newscan.Values["AGC_Target"]     = "10000";
                newscan.Values["MaxIT"]          = "50"; // Is this in ms???????
                newscan.Values["Microscans"]     = "1";
                newscan.RunningNumber            = ScanCount++;
                ScanID.Add(newscan.RunningNumber, ScanType.MS2);
                Console.WriteLine("Normcharge: " + charge.ToString());
                assigned_scan_count += 1;
                scan_queue.Enqueue(newscan);
            }
            Console.WriteLine("MS2s: Submitted " + assigned_scan_count.ToString() + " out of " + mz_sites.Count() + " " + scan_queue.Count());
        }