Example #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());
        }
Example #2
0
        public void compress(Spectrum spectrum, TempScan ts)
        {
            BinaryDataDouble mzData  = spectrum.getMZArray().data;
            BinaryDataDouble intData = spectrum.getIntensityArray().data;
            var dataCount            = mzData.Count;

            int[]   mzArray        = new int[dataCount];
            float[] intensityArray = new float[dataCount];
            int     j = 0;

            for (int t = 0; t < dataCount; t++)
            {
                if (jobInfo.jobParams.ignoreZeroIntensity && intData[t] == 0)
                {
                    continue;
                }
                int mz = Convert.ToInt32(mzData[t] * mzPrecision);
                mzArray[j] = mz;

                if (jobInfo.jobParams.log2)
                {
                    intensityArray[j] = Convert.ToSingle(Math.Round(Math.Log(intData[t]) / log2, 3)); //取log10并且精确到小数点后3位
                }
                else
                {
                    intensityArray[j] = Convert.ToSingle(Math.Round(intData[t], 1)); //精确到小数点后一位
                }
                j++;
            }
            int[] mzSubArray = new int[j];
            Array.Copy(mzArray, mzSubArray, j);
            float[] intensitySubArray = new float[j];
            Array.Copy(intensityArray, intensitySubArray, j);

            int[] compressedMzArray = CompressUtil.fastPforEncoder(mzSubArray);
            ts.mzArrayBytes  = CompressUtil.zlibEncoder(compressedMzArray);
            ts.intArrayBytes = CompressUtil.zlibEncoder(intensitySubArray);
        }