Esempio n. 1
0
        //将最终的数据写入文件中
        public void writeToAirdInfoFile()
        {
            jobInfo.log("Writing Index File", "Writing Index File");
            AirdInfo airdInfo = buildBasicInfo();
            JsonSerializerSettings jsonSetting = new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            };
            string airdInfoStr = JsonConvert.SerializeObject(airdInfo, jsonSetting);

            byte[] airdBytes = Encoding.Default.GetBytes(airdInfoStr);
            airdJsonStream.Write(airdBytes, 0, airdBytes.Length);
        }
Esempio n. 2
0
        /**
         * 使用直接的关键信息进行初始化
         *
         * @param airdPath      Aird文件路径
         * @param mzCompressor  mz压缩策略
         * @param intCompressor intensity压缩策略
         * @param mzPrecision   mz数字精度
         * @param airdType      aird类型
         * @throws ScanException 扫描异常
         */
        public BaseParser(String airdPath, Compressor mzCompressor, Compressor intCompressor, int mzPrecision, String airdType)
        {
            var indexFile = FileNameUtil.getIndexPathByAirdPath(airdPath);

            airdInfo = AirdScanUtil.loadAirdInfo(indexFile);
            try
            {
                airdFile = File.OpenRead(airdPath);
            }
            catch (FileNotFoundException e)
            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
                throw new Exception(ResultCodeEnum.AIRD_FILE_PARSE_ERROR.Message);
            }
            this.mzCompressor  = mzCompressor;
            this.intCompressor = intCompressor;
            this.mzPrecision   = mzPrecision;
            this.type          = airdType;
        }
Esempio n. 3
0
        public BaseParser(string indexPath)
        {
            airdInfo = AirdScanUtil.loadAirdInfo(indexPath);
            if (airdInfo == null)
            {
                throw new Exception(ResultCodeEnum.AIRD_INDEX_FILE_PARSE_ERROR.Message);
            }
            try
            {
                airdFile = File.OpenRead(FileNameUtil.getAirdPathByIndexPath(indexPath));
            }
            catch (FileNotFoundException e)
            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
                throw new Exception(ResultCodeEnum.AIRD_FILE_PARSE_ERROR.Message);
            }

            mzCompressor  = CompressUtil.getMzCompressor(airdInfo.compressors);
            intCompressor = CompressUtil.getIntCompressor(airdInfo.compressors);
            mzPrecision   = mzCompressor.precision;
            type          = airdInfo.type;
        }
