예제 #1
0
        public HCDInfo GetHCDInfo(int argScanNum)
        {
            HCDScoring Scoring = new HCDScoring();
            MSScan     scan    = ReadScan(argScanNum);

            double         HCDScore = Scoring.CalculateHCDScore(scan.MSPeaks);
            enumGlycanType GType    = Scoring.DetermineGlycanType(scan.MSPeaks);
            HCDInfo        HInfo    = new HCDInfo(argScanNum, GType, HCDScore);

            return(HInfo);
        }
예제 #2
0
        public HCDInfo GetHCDInfo(int argScanNum)
        {
            _usagecountter++;
            if (_usagecountter == 100)
            {
                GlypIDReader.Close();
                GlypIDReader.Start();
                _usagecountter = 1;
            }
            GlypIDReader.StandardInput.WriteLine("h");
            GlypIDReader.StandardInput.WriteLine(_fullFilePath);
            GlypIDReader.StandardInput.WriteLine(_fileType);
            GlypIDReader.StandardInput.WriteLine(argScanNum.ToString());
            string output = "";

            do
            {
                output = GlypIDReader.StandardOutput.ReadLine();
            } while (!output.StartsWith("ANS:"));
            Console.WriteLine(output);
            output = output.Substring(4);
            if (output == "false")
            {
                return(null);
            }
            string HCDString = output;


            int            ScanNum = Convert.ToInt32(HCDString.Split(';')[0]);
            string         StrType = HCDString.Split(';')[1];
            double         Score   = Convert.ToDouble(HCDString.Split(';')[2]);
            enumGlycanType GType   = enumGlycanType.NA;

            //     CA = 1, CS, HM, HY, NA
            if (StrType == "CA")
            {
                GType = enumGlycanType.CA;
            }
            else if (StrType == "CS")
            {
                GType = enumGlycanType.CS;
            }
            else if (StrType == "HM")
            {
                GType = enumGlycanType.HM;
            }
            else if (StrType == "HY")
            {
                GType = enumGlycanType.HY;
            }

            return(new HCDInfo(ScanNum, GType, Score));
        }
예제 #3
0
        public HCDInfo HCDInfo()
        {
            string  HCDString    = "";
            Process GlypIDReader = new Process();

            GlypIDReader.StartInfo.FileName  = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\GlypIDWrapper.exe";
            GlypIDReader.StartInfo.Arguments = "\"" + _FullRawPath + "\" " + _RawType + " H " + _ScanNum.ToString();
            GlypIDReader.StartInfo.RedirectStandardOutput = true;
            GlypIDReader.StartInfo.RedirectStandardError  = true;
            GlypIDReader.StartInfo.UseShellExecute        = false;
            GlypIDReader.StartInfo.CreateNoWindow         = true;
            GlypIDReader.OutputDataReceived += new DataReceivedEventHandler(
                (s, e) =>
            {
                HCDString += e.Data + "\n";
            }
                );
            GlypIDReader.Start();
            GlypIDReader.BeginOutputReadLine();
            GlypIDReader.WaitForExit();

            _ExitCode = GlypIDReader.ExitCode;
            if (_ExitCode == -1)
            {
                return(null);
            }

            HCDString = HCDString.Split('\n')[1];

            int            ScanNum = Convert.ToInt32(HCDString.Split(';')[0]);
            string         StrType = HCDString.Split(';')[1];
            double         Score   = Convert.ToDouble(HCDString.Split(';')[2]);
            enumGlycanType GType   = enumGlycanType.NA;

            //     CA = 1, CS, HM, HY, NA
            if (StrType == "CA")
            {
                GType = enumGlycanType.CA;
            }
            else if (StrType == "CS")
            {
                GType = enumGlycanType.CS;
            }
            else if (StrType == "HM")
            {
                GType = enumGlycanType.HM;
            }
            else if (StrType == "HY")
            {
                GType = enumGlycanType.HY;
            }



            return(new HCDInfo(ScanNum, GType, Score));

            //autoResetEvt = new AutoResetEvent(false);

            //Thread WrapperThread = new Thread(StartWrapper);

            //WrapperThread.Start();
            //WrapperThread.Join();
            //autoResetEvt.WaitOne();

            //HCDInfo hcdinfo = null;

            //if (_ExitCode==1)
            //{
            //    System.Runtime.Serialization.IFormatter f = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
            //    System.IO.MemoryStream memStream = new System.IO.MemoryStream(RecivedScan);
            //    hcdinfo = (HCDInfo)f.Deserialize(memStream);
            //}

            //return hcdinfo;
        }
