Exemple #1
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;
            //}
        }