コード例 #1
0
 private static void ZLib(Stream memoryStream, Peak1DArray peakArray)
 {
     using (var deflateStream = new DeflateStream(memoryStream, CompressionMode.Compress, true))
     {
         NoCompression(deflateStream, peakArray);
     }
 }
コード例 #2
0
ファイル: BinaryDataEncoder.cs プロジェクト: ZimmerD/MzLite
 private static void NoCompression(Stream memoryStream, Peak1DArray peakArray)
 {
     using (var writer = new BinaryWriter(memoryStream, Encoding.UTF8, true))
     {
         foreach (var pk in peakArray.Peaks)
         {
             WriteValue(writer, peakArray.IntensityDataType, pk.Intensity);
             WriteValue(writer, peakArray.MzDataType, pk.Mz);
         }
     }
 }
コード例 #3
0
 private static void NoCompression(Stream stream, Peak1DArray peakArray)
 {
     using (var reader = new BinaryReader(stream, Encoding.UTF8, true))
     {
         for (int i = 0; i < peakArray.ArrayLength; i++)
         {
             double intensity = ReadValue(reader, peakArray.IntensityDataType);
             double mz        = ReadValue(reader, peakArray.MzDataType);
             peakArray.Peaks[i] = new Peak1D(intensity, mz);
         }
     }
 }
コード例 #4
0
        public void Decode(Stream stream, Peak1DArray peakArray)
        {
            switch (peakArray.CompressionType)
            {
            case BinaryDataCompressionType.NoCompression:
                NoCompression(stream, peakArray);
                break;

            case BinaryDataCompressionType.ZLib:
                ZLib(stream, peakArray);
                break;

            default:
                throw new NotSupportedException("Compression type not supported: " + peakArray.CompressionType.ToString());
            }
        }
コード例 #5
0
        private static void NoCompression(Stream stream, Peak1DArray peakArray)
        {
            using (var reader = new BinaryReader(stream, Encoding.UTF8, true))
            {
                int      len   = reader.ReadInt32();
                Peak1D[] peaks = new Peak1D[len];

                for (int i = 0; i < len; i++)
                {
                    double intensity = ReadValue(reader, peakArray.IntensityDataType);
                    double mz        = ReadValue(reader, peakArray.MzDataType);
                    peaks[i] = new Peak1D(intensity, mz);
                }

                peakArray.Peaks = peaks.ToMzLiteArray();
            }
        }
コード例 #6
0
        public byte[] Encode(Peak1DArray peakArray)
        {
            memoryStream.Position = 0;
            switch (peakArray.CompressionType)
            {
            case BinaryDataCompressionType.NoCompression:
                NoCompression(memoryStream, peakArray);
                break;

            case BinaryDataCompressionType.ZLib:
                ZLib(memoryStream, peakArray);
                break;

            default:
                throw new NotSupportedException("Compression type not supported: " + peakArray.CompressionType.ToString());
            }
            memoryStream.Position = 0;
            return(memoryStream.ToArray());
        }