Esempio n. 1
0
        private void ReadandDisplayScan(int argMSScan)
        {
    
            if (raw != null)
            {
                scan = raw.ReadScan(argMSScan);
                StringBuilder SB = new StringBuilder();
                SB.Append("Scan Num:" + scan.ScanNo + Environment.NewLine);
                SB.Append("Scan Time:" + scan.Time + Environment.NewLine);
                SB.Append("Scan header:" + scan.ScanHeader + Environment.NewLine);
                SB.Append("Scan range:" + scan.MinMZ + "~" + scan.MaxMZ + Environment.NewLine);
                SB.Append("Scan MS Level:" + scan.MsLevel + Environment.NewLine);
                SB.Append("Scan is FT Scan:" + scan.IsFTScan + Environment.NewLine);
                SB.Append("Scan is CID:" + scan.IsCIDScan + Environment.NewLine + Environment.NewLine);
                if (scan.MsLevel == 2)
                {
                    SB.Append("Parent Scan Num:" + scan.ParentScanNo + Environment.NewLine);
                    SB.Append("Precursor M/Z:" + scan.ParentMZ + Environment.NewLine);
                    SB.Append("Precursor Charge:" + scan.ParentCharge + Environment.NewLine);
                    SB.Append("Precursor mono mass:" + scan.ParentMonoMW + Environment.NewLine + Environment.NewLine);
                }
                if (scan.IsHCDScan)
                {
                    HCDInfo HCD = ((ThermoRawReader) raw).GetHCDInfo(argMSScan);
                    SB.Append("HCD Score:" + HCD.HCDScore.ToString("0.00")+Environment.NewLine);
                    SB.Append("HCD Glycan Type:" + HCD.GlycanType + Environment.NewLine);
                }
                SB.Append("MS Peaks:" + scan.MSPeaks.Count + Environment.NewLine);
                SB.Append("DeisotopeMZ\tPeak Intensity\tMost intense Mz\tMost intense int\t Cluster int"+Environment.NewLine);
                foreach (MSPeak peak in scan.MSPeaks)
                {
                    SB.Append(peak.DeisotopeMz + "\t\t" + peak.MonoIntensity + "\t\t" + peak.MostIntenseMass + "\t\t" + peak.MostIntenseIntensity + "\t\t" + peak.ClusterIntensity + Environment.NewLine);
                }

                SB.Append(Environment.NewLine + Environment.NewLine + "MZs:" + scan.MZs.Length + Environment.NewLine);
                for (int i = 0; i < scan.MZs.Length; i++)
                {
                    SB.Append("[" + i.ToString() + "]" + scan.MZs[i].ToString("0.0000") + "\t" + scan.Intensities[i].ToString("0.0000") + Environment.NewLine);
                }
                txtPeaks_CSMSL.Text = SB.ToString();
                ZedGraphDisplay(scan);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// No HCD info the return will be null
        /// </summary>
        /// <param name="argReader"></param>
        /// <param name="argScanNo"></param>
        /// <returns></returns>
        private static HCDInfo GetHCDInfo(GlypID.Readers.clsRawData argReader, int argScanNo)
        {
            if (!argReader.IsHCDScan(argScanNo))
            {
                return(null);
            }
            HCDInfo HCDinfo = null;
            double  _hcd_score;

            GlypID.enmGlycanType _gType;
            int ParentScan = argReader.GetParentScan(argScanNo);

            // Scorers and transforms
            GlypID.HCDScoring.clsHCDScoring       HCDScoring = new GlypID.HCDScoring.clsHCDScoring();
            GlypID.HornTransform.clsHornTransform Transform  = new GlypID.HornTransform.clsHornTransform();

            // mzs , intensities
            float[] hcd_mzs            = null;
            float[] hcd_intensities    = null;
            float[] parent_mzs         = null;
            float[] parent_intensities = null;

            // Peaks
            GlypID.Peaks.clsPeak[] parent_peaks;
            GlypID.Peaks.clsPeak[] hcd_peaks;

            // Peak Processors
            GlypID.Peaks.clsPeakProcessor hcdPeakProcessor    = new GlypID.Peaks.clsPeakProcessor();
            GlypID.Peaks.clsPeakProcessor parentPeakProcessor = new GlypID.Peaks.clsPeakProcessor();

            // Results
            GlypID.HCDScoring.clsHCDScoringScanResults[]   hcd_scoring_results;
            GlypID.HornTransform.clsHornTransformResults[] transform_results;

            // Params
            GlypID.Scoring.clsScoringParameters             scoring_parameters   = new GlypID.Scoring.clsScoringParameters();
            GlypID.HornTransform.clsHornTransformParameters transform_parameters = new GlypID.HornTransform.clsHornTransformParameters();
            scoring_parameters.MinNumPeaksToConsider = 2;
            scoring_parameters.PPMTolerance          = 10;
            scoring_parameters.UsePPM = true;

            // Init
            Transform.TransformParameters = transform_parameters;

            // Loading parent
            int    parent_scan  = argReader.GetParentScan(argScanNo);
            double parent_mz    = argReader.GetParentMz(argScanNo);
            int    scan_level   = argReader.GetMSLevel(argScanNo);
            int    parent_level = argReader.GetMSLevel(parent_scan);

            argReader.GetSpectrum(parent_scan, ref parent_mzs, ref parent_intensities);


            // Parent processing
            parent_peaks = new GlypID.Peaks.clsPeak[1];
            parentPeakProcessor.ProfileType = GlypID.enmProfileType.PROFILE;
            parentPeakProcessor.DiscoverPeaks(ref parent_mzs, ref parent_intensities, ref parent_peaks,
                                              Convert.ToSingle(transform_parameters.MinMZ), Convert.ToSingle(transform_parameters.MaxMZ), true);
            double bkg_intensity         = parentPeakProcessor.GetBackgroundIntensity(ref parent_intensities);
            double min_peptide_intensity = bkg_intensity * transform_parameters.PeptideMinBackgroundRatio;


            transform_results = new GlypID.HornTransform.clsHornTransformResults[1];
            bool found = Transform.FindPrecursorTransform(Convert.ToSingle(bkg_intensity), Convert.ToSingle(min_peptide_intensity), ref parent_mzs, ref parent_intensities, ref parent_peaks, Convert.ToSingle(parent_mz), ref transform_results);

            if (!found && (argReader.GetMonoChargeFromHeader(ParentScan) > 0))
            {
                found = true;
                double mono_mz = argReader.GetMonoMzFromHeader(ParentScan);
                if (mono_mz == 0)
                {
                    mono_mz = parent_mz;
                }

                short[] charges = new short[1];
                charges[0] = argReader.GetMonoChargeFromHeader(ParentScan);
                Transform.AllocateValuesToTransform(Convert.ToSingle(mono_mz), 0, ref charges, ref transform_results); // Change abundance value from 0 to parent_intensity if you wish
            }
            if (found && transform_results.Length == 1)
            {
                // Score HCD scan first
                argReader.GetSpectrum(argScanNo, ref hcd_mzs, ref hcd_intensities);
                double hcd_background_intensity = GlypID.Utils.GetAverage(ref hcd_intensities, ref hcd_mzs, Convert.ToSingle(scoring_parameters.MinHCDMz), Convert.ToSingle(scoring_parameters.MaxHCDMz));
                hcdPeakProcessor.SetPeakIntensityThreshold(hcd_background_intensity);
                hcd_peaks = new GlypID.Peaks.clsPeak[1];

                //Check Header
                string Header = argReader.GetScanDescription(argScanNo);
                hcdPeakProcessor.ProfileType = GlypID.enmProfileType.PROFILE;
                if (Header.Substring(Header.IndexOf("+") + 1).Trim().StartsWith("c"))
                {
                    hcdPeakProcessor.ProfileType = GlypID.enmProfileType.CENTROIDED;
                }

                hcdPeakProcessor.DiscoverPeaks(ref hcd_mzs, ref hcd_intensities, ref hcd_peaks, Convert.ToSingle
                                                   (scoring_parameters.MinHCDMz), Convert.ToSingle(scoring_parameters.MaxHCDMz), false);
                hcdPeakProcessor.InitializeUnprocessedData();

                hcd_scoring_results = new GlypID.HCDScoring.clsHCDScoringScanResults[1];

                HCDScoring.ScoringParameters = scoring_parameters;
                _hcd_score = HCDScoring.ScoreHCDSpectra(ref hcd_peaks, ref hcd_mzs, ref hcd_intensities, ref transform_results, ref hcd_scoring_results);
                _gType     = (GlypID.enmGlycanType)hcd_scoring_results[0].menm_glycan_type;

                enumGlycanType GType; //Convert from GlypID.enumGlycanType to MassLib.enumGlycanType;
                if (_gType == GlypID.enmGlycanType.CA)
                {
                    GType = enumGlycanType.CA;
                }
                else if (_gType == GlypID.enmGlycanType.CS)
                {
                    GType = enumGlycanType.CS;
                }
                else if (_gType == GlypID.enmGlycanType.HM)
                {
                    GType = enumGlycanType.HM;
                }
                else if (_gType == GlypID.enmGlycanType.HY)
                {
                    GType = enumGlycanType.HY;
                }
                else
                {
                    GType = enumGlycanType.NA;
                }

                HCDinfo = new HCDInfo(argScanNo, GType, _hcd_score);
            }

            return(HCDinfo);
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="args">
        /// Arg0: FilePath
        /// Arg1: FileType switch
        ///        raw
        ///        mzxml
        /// Arg2: Function switch
        ///        R:ReadScan
        ///        N:Number of Scan
        ///        H: Get HCD info
        ///        C: Checked if it is CID scan
        ///        S: Scan header Description
        ///        M: Get MS Level
        /// Arg3:
        ///      Switch R:  int scan number
        ///      Switch N:  none
        ///
        /// Arg4: PeakProcessorParameter  _singleToNoiseRatio
        /// Arg5: PeakProcessorParameter  _peakBackgroundRatio
        /// Arg6: TransformParameter  _peptideMinBackgroundRatio
        /// Arg7: TransformParameter _maxCharge
        /// </param>
        ///
        static int Main(string[] args)
        {
            string FunctionSwitch;// = args[2].ToLower();

            GlypID.Readers.clsRawData Raw;
            //Debug

            //End Debug

            try
            {
                do
                {
                    Console.WriteLine(
                        "@@\nR:ReadScan\n" +
                        "N:Number of Scan\n" +
                        "H: Get HCD info\n" +
                        "C: Checked if it is CID scan\n" +
                        "S: Scan header Description\n" +
                        "M: Get MS Level\n" +
                        "Q: Quit\n" +
                        "Please select function:");
                    FunctionSwitch = Console.In.ReadLine().ToLower().Substring(0, 1);

                    if (FunctionSwitch == "q")
                    {
                        return(0);
                    }
                    else
                    {
                        Console.WriteLine("Please input file location:");
                        string _fullFilePath = Console.In.ReadLine();
                        Console.WriteLine("FIle Type(r: Raw, x:mzXML)");
                        if (Console.In.ReadLine().ToLower().StartsWith("x"))
                        {
                            Raw = new GlypID.Readers.clsRawData(_fullFilePath, GlypID.Readers.FileType.MZXMLRAWDATA);
                        }
                        else
                        {
                            Raw = new GlypID.Readers.clsRawData(_fullFilePath, GlypID.Readers.FileType.FINNIGAN);
                        }

                        //PipeClient pipeClt = new PipeClient();
                        //pipeClt.Connect("\\\\.\\pipe\\GlypIDPipe");
                        if (FunctionSwitch == "r")//Read Scan
                        {
                            Console.WriteLine("Please input scan num:");
                            int ScanNo = Convert.ToInt32(Console.In.ReadLine());

                            Console.WriteLine("Please input Single to Noise ratio (default:3.0):");
                            double parsedResult        = 3.0;
                            double _singleToNoiseRatio = 3.0;
                            if (double.TryParse(Console.In.ReadLine(), out parsedResult))
                            {
                                _singleToNoiseRatio = parsedResult;
                            }

                            Console.WriteLine("Please input Peak background ratio (default:5.0):");
                            parsedResult = 5.0;
                            double _peakBackgroundRatio = 5.0;
                            if (double.TryParse(Console.In.ReadLine(), out parsedResult))
                            {
                                _peakBackgroundRatio = parsedResult;
                            }

                            Console.WriteLine("Please input Minimum background ratio (default:5.0):");
                            parsedResult = 5.0;
                            double _peptideMinBackgroundRatio = 5.0;
                            if (double.TryParse(Console.In.ReadLine(), out parsedResult))
                            {
                                _peptideMinBackgroundRatio = parsedResult;
                            }

                            Console.WriteLine("Please input Max charge (defatlt:10):");
                            short paredCharge = 10;
                            short _maxCharge  = 10;
                            if (short.TryParse(Console.In.ReadLine(), out paredCharge))
                            {
                                _maxCharge = paredCharge;
                            }


                            Console.WriteLine("Reading Scan");
                            MSScan scan        = GetScanFromFile(ScanNo, _singleToNoiseRatio, _peakBackgroundRatio, _peptideMinBackgroundRatio, _maxCharge, Raw);
                            string responseMsg = SendScanViaNamedPipe(scan);

                            //scan = null;
                            //if (pipeClt.Connected)
                            //{
                            //    while (!pipeClt.SendMessage(memStream.ToArray())) ;
                            //    Console.WriteLine("Named pipe sent");
                            //    pipeClt.Disconnect();
                            //}
                            //else
                            //{
                            //    throw new Exception("Named Pipe not found");
                            //}
                            Console.WriteLine("ANS:Read Scan: " + ScanNo + " finish;MSScan bytes-" + responseMsg);
                        }
                        else if (FunctionSwitch == "n") //Get total scans
                        {
                            Console.WriteLine("ANS:" + Raw.GetNumScans().ToString());
                        }
                        else if (FunctionSwitch == "h") //Check HCD
                        {
                            Console.WriteLine("Please input scan num:");
                            int     ScanNo  = Convert.ToInt32(Console.In.ReadLine());
                            HCDInfo HCDinfo = GetHCDInfo(Raw, ScanNo);
                            if (HCDinfo != null)
                            {
                                Console.WriteLine("ANS:" + HCDinfo.ScanNum.ToString() + ";" +
                                                  HCDinfo.GlycanType.ToString() + ";" +
                                                  HCDinfo.HCDScore.ToString());
                            }
                            else
                            {
                                Console.WriteLine("ANS:" + "false");
                            }
                        }
                        else if (FunctionSwitch == "c") //Check CID
                        {
                            Console.WriteLine("Please input scan num:");
                            int ScanNo = Convert.ToInt32(Console.In.ReadLine());
                            if (Raw.IsCIDScan(ScanNo) == true)
                            {
                                Console.WriteLine("ANS:" + "true");
                            }
                            else
                            {
                                Console.WriteLine("ANS:" + "false");
                            }
                        }
                        else if (FunctionSwitch == "s") //Check description
                        {
                            Console.WriteLine("Please input scan num:");
                            int    ScanNo      = Convert.ToInt32(Console.In.ReadLine());
                            string description = Raw.GetScanDescription(ScanNo);
                            Console.WriteLine("ANS:" + description);
                        }
                        else if (FunctionSwitch == "m")//Get MS Level
                        {
                            Console.WriteLine("Please input scan num:");
                            int ScanNo = Convert.ToInt32(Console.In.ReadLine());
                            Console.WriteLine("ANS:" + Raw.GetMSLevel(ScanNo));
                        }
                        else
                        {
                            Console.WriteLine("Function error");
                        }
                    }
                } while (true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(-1);
            }

            //if (args == null || args.Length == 0)
            //{
            //    Console.WriteLine("args is null"); // Check for null array
            //    return -1;
            //}

            //if (FunctionSwitch == "r" && args.Length != 8)
            //{
            //    Console.WriteLine("args is not enough"); // Check for null array
            //    return -1;
            //}
            //else
            //{


            //    string _fullFilePath = Console.In.ReadLine();

            //    Console.WriteLine("Init GlypID");
            //    if (args[1].ToLower() == "raw")
            //    {
            //        Raw = new GlypID.Readers.clsRawData(_fullFilePath, GlypID.Readers.FileType.FINNIGAN);
            //    }
            //    else
            //    {
            //        Raw = new GlypID.Readers.clsRawData(_fullFilePath, GlypID.Readers.FileType.MZXMLRAWDATA);
            //    }


            //    if (FunctionSwitch == "n") //Get Total scans
            //    {
            //        Console.WriteLine(Raw.GetNumScans().ToString());
            //        return Raw.GetNumScans();
            //    }
            //    else if (FunctionSwitch == "m")  //Get MS Level
            //    {
            //        int ScanNo = Convert.ToInt32(args[3]);
            //        return Raw.GetMSLevel(ScanNo);
            //    }
            //    else if (FunctionSwitch == "c") //IsCID Scan
            //    {
            //        int ScanNo = Convert.ToInt32(args[3]);
            //        if (Raw.IsCIDScan(ScanNo) == true)
            //        {
            //            return 1;
            //        }
            //        return 0;

            //    }
            //    else if (FunctionSwitch == "s") //Get Description
            //    {
            //        int ScanNo = Convert.ToInt32(args[3]);

            //        //Console.WriteLine("Get Description info");
            //        string description = Raw.GetScanDescription(ScanNo);
            //        Console.WriteLine(description);
            //        //System.Runtime.Serialization.IFormatter f = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
            //        //MemoryStream memStream = new MemoryStream();
            //        //f.Serialize(memStream, description);
            //        //PipeClient pipeClt = new PipeClient();
            //        //pipeClt.Connect("\\\\.\\pipe\\GlypIDPipe");
            //        //if (pipeClt.Connected)
            //        //{
            //        //    while (!pipeClt.SendMessage(memStream.ToArray())) ;
            //        //    Console.WriteLine("Named pipe sent");
            //        //}
            //        //else
            //        //{
            //        //    throw new Exception("Named Pipe not found");
            //        //}

            //        return 1;
            //    }
            //    else if (FunctionSwitch == "h")  //Get HCD
            //    {
            //        int ScanNo = Convert.ToInt32(args[3]);
            //        HCDInfo HCDinfo = GetHCDInfo(Raw, ScanNo);

            //        //Console.WriteLine("Get HCD info");
            //        //System.Runtime.Serialization.IFormatter f = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
            //        //PipeClient pipeClt = new PipeClient();
            //        //pipeClt.Connect("\\\\.\\pipe\\GlypIDPipeHCD");
            //        if (HCDinfo != null)
            //        {
            //            Console.WriteLine(HCDinfo.ScanNum.ToString() + ";" +
            //                              HCDinfo.GlycanType.ToString() + ";" +
            //                              HCDinfo.HCDScore.ToString());
            //            //MemoryStream memStream = new MemoryStream();
            //            //f.Serialize(memStream, HCDinfo);

            //            //if (pipeClt.Connected)
            //            //{
            //            //    while (!pipeClt.SendMessage(memStream.ToArray())) ;
            //            //    Console.WriteLine("Named pipe sent");
            //            //}
            //            //else
            //            //{
            //            //    throw new Exception("Named Pipe not found");
            //            //}
            //            return 1;
            //        }
            //        else
            //        {

            //            //if (pipeClt.Connected)
            //            //{

            //            //    while (!pipeClt.SendMessage(Encoding.ASCII.GetBytes("No HCD Info found"))) ;
            //            //    Console.WriteLine("Named pipe sent");
            //            //}
            //            //else
            //            //{
            //            //    throw new Exception("Named Pipe not found");
            //            //}
            //            return -1;
            //        }



            //    }
            //    else //ReadScan
            //    {
            //        int ScanNo = Convert.ToInt32(args[3]);
            //        double _singleToNoiseRatio = Convert.ToDouble(args[4]);
            //        double _peakBackgroundRatio = Convert.ToDouble(args[5]);
            //        double _peptideMinBackgroundRatio = Convert.ToDouble(args[6]);
            //        short _maxCharge = Convert.ToInt16(args[7]);


            //        Console.WriteLine("Read Scan");
            //        MSScan scan = GetScanFromFile(ScanNo, _singleToNoiseRatio, _peakBackgroundRatio, _peptideMinBackgroundRatio, _maxCharge);
            //        System.Runtime.Serialization.IFormatter f = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
            //        MemoryStream memStream = new MemoryStream();
            //        f.Serialize(memStream, scan);
            //        PipeClient pipeClt = new PipeClient();
            //        pipeClt.Connect("\\\\.\\pipe\\GlypIDPipe");
            //        if (pipeClt.Connected)
            //        {
            //            while (!pipeClt.SendMessage(memStream.ToArray())) ;
            //            Console.WriteLine("Named pipe sent");
            //        }
            //        else
            //        {
            //            throw new Exception("Named Pipe not found");
            //        }


            //        /*NamedPipeClientStream PipeClient = new NamedPipeClientStream(".", "ReadMSScan", PipeDirection.Out);
            //        PipeClient.Connect();


            //        f.Serialize(PipeClient, scan);
            //        PipeClient.Close();*/
            //        Console.WriteLine("Read Scan: " + args[3] + " finish");

            //    }
            //    //End Read Scan

            //    return 1;
            //}
        }
Esempio n. 4
0
        private void bgWorker_Process_DoWork(object sender, DoWorkEventArgs e)
        {
            AAMW = new AminoAcidMass();
            this.lblStatus.SafeBeginInvoke(new Action(() => lblStatus.Text = "Begin initial raw file"));
            Raw = new ThermoRawReader(_rawFile);
            this.lblStatus.SafeBeginInvoke(new Action(() => lblStatus.Text = "Initial raw file completed"));
            List <GlycanSequencing> lstGS = new List <GlycanSequencing>();

            if (_UseGlycanList)
            {
                _GlycanCompounds        = ReadGlycanListFromFile.ReadGlycanList(_glycanFile, false, _Human, false);
                _MassGlycanMapping      = new Dictionary <double, GlycanCompound>();
                _GlycanCompoundMassList = new List <float>();
                foreach (GlycanCompound G in _GlycanCompounds)
                {
                    if (!_MassGlycanMapping.ContainsKey(G.AVGMass))
                    {
                        _MassGlycanMapping.Add(G.AVGMass, G);
                        _GlycanCompoundMassList.Add((float)G.AVGMass);
                    }
                }
            }

            for (int i = 0; i < lstScans.Count; i++)
            {
                int ScanNo = lstScans[i];
                if (Raw.GetMsLevel(ScanNo) == 1)
                {
                    CurrentScan = ScanNo;
                    int ProcessReport = Convert.ToInt32((i / (float)lstScans.Count) * 100);
                    //Console.WriteLine("Scan:" + ScanNo.ToString()+"\t Peptide:" + Peptide + "  completed");
                    bgWorker_Process.ReportProgress(ProcessReport);
                    this.lblStatus.SafeBeginInvoke(new Action(() => lblStatus.Text = "MS scan pass:"******"Scan:" + ScanNo.ToString()+"\t Peptide:" + Peptide + "  completed");
                    bgWorker_Process.ReportProgress(ProcessReport);
                    this.lblStatus.SafeBeginInvoke(new Action(() => lblStatus.Text = "Not CID scan pass:"******"ms2")+4, _scan.ScanHeader.IndexOf("@") - _scan.ScanHeader.IndexOf("ms2")-3) + "hcd";
                    do
                    {
                        CheckScanNO++;
                        //    if (Raw.GlypIDReader.GetScanDescription(CheckScanNO).Contains(ScanHeader))
                        //    {
                        //        HCDScanNo = CheckScanNO;
                        //        HCD = new HCDInfo(Raw.GlypIDReader, HCDScanNo);
                        //        break;
                        //    }
                        if (Raw.GetHCDInfo(CheckScanNO) != null)
                        {
                            HCD = Raw.GetHCDInfo(CheckScanNO);
                            break;
                        }
                    } while (Raw.GetMsLevel(CheckScanNO) != 1); //Check Until hit Next Full MS

                    //CA: Complex Asialyated, CS:Complex Sialylated, HM:High mannose, HY:Hybrid and NA
                }
                if (HCD != null)
                {
                    Console.WriteLine("CID Scan No:" + ScanNo.ToString() + "\tHCD Scan No:" + HCDScanNo.ToString() + "\tGlycanType:" + HCD.GlycanType.ToString());
                }

                this.lblStatus.SafeBeginInvoke(new Action(() => lblStatus.Text = "Sequencing:" + ScanNo.ToString()));
                foreach (string Peptide in _Peptides)
                {
                    float PeptideMass = AAMW.GetMonoMW(Peptide, true);
                    for (int j = PrecursorCharge - 1; j <= PrecursorCharge; j++)
                    {
                        int Y1ChargeSt = j;
                        if (j == 0)
                        {
                            continue;
                        }
                        float PredictedY1 = 0.0f;
                        PredictedY1 = (float)(PeptideMass + GlycanMass.GetGlycanAVGMass(Glycan.Type.HexNAc) + COL.MassLib.Atoms.ProtonMass * Y1ChargeSt) / Y1ChargeSt;
                        GlycanSequencing GS = null;
                        if (_UseGlycanList)
                        {
                            float GlycanMonoMass = (_scan.ParentMZ - Atoms.ProtonMass) * _scan.ParentCharge - AAMW.GetAVGMonoMW(Peptide, true);
                            float PrecursorMono  = _scan.ParentMonoMW;
                            //if (_scan.ParentAVGMonoMW != 0.0)
                            //{
                            //    GlycanMonoMass = _scan.ParentAVGMonoMW - PeptideMass + (Atoms.HydrogenAVGMass * 2 + Atoms.OxygenAVGMass);
                            //    PrecursorMono = _scan.ParentAVGMonoMW;
                            //}
                            //else
                            //{
                            //    GlycanMonoMass = (_scan.ParentMZ - Atoms.ProtonMass) * _scan.ParentCharge - PeptideMass + (Atoms.HydrogenAVGMass * 2 + Atoms.OxygenAVGMass);
                            //    PrecursorMono = _scan.ParentMonoMW;
                            //}

                            List <GlycanCompound> ClosedGlycans = new List <GlycanCompound>();
                            foreach (float gMass in _GlycanCompoundMassList)
                            {
                                if (Math.Abs(gMass - GlycanMonoMass) < 100.0f)
                                {
                                    ClosedGlycans.Add(_GlycanCompounds[MassUtility.GetClosestMassIdx(_GlycanCompoundMassList, gMass)]);
                                }
                            }

                            //if (HCD != null)
                            //{
                            //    if ((HCD.GlycanType == GlypID.enmGlycanType.CA && ClosedGlycan.NoOfSia>0) ||
                            //         (HCD.GlycanType == GlypID.enmGlycanType.HM && (ClosedGlycan.NoOfSia!=0||ClosedGlycan.NoOfHexNAc!=2 || ClosedGlycan.NoOfDeHex!=0) ) ||
                            //         (HCD.GlycanType == GlypID.enmGlycanType.CS && ClosedGlycan.NoOfSia==0))
                            //    {
                            //        continue;
                            //    }
                            //}
                            //if (Math.Abs(ClosedGlycan.AVGMass - GlycanMonoMass) <= _MSMSTol)
                            foreach (GlycanCompound ClosedGlycan in ClosedGlycans)
                            {
                                if (_Human) //NeuAc
                                {
                                    int NoOfSia   = ClosedGlycan.NoOfSia;
                                    int NoOfDeHex = ClosedGlycan.NoOfDeHex;
                                    if (HCD != null && HCD.GlycanType == COL.MassLib.enumGlycanType.CA && ClosedGlycan.NoOfSia > 0)
                                    {
                                        NoOfDeHex = NoOfDeHex + NoOfSia * 2;
                                        NoOfSia   = 0;
                                    }
                                    GS = new GlycanSequencing(_scan, Peptide, true, Y1ChargeSt, ClosedGlycan.NoOfHex, ClosedGlycan.NoOfHexNAc, NoOfDeHex, NoOfSia, 0, @"d:\tmp", _NGlycan, _MSMSTol, _PrecursorTol);
                                }
                                else //NeuGc
                                {
                                    GS = new GlycanSequencing(_scan, Peptide, true, Y1ChargeSt, ClosedGlycan.NoOfHex, ClosedGlycan.NoOfHexNAc, ClosedGlycan.NoOfDeHex, 0, ClosedGlycan.NoOfSia, @"d:\tmp", _NGlycan, _MSMSTol, _PrecursorTol);
                                }
                                GS.NumbersOfPeaksForSequencing = 140;
                                GS.UseAVGMass        = _AverageMass;
                                GS.CreatePrecursotMZ = true;
                                if (!_CompletedOnly)
                                {
                                    GS.RewardForCompleteStructure = 0.0f;
                                }
                                if (HCD != null)
                                {
                                    GS.GlycanType = HCD.GlycanType;
                                }
                                GS.StartSequencing();
                                if (_CompletedOnly && GS.FullSequencedStructures.Count == 0)
                                {
                                    continue;
                                }
                                lstGS.Add(GS);
                                CurrentScan    = ScanNo;
                                CurrentPeptide = GS.PeptideSeq;
                                int ProcessReport = Convert.ToInt32((i / (float)lstScans.Count) * 100);
                                //Console.WriteLine("Scan:" + ScanNo.ToString()+"\t Peptide:" + Peptide + "  completed");
                                bgWorker_Process.ReportProgress(ProcessReport);
                            }
                        }
                        else // no list
                        {
                            if (_Human) //NeuAc
                            {
                                if (HCD != null)
                                {
                                    //CA: Complex Asialyated, CS:Complex Sialylated, HM:High mannose, HY:Hybrid and NA
                                    if (HCD.GlycanType == enumGlycanType.CA)
                                    {
                                        GS = new GlycanSequencing(_scan, Peptide, true, Y1ChargeSt, _NoHex, _NoHexNAc, _NoDeHex, 0, 0, @"d:\tmp", _NGlycan, _MSMSTol, _PrecursorTol);
                                    }
                                    else if (HCD.GlycanType == enumGlycanType.HM)
                                    {
                                        GS = new GlycanSequencing(_scan, Peptide, true, Y1ChargeSt, _NoHex, 2, 0, 0, 0, @"d:\tmp", _NGlycan, _MSMSTol, _PrecursorTol);
                                    }
                                    else
                                    {
                                        GS = new GlycanSequencing(_scan, Peptide, true, Y1ChargeSt, _NoHex, _NoHexNAc, _NoDeHex, _NoSia, 0, @"d:\tmp", _NGlycan, _MSMSTol, _PrecursorTol);
                                    }
                                }
                                else
                                {
                                    GS = new GlycanSequencing(_scan, Peptide, true, Y1ChargeSt, _NoHex, _NoHexNAc, _NoDeHex, _NoSia, 0, @"d:\tmp", _NGlycan, _MSMSTol, _PrecursorTol);
                                }
                            }
                            else //NeuGc
                            {
                                if (HCD != null)
                                {
                                    //CA: Complex Asialyated, CS:Complex Sialylated, HM:High mannose, HY:Hybrid and NA
                                    if (HCD.GlycanType == enumGlycanType.CA)
                                    {
                                        GS = new GlycanSequencing(_scan, Peptide, true, Y1ChargeSt, _NoHex, _NoHexNAc, _NoDeHex, 0, 0, @"d:\tmp", _NGlycan, _MSMSTol, _PrecursorTol);
                                    }
                                    else if (HCD.GlycanType == enumGlycanType.HM)
                                    {
                                        GS = new GlycanSequencing(_scan, Peptide, true, Y1ChargeSt, _NoHex, 2, 0, 0, 0, @"d:\tmp", _NGlycan, _MSMSTol, _PrecursorTol);
                                    }
                                    else
                                    {
                                        GS = new GlycanSequencing(_scan, Peptide, true, Y1ChargeSt, _NoHex, _NoHexNAc, _NoDeHex, 0, _NoSia, @"d:\tmp", _NGlycan, _MSMSTol, _PrecursorTol);
                                    }
                                }
                                else
                                {
                                    GS = new GlycanSequencing(_scan, Peptide, true, Y1ChargeSt, _NoHex, _NoHexNAc, _NoDeHex, 0, _NoSia, @"d:\tmp", _NGlycan, _MSMSTol, _PrecursorTol);
                                }
                            }
                            GS.NumbersOfPeaksForSequencing = 140;
                            GS.UseAVGMass        = _AverageMass;
                            GS.CreatePrecursotMZ = true;
                            if (!_CompletedOnly)
                            {
                                GS.RewardForCompleteStructure = 0.0f;
                            }
                            if (HCD != null)
                            {
                                GS.GlycanType = HCD.GlycanType;
                            }
                            GS.StartSequencing();
                            if (_CompletedOnly && GS.FullSequencedStructures.Count == 0)
                            {
                                continue;
                            }
                            lstGS.Add(GS);
                            CurrentScan    = ScanNo;
                            CurrentPeptide = GS.PeptideSeq;
                            int ProcessReport = Convert.ToInt32((i / (float)lstScans.Count) * 100);
                            //Console.WriteLine("Scan:" + ScanNo.ToString()+"\t Peptide:" + Peptide + "  completed");
                            bgWorker_Process.ReportProgress(ProcessReport);
                        }
                    } //Foreach charge
                }     //Foreach peptide
                if (lstGS.Count > 0)
                {
                    GenerateReportBody(lstGS);
                }
            }//Foreach Scan
        }