Beispiel #1
0
        public void compress(List <Spectrum> spectrumGroup, TempScanSZDPD ts)
        {
            List <int[]> mzListGroup = new List <int[]>();
            //Intensity数组会直接合并为一个数组
            List <float> intListAllGroup = new List <float>();

            for (int i = 0; i < spectrumGroup.Count; i++)
            {
                BinaryDataDouble mzData        = spectrumGroup[i].getMZArray().data;
                BinaryDataDouble intData       = spectrumGroup[i].getIntensityArray().data;
                List <int>       mzList        = new List <int>();
                List <float>     intensityList = new List <float>();
                var   dataCount = mzData.Count;
                int[] mzArray   = new int[dataCount];
                int   j         = 0;
                for (int t = 0; t < mzData.Count; t++)
                {
                    if (jobInfo.jobParams.ignoreZeroIntensity && intData[t] == 0)
                    {
                        continue;
                    }

                    int mz = Convert.ToInt32(mzData[t] * mzPrecision);
                    mzArray[j] = mz;

                    if (jobInfo.jobParams.log2)
                    {
                        intensityList.Add(Convert.ToSingle(Math.Round(Math.Log(intData[t]) / log2, 3))); //取log10并且精确到小数点后3位
                    }
                    else
                    {
                        intensityList.Add(Convert.ToSingle(Math.Round(intData[t], 1))); //精确到小数点后一位
                    }
                    j++;
                }
                //空光谱的情况下会填充一个mz=0,intensity=0的点
                if (j == 0)
                {
                    mzListGroup.Add(new int[] { 0 });
                    intensityList.Add(0);
                }
                else
                {
                    int[] mzSubArray = new int[j];
                    Array.Copy(mzArray, mzSubArray, j);
                    mzListGroup.Add(mzSubArray);
                }
                //说明是一帧空光谱,那么直接在Aird文件中抹除这一帧的信息
                intListAllGroup.AddRange(intensityList);
            }

            Layers layers = StackCompressUtil.stackEncode(mzListGroup, mzListGroup.Count == Math.Pow(2, jobInfo.jobParams.digit));

            // List<int[]> temp = StackCompressUtil.stackDecode(layers);
            //使用SZDPD对mz进行压缩
            ts.mzArrayBytes  = layers.mzArray;
            ts.tagArrayBytes = layers.tagArray;
            ts.intArrayBytes = CompressUtil.zlibEncoder(intListAllGroup.ToArray());
        }
Beispiel #2
0
        //注意:本函数会操作startPosition这个全局变量
        public void addToIndex(BlockIndex index, object tempScan)
        {
            if (jobInfo.jobParams.useStackZDPD())
            {
                TempScanSZDPD ts = (TempScanSZDPD)tempScan;

                index.nums.AddRange(ts.nums);
                index.rts.AddRange(ts.rts);
                index.tics.AddRange(ts.tics);
                if (jobInfo.jobParams.includeCV)
                {
                    index.cvList.AddRange(ts.cvs);
                }
                index.mzs.Add(ts.mzArrayBytes.Length);
                index.ints.Add(ts.intArrayBytes.Length);
                index.tags.Add(ts.tagArrayBytes.Length);
                startPosition = startPosition + ts.mzArrayBytes.Length + ts.tagArrayBytes.Length + ts.intArrayBytes.Length;
                airdStream.Write(ts.mzArrayBytes, 0, ts.mzArrayBytes.Length);
                airdStream.Write(ts.tagArrayBytes, 0, ts.tagArrayBytes.Length);
                airdStream.Write(ts.intArrayBytes, 0, ts.intArrayBytes.Length);
            }
            else
            {
                TempScan ts = (TempScan)tempScan;

                index.nums.Add(ts.num);
                index.rts.Add(ts.rt);
                index.tics.Add(ts.tic);
                if (jobInfo.jobParams.includeCV)
                {
                    index.cvList.Add(ts.cvs);
                }
                index.mzs.Add(ts.mzArrayBytes.Length);
                index.ints.Add(ts.intArrayBytes.Length);
                startPosition = startPosition + ts.mzArrayBytes.Length + ts.intArrayBytes.Length;
                airdStream.Write(ts.mzArrayBytes, 0, ts.mzArrayBytes.Length);
                airdStream.Write(ts.intArrayBytes, 0, ts.intArrayBytes.Length);
            }
        }
Beispiel #3
0
        public void compressMS1(BlockIndex index)
        {
            int layers = (int)Math.Pow(2, converter.jobInfo.jobParams.digit);                                                                 //计算堆叠层数
            int iter   = converter.ms1List.Count % layers == 0 ? (converter.ms1List.Count / layers) : (converter.ms1List.Count / layers + 1); //计算循环周期

            if (converter.jobInfo.jobParams.threadAccelerate)
            {
                Hashtable table = Hashtable.Synchronized(new Hashtable());
                //使用多线程处理数据提取与压缩
                Parallel.For(0, iter, (i, ParallelLoopState) =>
                {
                    converter.jobInfo.log(null, "MS1:" + i + "/" + iter);
                    List <float> rts              = new List <float>();
                    List <int> nums               = new List <int>();
                    List <long> tics              = new List <long>();
                    List <List <CV> > cvs         = new List <List <CV> >();
                    List <Spectrum> spectrumGroup = new List <Spectrum>();
                    for (int k = 0; k < layers; k++)
                    {
                        int realNum = i * layers + k;
                        if (realNum >= converter.ms1List.Count)
                        {
                            break;
                        }
                        TempIndex scanIndex = converter.ms1List[realNum];
                        rts.Add(scanIndex.rt);
                        nums.Add(scanIndex.num);
                        tics.Add(scanIndex.tic);
                        if (converter.jobInfo.jobParams.includeCV)
                        {
                            cvs.Add(scanIndex.cvList);
                        }
                        spectrumGroup.Add(converter.spectrumList.spectrum(scanIndex.num, true));
                    }

                    TempScanSZDPD ts = new TempScanSZDPD(nums, rts, tics);
                    if (converter.jobInfo.jobParams.includeCV)
                    {
                        ts.cvs = cvs;
                    }
                    converter.compress(spectrumGroup, ts);
                    table.Add(i, ts);
                });
                converter.outputWithOrder(table, index);
            }
            else
            {
                for (int i = 0; i < iter; i++)
                {
                    converter.jobInfo.log(null, "MS1:" + i + "/" + iter);

                    List <float>      rts           = new List <float>();
                    List <int>        nums          = new List <int>();
                    List <long>       tics          = new List <long>();
                    List <List <CV> > cvs           = new List <List <CV> >();
                    List <Spectrum>   spectrumGroup = new List <Spectrum>();
                    for (int k = 0; k < layers; k++)
                    {
                        int realNum = i * layers + k;
                        if (realNum >= converter.ms1List.Count)
                        {
                            break;
                        }
                        TempIndex scanIndex = converter.ms1List[realNum];
                        rts.Add(scanIndex.rt);
                        nums.Add(scanIndex.num);
                        tics.Add(scanIndex.tic);
                        if (converter.jobInfo.jobParams.includeCV)
                        {
                            cvs.Add(scanIndex.cvList);
                        }
                        spectrumGroup.Add(converter.spectrumList.spectrum(scanIndex.num, true));
                    }

                    TempScanSZDPD ts = new TempScanSZDPD(nums, rts, tics);
                    if (converter.jobInfo.jobParams.includeCV)
                    {
                        ts.cvs = cvs;
                    }
                    converter.compress(spectrumGroup, ts);
                    converter.addToIndex(index, ts);
                }
            }
        }