Exemplo n.º 1
0
        private ParameterModel SaveControlToModel()
        {
            ParameterModel model = new ParameterModel();

            model.GetType().GetProperty("MS_PAT").SetValue(model, 0.5, null);
            model.GetType().GetProperty("MS_IPMD").SetValue(model, 10.0, null);
            model.GetType().GetProperty("MS_IPACO").SetValue(model, 5, null);
            model.GetType().GetProperty("MS_IPMDO").SetValue(model, 20, null);
            model.GetType().GetProperty("MS_IPMDOM").SetValue(model, 30.0, null);
            model.GetType().GetProperty("MS_IPAD").SetValue(model, 50, null);
            model.GetType().GetProperty("MS_IPADO").SetValue(model, 20, null);
            model.GetType().GetProperty("MS_IPADOM").SetValue(model, 100, null);
            model.GetType().GetProperty("MS_WINDOW").SetValue(model, 10, null);

            model.GetType().GetProperty("MS2_FAT").SetValue(model, 0.5, null);
            model.GetType().GetProperty("MS2_IPMD").SetValue(model, 10.0, null);
            model.GetType().GetProperty("MS2_IPACO").SetValue(model, 5, null);
            model.GetType().GetProperty("MS2_IPMDO").SetValue(model, 20, null);
            model.GetType().GetProperty("MS2_IPMDOM").SetValue(model, 30.0, null);
            model.GetType().GetProperty("MS2_IPAD").SetValue(model, 50, null);
            model.GetType().GetProperty("MS2_IPADO").SetValue(model, 20, null);
            model.GetType().GetProperty("MS2_IPADOM").SetValue(model, 100, null);
            model.GetType().GetProperty("MS2_PMFS").SetValue(model, 5.0, null);
            model.GetType().GetProperty("MS2_PTMS").SetValue(model, 1, null);


            model.MS2_SA = 1;

            return(model);
        }
Exemplo n.º 2
0
        private void OutputFile(List <MatchedData> lstMatchedData)
        {
            FileProcess filePro = new FileProcess();

            //Parameter Output
            string         sParameterFileName = System.IO.Path.Combine(new string[] { FolderName, "output" + ".bin" });
            ParameterModel model = SaveControlToModel();

            filePro.Serializer <ParameterModel>(model, sParameterFileName);

            if (lstMatchedData.Count == 0)
            {
                return;
            }

            //Excel Output
            string sXlsName = System.IO.Path.Combine(new string[] { FolderName, "output" + ".xls" });

            filePro.ExcelOut(lstMatchedData, sXlsName);
        }
