public override int GetPrecusorCharge(int spectrumNumber, int msnOrder = 2)
        {
            IBDASpecData spectrum = _msdr.GetSpectrum(spectrumNumber - 1);
            int          precursor_charge;

            spectrum.GetPrecursorCharge(out precursor_charge);
            return((short)precursor_charge);
        }
Beispiel #2
0
        public override PrecursorInfo GetPrecursorInfo(int scanNum)
        {
            m_spec = m_reader.GetSpectrum(scanNum, null, null);

            var precursor = new PrecursorInfo();

            var level = m_spec.MSLevelInfo;

            if (level == MSLevel.MS)
            {
                precursor.MSLevel = 1;
            }
            else if (level == MSLevel.MSMS)
            {
                precursor.MSLevel = 2;
            }
            else
            {
                precursor.MSLevel = 1;
            }

            int precursorMassCount;

            //this returns a list of precursor masses (not sure how there can be more than one)
            var precursorMZlist = m_spec.GetPrecursorIon(out precursorMassCount);

            //if a mass is returned
            if (precursorMassCount == 1)
            {
                //mass
                precursor.PrecursorMZ = precursorMZlist[0];

                //intensity
                double precursorIntensity;
                m_spec.GetPrecursorIntensity(out precursorIntensity);
                precursor.PrecursorIntensity = (float)precursorIntensity;

                //charge
                int precursorCharge;
                m_spec.GetPrecursorCharge(out precursorCharge);
                precursor.PrecursorCharge = precursorCharge;

                //adjust scan number if needed
                precursor.PrecursorScan = scanNum;

                // TODO: Only CID possible in Aglent files?
                precursor.FragmentationType = FragmentionType.CID;
            }
            else if (precursorMassCount > 1)
            {
                throw new NotImplementedException("Strange case where more than one precursor is used to generate one spectra");
            }
            else
            {
                precursor.PrecursorMZ        = 0;
                precursor.PrecursorIntensity = 0;
                precursor.PrecursorCharge    = -1;
                precursor.PrecursorScan      = scanNum;
            }

            precursor.IonizationMode = m_spec.IonPolarity == IonPolarity.Negative ? IonizationMode.Negative : IonizationMode.Positive;

            return(precursor);
        }
Beispiel #3
0
        /// <summary>
        /// Get all Product Ion MS/MS scans and print out the precursor and collision energy.
        /// </summary>
        private void GetPrecursorInfo(IMsdrDataReader dataAccess)
        {
            //Create a chromatogram filter to let the scans that match
            //the filter criteria to pass through
            IBDAChromFilter chromFilter = new BDAChromFilter();

            chromFilter.ChromatogramType     = ChromType.TotalIon;
            chromFilter.DesiredMSStorageType = DesiredMSStorageType.PeakElseProfile;//This means to use peak scans if available, otherwise use profile scans
            chromFilter.MSLevelFilter        = MSLevel.MSMS;
            chromFilter.MSScanTypeFilter     = MSScanType.ProductIon;
            IBDAChromData[] chroms = dataAccess.GetChromatogram(chromFilter);//expect 1 chromatogram because we're not asking it to separate by scan segments, etc.
            IBDAChromData   chrom  = chroms[0];

            double[] retTime = chrom.XArray;
            println("Get MS/MS spectra using retention time");

            for (int i = 0; i < retTime.Length; i++)
            {
                //for each retention time, get the corresponding scan
                //passing in null for peak filter means no peak threshold applied
                IBDASpecData spec = dataAccess.GetSpectrum(retTime[i], MSScanType.ProductIon, IonPolarity.Mixed, IonizationMode.Unspecified, null);
                print("RT=" + retTime[i] + ", ");
                int      precursorCount = 0;
                double[] precursorIons  = spec.GetPrecursorIon(out precursorCount);

                if (precursorCount == 1)
                {
                    print("Precursor Ions:");
                    for (int j = 0; j < precursorIons.Length; j++)
                    {
                        print(precursorIons[j] + " ");
                    }
                    println("");
                    int    charge;
                    double intensity;
                    if (spec.GetPrecursorCharge(out charge))
                    {
                        println("  charge: " + charge);
                    }
                    else
                    {
                        println("  no charge avaialble");
                    }
                    if (spec.GetPrecursorIntensity(out intensity))
                    {
                        println("  intensity: " + intensity);
                    }
                    else
                    {
                        println("  no intensity available");
                    }
                }
                else
                {
                    println("No precursor ions");
                }

                /*
                 * //Uncomment this if you want to print out x and y values of the spectrum.
                 * double[] mzVals = spec.XArray;
                 * float[] aboundanceVals = spec.YArray;
                 * println("RT=" + retTime[i]);
                 * for (int j = 0; j < mzVals.Length; j++)
                 * {
                 *  println(mzVals[j] + ", " + aboundanceVals[j]);
                 * }
                 */
            }
        }