コード例 #1
0
ファイル: InputAdapterBase.cs プロジェクト: xj0229/gsf
 /// <summary>
 /// Raises the <see cref="ProcessingComplete"/> event.
 /// </summary>
 protected virtual void OnProcessingComplete()
 {
     try
     {
         ProcessingComplete?.Invoke(this, EventArgs.Empty);
     }
     catch (Exception ex)
     {
         // We protect our code from consumer thrown exceptions
         OnProcessException(MessageLevel.Info, new InvalidOperationException($"Exception in consumer handler for ProcessingComplete event: {ex.Message}", ex), "ConsumerEventException");
     }
 }
コード例 #2
0
ファイル: Job.cs プロジェクト: Javohir428/ds-4
        public override int GetHashCode()
        {
            int hash = 1;

            if (ProcessingComplete != false)
            {
                hash ^= ProcessingComplete.GetHashCode();
            }
            if (TextRank.Length != 0)
            {
                hash ^= TextRank.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
コード例 #3
0
        /// <summary>
        /// Examine the spectra in a _DTA.txt file to determine the number of centroided spectra
        /// </summary>
        /// <param name="concatenatedDtaPath"></param>
        /// <returns>True on success, false if an error</returns>
        public bool CheckCDTAFile(string concatenatedDtaPath)
        {
            var dtLastStatusTime = DateTime.UtcNow;

            var splitChars = new[] { ' ' };

            try
            {
                if (!File.Exists(concatenatedDtaPath))
                {
                    throw new FileNotFoundException("CDTA file not found: " + concatenatedDtaPath);
                }

                // Read the m/z values in the _dta.txt file
                // Using a simple text reader here for speed purposes

                using (var srDtaFile = new StreamReader(new FileStream(concatenatedDtaPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
                {
                    var lstMZs      = new List <double>(2000);
                    var lstPpmDiffs = new List <double>(2000);

                    double previousMz = 0;

                    while (!srDtaFile.EndOfStream)
                    {
                        var dataLine = srDtaFile.ReadLine();

                        if (string.IsNullOrEmpty(dataLine))
                        {
                            continue;
                        }

                        if (dataLine.StartsWith("============="))
                        {
                            // DTA header line

                            // Process the data for the previous spectrum
                            CheckPPMDiffs(lstMZs, lstPpmDiffs, 2, eCentroidStatusConstants.Unknown);

                            // Reset the previous m/z value and skip the next line (since it has parent ion m/z and charge)
                            if (!srDtaFile.EndOfStream)
                            {
                                srDtaFile.ReadLine();
                            }

                            previousMz = 0;
                            lstMZs.Clear();
                            lstPpmDiffs.Clear();

                            if (DateTime.UtcNow.Subtract(dtLastStatusTime).TotalSeconds >= 30)
                            {
                                ReadingSpectra?.Invoke(TotalSpectra);
                                dtLastStatusTime = DateTime.UtcNow;
                            }
                            continue;
                        }

                        var dataColumns = dataLine.Split(splitChars, 3);

                        if (!double.TryParse(dataColumns[0], out var mz))
                        {
                            continue;
                        }

                        lstMZs.Add(mz);

                        if (previousMz > 0 && mz > previousMz)
                        {
                            var delMassPPM = 1000000.0 * (mz - previousMz) / mz;
                            lstPpmDiffs.Add(delMassPPM);
                        }
                        previousMz = mz;
                    }

                    // Process the data for the previous spectrum
                    CheckPPMDiffs(lstMZs, lstPpmDiffs, 2, eCentroidStatusConstants.Unknown);
                }

                ProcessingComplete?.Invoke(TotalSpectra);

                return(true);
            }
            catch (Exception ex)
            {
                mErrorMessage = "Exception in CheckCDTAFile: " + ex.Message;
                OnErrorEvent(mErrorMessage, ex);
                return(false);
            }
        }
コード例 #4
0
ファイル: InputAdapterCollection.cs プロジェクト: xj0229/gsf
 // Raise processing complete event on behalf of each item in collection
 private void item_ProcessingComplete(object sender, EventArgs e) => ProcessingComplete?.Invoke(sender, e);