Exemplo n.º 3
0
        private List <MatchedData> GetMatchedData(XmlReader xmlReader)
        {
            List <MassPoint>   lstMassPoint   = new List <MassPoint>();
            List <MatchedData> lstMatchedData = new List <MatchedData>();
            List <MatchedData> lstTemp        = null;
            MassScan           scanMS         = new MassScan();

            PeptideModResBLL peModResBLL = new PeptideModResBLL(DBName);
            ParameterModel   model       = this.SaveControlToModel();

            peModResBLL.ParameterModel = model;

            bool bSingle    = false;
            int  iScanCount = 0;
            int  currentCnt = 0;
            int  allCnt     = (int)99998;
            int  avgCnt     = 0;
            int  surplusCnt = 0;

            if (allCnt >= 90)
            {
                avgCnt = allCnt / 90;
            }
            else
            {
                avgCnt     = (int)Math.Round(90.0 / allCnt, MidpointRounding.AwayFromZero);
                surplusCnt = (int)Math.Round((avgCnt - 90.0 / allCnt) * allCnt);
            }

            while (xmlReader.Read())
            {
                if (xmlReader.Name == "sha1")
                {
                    break;
                }

                if (xmlReader.NodeType != XmlNodeType.Element)
                {
                    continue;
                }

                if (xmlReader.Name == "msRun")
                {
                    xmlReader.MoveToAttribute("scanCount");
                    iScanCount = int.Parse(xmlReader.Value);

                    if (allCnt > iScanCount)
                    {
                        allCnt = iScanCount;

                        if (allCnt >= 90)
                        {
                            avgCnt = allCnt / 90;
                        }
                        else
                        {
                            avgCnt     = (int)Math.Round(90.0 / allCnt, MidpointRounding.AwayFromZero);
                            surplusCnt = (int)Math.Round((avgCnt - 90.0 / allCnt) * allCnt);
                        }
                    }

                    if (iScanCount == 1)
                    {
                        bSingle = true;
                    }
                }

                if (xmlReader.Name == "scan")
                {
                    if (!xmlReader.HasAttributes)
                    {
                        continue;
                    }

                    //判断 是MS 还是MS2
                    xmlReader.MoveToAttribute("msLevel");

                    if ("1".Equals(xmlReader.Value))
                    {
                        xmlReader.MoveToAttribute("num");
                        scanMS.Index = UInt32.Parse(xmlReader.Value);

                        xmlReader.MoveToAttribute("msLevel");
                        scanMS.MsLevel = UInt32.Parse(xmlReader.Value);

                        xmlReader.MoveToAttribute("peaksCount");
                        scanMS.PeaksCount = UInt32.Parse(xmlReader.Value);

                        xmlReader.MoveToAttribute("polarity");
                        scanMS.Polarity = xmlReader.Value == "+" ? true : false;

                        xmlReader.MoveToAttribute("basePeakIntensity");
                        scanMS.BasePeakIntensity = double.Parse(xmlReader.Value);

                        while (xmlReader.Read())
                        {
                            if (xmlReader.Name == "peaks")
                            {
                                scanMS.IsPeaks = true;
                                scanMS.Peaks   = xmlReader.ReadInnerXml();
                                lstMassPoint   = Base64Convert.CalcMz(scanMS.Peaks, scanMS.PeaksCount);
                                break;
                            }
                        }
                    }
                    else if ("2".Equals(xmlReader.Value))
                    {
                        //读取属性
                        MassScan scanMS2 = new MassScan();

                        xmlReader.MoveToAttribute("num");
                        scanMS2.Index = UInt32.Parse(xmlReader.Value);

                        xmlReader.MoveToAttribute("msLevel");
                        scanMS2.MsLevel = UInt32.Parse(xmlReader.Value);

                        xmlReader.MoveToAttribute("peaksCount");
                        scanMS2.PeaksCount = UInt32.Parse(xmlReader.Value);

                        xmlReader.MoveToAttribute("polarity");
                        scanMS2.Polarity = xmlReader.Value == "+" ? true : false;

                        xmlReader.MoveToAttribute("basePeakIntensity");
                        scanMS2.BasePeakIntensity = double.Parse(xmlReader.Value);

                        while (xmlReader.Read())
                        {
                            if (xmlReader.NodeType != XmlNodeType.Element)
                            {
                                continue;
                            }

                            if (xmlReader.Name == "precursorMz")
                            {
                                xmlReader.MoveToAttribute("activationMethod");
                                scanMS2.ScanType = xmlReader.Value;
                                xmlReader.MoveToElement();
                                scanMS2.PrecursorMz = float.Parse(xmlReader.ReadInnerXml());
                            }
                            if (xmlReader.Name == "peaks")
                            {
                                scanMS2.Peaks = xmlReader.ReadInnerXml();
                                break;
                            }
                        }

                        if (bSingle == true)
                        {
                            if (scanMS2 == null)
                            {
                                return(null);
                            }

                            lstTemp = peModResBLL.getMSMatchs(scanMS2);

                            if (lstTemp != null && lstTemp.Count != 0)
                            {
                                lstMatchedData.AddRange(lstTemp);
                            }


                            return(lstMatchedData);
                        }

                        if (scanMS.IsPeaks == true)
                        {
                            if (scanMS2.Index >= 1 && scanMS2.Index <= 99999)
                            {
                                lstTemp = peModResBLL.getMSMatchs(scanMS, scanMS2);

                                if (lstTemp != null && lstTemp.Count != 0)
                                {
                                    lstMatchedData.AddRange(lstTemp);
                                }

                                if (allCnt <= 0)
                                {
                                }
                                else if (allCnt >= 90)
                                {
                                    currentCnt++;
                                }
                                else
                                {
                                    currentCnt++;
                                }
                            }
                        }
                    }
                    else
                    {
                        continue;
                    }
                }
            }

            return(lstMatchedData);
        }