public MyScanContainer(IEnumerable <SimpleSpectrum> spectra) { SimpleSpectrum[] allSpectra = spectra.ToArray(); SimpleSpectrum previous = null; for (int i = 0; i < allSpectra.Length; i++) { SimpleSpectrum current = allSpectra[i]; if (current.MsLevel == 1) { originalMs1Spectra.Add(current); } else { originalMsnSpectra.Add(current); } // compute the scan duration of the previous scan if (i == 0) { previous = current; } else { double previousDuration = (current.ScanStartTime - previous.ScanStartTime) * 60; scanDurations.Add(previous.ScanNumber, previousDuration); previous = current; } } }
// Use this for initialization void Start() { spectrumAnalyzer = spectrumAsset.GetComponent <SimpleSpectrum>(); //ps = GetComponent<ParticleSystem>(); pShape = ps.shape; pMain = ps.main; vMain = ps.velocityOverLifetime; }
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); }
private bool disposedValue = false; // To detect redundant calls public MyMsScan(SimpleSpectrum scan, long runningNumber, DateTime startTime) { // obtained from checking the dumps of scan header from the actual instrument this.Header["MassAnalyzer"] = ""; this.Header["IonizationMode"] = ""; this.Header["ScanRate"] = ""; this.Header["ScanMode"] = ""; double elapsedTime = DateTime.Now.Subtract(startTime).TotalSeconds; this.Header["StartTime"] = elapsedTime.ToString(); this.Header["Scan"] = scan.ScanNumber.ToString(); this.Header["TIC"] = scan.TotalIonCurrent.ToString(); this.Header["BasePeakIntensity"] = ""; this.Header["BasePeakMass"] = ""; this.Header["CycleNumber"] = ""; this.Header["Polarity"] = "0"; this.Header["Microscans"] = ""; this.Header["InjectTime"] = ""; this.Header["ScanData"] = ""; this.Header["Segments"] = ""; this.Header["Monoisotopic"] = ""; this.Header["MasterScan"] = runningNumber.ToString(); this.Header["FirstMass"] = ""; this.Header["LastMass"] = ""; this.Header["Checksum"] = ""; this.Header["MSOrder"] = scan.MsLevel.ToString(); this.Header["Average"] = ""; this.Header["Dependent"] = ""; this.Header["MSX"] = ""; this.Header["SourceFragmentaiton"] = ""; // the spelling is correct here, "SourceFragmentaiton" this.Header["SourceFragmentationEnergy"] = ""; this.Trailer = new MyTrailer(runningNumber); List <ICentroid> myList = new List <ICentroid>(); if (scan.Centroided) { this.CentroidCount = scan.Mzs.Length; foreach (Peak p in scan.Peaks) { ICentroid centroid = new MyCentroid(p); myList.Add(centroid); } this.Centroids = myList; } }