Ejemplo n.º 1
0
        public static void stackZDPD_Test1()
        {
            List <int[]> arrGroup = new List <int[]>();

            for (int j = 0; j < 256; j++)
            {
                int[] mz = new int[1000 + (int)(new Random().NextDouble() * 100)];
                mz[0] = 10000;
                for (int i = 1; i < mz.Length; i++)
                {
                    mz[i] = mz[i - 1] + (int)(new Random().NextDouble() * 1000);
                }
                arrGroup.Add(mz);
            }
            Layers       layers             = StackCompressUtil.stackEncode(arrGroup, false);
            List <int[]> decompressArrGroup = StackCompressUtil.stackDecode(layers);
            Boolean      pass = true;

            for (int i = 0; i < arrGroup.Count; i++)
            {
                pass = pass && Arrays.equals(arrGroup[i], decompressArrGroup[i]);
                if (!pass)
                {
                    break;
                }
            }
            Console.WriteLine(pass);
        }
Ejemplo n.º 2
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());
        }