Esempio n. 4
0
        protected AirdInfo buildBasicInfo()
        {
            AirdInfo airdInfo = new AirdInfo();
            List <DomainsCore.Aird.Software> softwares = new List <DomainsCore.Aird.Software>();
            List <ParentFile> parentFiles = new List <ParentFile>();

            //Basic Job Info
            airdInfo.airdPath       = jobInfo.airdFilePath;
            airdInfo.fileSize       = fileSize;
            airdInfo.createDate     = new DateTime();
            airdInfo.type           = jobInfo.type;
            airdInfo.totalScanCount = msd.run.spectrumList.size();
            airdInfo.creator        = jobInfo.jobParams.creator;
            airdInfo.activator      = activator;
            airdInfo.energy         = energy;
            airdInfo.rtUnit         = rtUnit;
            airdInfo.msType         = msType;
            airdInfo.polarity       = polarity;
            //Scan index and window range info
            airdInfo.rangeList = ranges;

            //Block index
            airdInfo.indexList = indexList;

            //Instrument Info
            List <Instrument> instruments = new List <Instrument>();

            foreach (InstrumentConfiguration ic in msd.instrumentConfigurationList)
            {
                Instrument instrument = new Instrument();
                //仪器设备信息
                if (jobInfo.format.Equals("WIFF"))
                {
                    instrument.manufacturer = "SCIEX";
                }
                if (jobInfo.format.Equals("RAW"))
                {
                    instrument.manufacturer = "THERMO";
                }

                //设备信息在不同的源文件格式中取法不同,有些是在instrumentConfigurationList中获取,有些是在paramGroups获取,因此出现了以下比较丑陋的写法
                if (ic.cvParams.Count != 0)
                {
                    foreach (CVParam cv in ic.cvParams)
                    {
                        featuresMap.Add(cv.name, cv.value);
                    }
                    instrument.model = ic.cvParams[0].name;
                }
                else if (msd.paramGroups.Count != 0)
                {
                    foreach (ParamGroup pg in msd.paramGroups)
                    {
                        if (pg.cvParams.Count != 0)
                        {
                            foreach (CVParam cv in pg.cvParams)
                            {
                                if (!featuresMap.ContainsKey(cv.name))
                                {
                                    featuresMap.Add(cv.name, cv.value.ToString());
                                }
                            }
                            instrument.model = pg.cvParams[0].name;
                        }
                    }
                }
                foreach (Component component in ic.componentList)
                {
                    switch (component.type)
                    {
                    case ComponentType.ComponentType_Analyzer:
                        foreach (CVParam cv in component.cvParams)
                        {
                            instrument.analyzer.Add(cv.name);
                        }
                        break;

                    case ComponentType.ComponentType_Source:
                        foreach (CVParam cv in component.cvParams)
                        {
                            instrument.source.Add(cv.name);
                        }
                        break;

                    case ComponentType.ComponentType_Detector:
                        foreach (CVParam cv in component.cvParams)
                        {
                            instrument.detector.Add(cv.name);
                        }
                        break;
                    }
                }
                instruments.Add(instrument);
            }
            airdInfo.instruments = instruments;

            //Software Info
            foreach (Software soft in msd.softwareList)
            {
                DomainsCore.Aird.Software software = new DomainsCore.Aird.Software();
                software.name    = soft.id;
                software.version = soft.version;
                softwares.Add(software);
            }
            DomainsCore.Aird.Software airdPro = new DomainsCore.Aird.Software();
            airdPro.name    = SoftwareInfo.NAME;
            airdPro.version = SoftwareInfo.VERSION;
            airdPro.type    = "DataFormatConversion";
            softwares.Add(airdPro);
            airdInfo.softwares = softwares;

            //Parent Files Info
            foreach (SourceFile sf in msd.fileDescription.sourceFiles)
            {
                ParentFile file = new ParentFile();
                file.name       = sf.name;
                file.location   = sf.location;
                file.formatType = sf.id;
                parentFiles.Add(file);
            }
            airdInfo.parentFiles = parentFiles;

            //Compressor Info
            List <Compressor> coms = new List <Compressor>();
            //mz compressor
            Compressor mzCompressor = new Compressor();

            if (jobInfo.jobParams.useStackZDPD())
            {
                mzCompressor.addMethod(Compressor.METHOD_STACK);
                mzCompressor.digit = jobInfo.jobParams.digit;
            }
            mzCompressor.addMethod(Compressor.METHOD_PFOR);
            mzCompressor.addMethod(Compressor.METHOD_ZLIB);
            mzCompressor.target    = Compressor.TARGET_MZ;
            mzCompressor.precision = (int)(Math.Ceiling(1 / jobInfo.jobParams.mzPrecision));
            coms.Add(mzCompressor);
            //intensity compressor
            Compressor intCompressor = new Compressor();

            if (jobInfo.jobParams.useStackZDPD())
            {
                intCompressor.addMethod(Compressor.METHOD_STACK);
                intCompressor.digit = jobInfo.jobParams.digit;
            }
            if (jobInfo.jobParams.log2)
            {
                intCompressor.addMethod(Compressor.METHOD_LOG10);
                intCompressor.addMethod(Compressor.METHOD_ZLIB);
            }
            else
            {
                intCompressor.addMethod(Compressor.METHOD_ZLIB);
            }

            intCompressor.target    = Compressor.TARGET_INTENSITY;
            intCompressor.precision = 10;  //intensity默认精确到小数点后1位

            coms.Add(intCompressor);
            airdInfo.compressors = coms;

            airdInfo.ignoreZeroIntensityPoint = jobInfo.jobParams.ignoreZeroIntensity;
            //Features Info
            featuresMap.Add(Features.raw_id, msd.id);
            featuresMap.Add(Features.ignore_zero_intensity, jobInfo.jobParams.ignoreZeroIntensity);
            featuresMap.Add(Features.source_file_format, jobInfo.format);
            featuresMap.Add(Features.byte_order, ByteOrder.LITTLE_ENDIAN);
            featuresMap.Add(Features.aird_algorithm, jobInfo.jobParams.getAirdAlgorithmStr());
            airdInfo.features    = FeaturesUtil.toString(featuresMap);
            airdInfo.version     = SoftwareInfo.VERSION;
            airdInfo.versionCode = SoftwareInfo.VERSION_CODE;
            return(airdInfo);
        }