Beispiel #1
0
        /// <summary>
        /// Illustrate how to make calls to deisotope a spectrum.
        /// </summary>
        /// <param name="dataAccess"></param>
        private void DeisotopeTest(IMsdrDataReader dataAccess)
        {
            IMsdrPeakFilter filter1 = new MsdrPeakFilter();

            filter1.AbsoluteThreshold = 10;
            filter1.RelativeThreshold = 0.1;
            filter1.MaxNumPeaks       = 0;//no limit on max number of peaks
            IMsdrChargeStateAssignmentFilter csaFilter = new MsdrChargeStateAssignmentFilter();

            IBDASpecFilter f = new BDASpecFilter();

            f.SpectrumType = SpecType.MassSpectrum;

            IBDAMSScanFileInformation msscanFileInfo = dataAccess.MSScanFileInformation;
            int numSpectra     = (int)msscanFileInfo.TotalScansPresent;
            int nNonEmptyCount = 0; // just deisotope the first 10 non-empty spectra

            for (int i = 0; i < numSpectra; i++)
            {
                IBDASpecData spec = dataAccess.GetSpectrum(i, filter1, filter1);//same peak filter used for both MS and MS2 spectra (you can pass in 2 different filters)
                println("Original spectrum has " + spec.TotalDataPoints + " points");
                if (spec.XArray.Length > 0)
                {
                    ++nNonEmptyCount;
                }
                if (nNonEmptyCount > 10)
                {
                    break;
                }
                dataAccess.Deisotope(spec, csaFilter);
                println("  Deisotoped spectrum has " + spec.TotalDataPoints + " points");
            }
        }
Beispiel #2
0
        private static bool GetAccurateMZAndIntensity(IDictionary <int, IBDASpecData> ms1s, IMsdrDataReader agilentD, int parentScanId, ref double mz, out double intensity)
        {
            IBDASpecData ms1;

            lock (ms1s)
            {
                if (!ms1s.TryGetValue(parentScanId, out ms1))
                {
                    IBDASpecFilter spec_filter = new BDASpecFilter();
                    spec_filter.SpectrumType = SpecType.MassSpectrum;
                    spec_filter.ScanIds      = new int[] { parentScanId };
                    lock (agilentD)
                    {
                        ms1 = agilentD.GetSpectrum(spec_filter)[0];
                    }
                    ms1s.Add(parentScanId, ms1);
                }
            }

            int index = -1;

            for (int i = 0; i < ms1.TotalDataPoints; i++)
            {
                if (index < 0 || Math.Abs(ms1.XArray[i] - mz) < Math.Abs(ms1.XArray[index] - mz))
                {
                    index = i;
                }
            }

            if (index >= 0)
            {
                mz        = ms1.XArray[index];
                intensity = ms1.YArray[index];
                return(true);
            }

            intensity = double.NaN;
            return(false);
        }
        private static bool GetAccurateMZAndIntensity(IDictionary<int, IBDASpecData> ms1s, IMsdrDataReader agilentD, int parentScanId, ref double mz, out double intensity)
        {
            IBDASpecData ms1;
            lock(ms1s)
            {
                if(!ms1s.TryGetValue(parentScanId, out ms1))
                {
                    IBDASpecFilter spec_filter = new BDASpecFilter();
                    spec_filter.SpectrumType = SpecType.MassSpectrum;
                    spec_filter.ScanIds = new int[] { parentScanId };
                    lock(agilentD)
                    {
                        ms1 = agilentD.GetSpectrum(spec_filter)[0];
                    }
                    ms1s.Add(parentScanId, ms1);
                }
            }

            int index = -1;
            for(int i = 0; i < ms1.TotalDataPoints; i++)
            {
                if(index < 0 || Math.Abs(ms1.XArray[i] - mz) < Math.Abs(ms1.XArray[index] - mz))
                {
                    index = i;
                }
            }

            if(index >= 0)
            {
                mz = ms1.XArray[index];
                intensity = ms1.YArray[index];
                return true;
            }

            intensity = double.NaN;
            return false;
        }