Exemple #1
0
        public ThermoSpectrum GetSpectrum(int spectrumNumber, bool profileIfAvailable = false)
        {
            bool useProfile = false;

            if (profileIfAvailable)
            {
                int isProfile = 0;
                _rawConnection.IsProfileScanForScanNum(spectrumNumber, ref isProfile);
                useProfile = isProfile == 1;
            }
            return(new ThermoSpectrum(GetLabeledData(spectrumNumber) ?? GetUnlabeledData(spectrumNumber, !useProfile)));
        }
Exemple #2
0
        public MZSpectrum GetSpectrum(int spectrumNumber, bool profileIfAvailable = false)
        {
            bool useProfile = false;

            if (profileIfAvailable)
            {
                int isProfile = 0;
                _rawConnection.IsProfileScanForScanNum(spectrumNumber, ref isProfile);
                useProfile = isProfile == 1;
            }

            var peakData = GetUnlabeledData(spectrumNumber, !useProfile);

            return(new MZSpectrum(peakData));
        }
Exemple #3
0
        private MSScan GetScanFromFile(int argScanNo, float argMinSN = 2)
        {
            int isProfile = 0;

            _rawConnection.IsProfileScanForScanNum(argScanNo, ref isProfile);

            object labels = null;
            object flags  = null;

            _rawConnection.GetLabelData(ref labels, ref flags, ref argScanNo);
            double[,] LabeledPeaks = (double[, ])labels;


            //Start Read Scan
            MSScan scan = new MSScan(argScanNo);
            List <ThermoLabeledPeak> FullLabeledPeak = new List <ThermoLabeledPeak>();

            float[] mz        = new float[LabeledPeaks.GetLength(1)];
            float[] intensity = new float[LabeledPeaks.GetLength(1)];
            int     j         = 0;

            for (int i = 0; i < LabeledPeaks.GetLength(1); i++)
            {
                double sn = LabeledPeaks[1, i] / LabeledPeaks[4, i];
                if (sn >= argMinSN)
                {
                    mz[j]        = Convert.ToSingle(LabeledPeaks[0, i]);
                    intensity[j] = Convert.ToSingle(LabeledPeaks[1, i]);
                    j++;
                    FullLabeledPeak.Add(new ThermoLabeledPeak(
                                            Convert.ToSingle(LabeledPeaks[0, i]),
                                            Convert.ToSingle(LabeledPeaks[1, i]),
                                            Convert.ToInt32(LabeledPeaks[5, i]),
                                            Convert.ToSingle(LabeledPeaks[4, i])));
                }
            }
            Array.Resize(ref mz, j);
            Array.Resize(ref intensity, j);

            //scan.MZs = ConvertDoubleArrayToFloatArray(CSMSLScan.MassSpectrum.GetMasses());
            scan.MZs = mz;
            //scan.Intensities = ConvertDoubleArrayToFloatArray(CSMSLScan.MassSpectrum.GetIntensities());
            scan.Intensities = intensity;
            scan.MsLevel     = GetMsLevel(argScanNo);

            double retentionTime = 0;

            _rawConnection.RTFromScanNum(argScanNo, ref retentionTime);
            scan.Time       = retentionTime;
            scan.ScanHeader = GetScanDescription(argScanNo);

            if (scan.MsLevel != 1)
            {
                for (int chNum = 0; chNum < scan.MZs.Length; chNum++)
                {
                    scan.MSPeaks.Add(new MSPeak(
                                         Convert.ToSingle(scan.MZs[chNum]),
                                         Convert.ToSingle(scan.Intensities[chNum])));
                }

                // Get parent information
                object value = null;
                _rawConnection.GetTrailerExtraValueForScanNum(argScanNo, "Master Scan Number:", ref value);
                scan.ParentScanNo = Convert.ToInt32(value);
                string ParentDesc = GetScanDescription(scan.ParentScanNo);

                //_rawConnection.GetPrecursorInfoFromScanNum(argScanNo, ref PrecursorInfo, ref PrecursorInfoSize);


                //scan.ParentMonoMW = Convert.ToSingle(PrecurorArray.);
                //scan.ParentMZ = Convert.ToSingle(PrecurorArray[1,0]);
                //scan.ParentCharge = Convert.ToInt32(PrecurorArray.nChargeState);
                scan.IsCIDScan = IsCIDScan(argScanNo);
                scan.IsFTScan  = IsFTScan(argScanNo);

                //Array.Clear(_transformResult, 0, _transformResult.Length);
                //Array.Clear(_cidPeaks, 0, _cidPeaks.Length);
                //Array.Clear(_cidMzs, 0, _cidMzs.Length);
                //Array.Clear(_cidIntensities, 0, _cidIntensities.Length);
                //Array.Clear(_parentRawMzs, 0, _parentRawMzs.Length);
                //Array.Clear(_parentRawIntensitys, 0, _parentRawIntensitys.Length);
            }
            else //MS Scan
            {
                do
                {
                    ThermoLabeledPeak        BasePeak     = FullLabeledPeak[0];
                    List <ThermoLabeledPeak> clusterPeaks = new List <ThermoLabeledPeak>();
                    List <int> RemoveIdx = new List <int>();
                    RemoveIdx.Add(0);
                    clusterPeaks.Add(BasePeak);
                    double Interval = 1 / (double)BasePeak.Charge;
                    double FirstMZ  = BasePeak.MZ;
                    for (int i = 1; i < FullLabeledPeak.Count; i++)
                    {
                        if (FullLabeledPeak[i].MZ - FirstMZ > Interval * 10)
                        {
                            break;
                        }
                        if ((FullLabeledPeak[i].MZ - (BasePeak.MZ + Interval)) < 0.1 && (FullLabeledPeak[i].MZ - (BasePeak.MZ + Interval)) >= 0 && clusterPeaks[0].Charge == FullLabeledPeak[i].Charge)
                        {
                            BasePeak = FullLabeledPeak[i];
                            clusterPeaks.Add(FullLabeledPeak[i]);
                            RemoveIdx.Add(i);
                        }
                    }
                    if (clusterPeaks.Count < 3)
                    {
                        FullLabeledPeak.RemoveAt(RemoveIdx[0]);
                    }
                    else
                    {
                        float  MostIntenseMZ        = 0.0f;
                        double MostIntenseIntneisty = 0;
                        double ClusterIntensity     = 0;
                        RemoveIdx.Reverse();
                        for (int i = 0; i < RemoveIdx.Count; i++)
                        {
                            if (FullLabeledPeak[RemoveIdx[i]].Intensity > MostIntenseIntneisty)
                            {
                                MostIntenseIntneisty = FullLabeledPeak[RemoveIdx[i]].Intensity;
                                MostIntenseMZ        = FullLabeledPeak[RemoveIdx[i]].MZ;
                            }
                            ClusterIntensity = ClusterIntensity + FullLabeledPeak[RemoveIdx[i]].Intensity;
                            FullLabeledPeak.RemoveAt(RemoveIdx[i]);
                        }
                        scan.MSPeaks.Add(new MSPeak(clusterPeaks[0].Mass, clusterPeaks[0].Intensity, clusterPeaks[0].Charge, clusterPeaks[0].MZ, clusterPeaks[0].SN, MostIntenseMZ, MostIntenseIntneisty, ClusterIntensity));
                    }
                } while (FullLabeledPeak.Count != 0);


                //Array.Clear(_transformResult, 0, _transformResult.Length);
                //Array.Clear(_cidPeaks, 0, _cidPeaks.Length);
                //Array.Clear(_cidMzs, 0, _cidMzs.Length);
                //Array.Clear(_cidIntensities, 0, _cidIntensities.Length);
            }
            return(scan);
        }