예제 #4
0
        public enumGlycanType DetermineGlycanType(List <MSPeak> argPeaks)
        {
            enumGlycanType GType = enumGlycanType.NA;
            // Function that attempts to categorize the glycan type by calculating cross correlation

            //First find peaks and get p value
            int    num_hcd_present = 0;
            double hcd_score       = 0;
            double del_mz_bin      = 0.015;
            double del_mz_range    = mdbl_max_mz - mdbl_min_mz;
            double p       = (2 * del_mz_bin) / del_mz_range;
            double p_value = 0;

            double[]   mzs               = new double[argPeaks.Count];
            double[]   intensities       = new double[argPeaks.Count];
            List <int> mint_peak_indices = new List <int>();

            for (int i = 0; i < argPeaks.Count; i++)
            {
                mzs[i]         = argPeaks[i].MonoisotopicMZ;
                intensities[i] = argPeaks[i].MonoIntensity;
            }
            float[] obs_intensities = new float[7];
            double  maxintensity    = 0;

            for (int j = 0; j < 7; j++)
            {
                obs_intensities[j] = 0;
            }
            mint_peak_indices.Clear();



            for (int j = 0; j < 7; j++)
            {
                double this_mz   = marr_theoretical_peaks[j];
                int    ClosedIdx = MassUtility.GetClosestMassIdx(argPeaks, Convert.ToSingle(mzs[j]));

                if (Math.Abs(mzs[ClosedIdx] - this_mz) < del_mz_bin)
                {
                    if (intensities[ClosedIdx] > obs_intensities[j])     //Anoop jan 2011, make sure you get teh highest intensity
                    {
                        num_hcd_present++;
                        mint_peak_indices.Add(ClosedIdx);
                        obs_intensities[j] = (float)intensities[ClosedIdx];
                        if (intensities[ClosedIdx] > maxintensity)
                        {
                            maxintensity = intensities[ClosedIdx];
                        }
                    }
                }
            }
            // Normalizing
            for (int j = 0; j < 7; j++)
            {
                obs_intensities[j] = (float)(obs_intensities[j] / maxintensity);
            }

            if (num_hcd_present >= mint_min_number_peaks)
            {
                for (int i = 0; i < mint_peak_indices.Count; i++)
                {
                    identified_peak_indices.Add(mint_peak_indices[i]);
                }

                // Start calculating p value
                long N_factorial = Factorial(7);

                if (num_hcd_present > 7)
                {
                    num_hcd_present = 7;
                }

                for (int x = num_hcd_present; x <= 7; x++)
                {
                    long   x_factorial   = Factorial(x);
                    long   N_x_factorial = Factorial(7 - x);
                    double N_choose_x    = (double)(N_factorial / (x_factorial * N_x_factorial));
                    double pX            = N_choose_x * Math.Pow(p, x) * Math.Pow(1 - p, 7 - x);
                    p_value += pX;
                }

                //Now do a correlation with each class
                float corr_HM     = 0;
                float corr_CA     = 0;
                float corr_CS     = 0;
                float corr_Hybrid = 0;
                float max_corr    = 0;

                //Anoop Jan 2011, performing the glycan type detection in two stages,
                //if NeuAc peak  (or its water equivalent) is present, a distinction between hybrid and sialylated structures is made
                // else only look for high mannose and complex_asialylated
                if ((obs_intensities[4] > 0) || (obs_intensities[3] > 0))
                {
                    corr_CS     = Correlation(obs_intensities, marr_theoretical_cs, 0);
                    corr_Hybrid = Correlation(obs_intensities, marr_theoretical_hybrid, 0);
                    corr_HM     = 0;
                    corr_CA     = 0;
                }
                else
                {
                    corr_CS     = 0;
                    corr_Hybrid = 0;
                    corr_HM     = Correlation(obs_intensities, marr_theoretical_hm, 0);
                    corr_CA     = Correlation(obs_intensities, marr_theoretical_ca, 0);
                }


                max_corr = Math.Max(Math.Max(Math.Max(corr_HM, corr_CA), corr_CS), corr_Hybrid);

                if (max_corr == corr_HM)
                {
                    GType = enumGlycanType.HM;
                }
                if (max_corr == corr_CA)
                {
                    GType = enumGlycanType.CA;
                }
                if (max_corr == corr_CS)
                {
                    GType = enumGlycanType.CS;
                }
                if (max_corr == corr_Hybrid)
                {
                    GType = enumGlycanType.HY;
                }
            }
            else
            {
                p_value = 1;
                GType   = enumGlycanType.NA;
            }

            return(GType);
        }
예제 #5
0
 public HCDInfo(int argScanNum, enumGlycanType argGType, double argHCDScore)
 {
     _scanNum  = argScanNum;
     _type     = argGType;
     _hcdscore = argHCDScore;
 }
예제 #6
0
파일: HCDInfo.cs 프로젝트: chpaul/COL_Lib
 public HCDInfo(int argScanNum, enumGlycanType argGType, double argHCDScore)
 {
     _scanNum = argScanNum;
     _type = argGType;
     _hcdscore = argHCDScore;
 }