Commit a4d9e249 authored by yugao@uic.edu's avatar yugao@uic.edu

added header reader to decoder

parent 0759b4b1
......@@ -67,7 +67,7 @@ def base64_encoder(number_array: np.ndarray, compress_method: str):
def find_string(file_io_fp, mzml_read_fp, match_tag_start, match_tag_end,
data_format, spec_no, compression='auto'):
start_time = time.time()
if compression=='zstd':
if compression.lower()=='zstd':
compressor = zstandard.ZstdCompressor(threads=2)
file_name = mzml_read_fp.name
file_size = os.path.getsize(file_name)
......@@ -202,8 +202,10 @@ def mzml_decoder(msz_file, mzml_file, compression='auto'):
bmass_data = msz_fp.read(file_pos_array[3]-file_pos_array[2])
bint_data = msz_fp.read(file_pos_array[5] - file_pos_array[4])
if compression == 'auto':
compression = file_head[180:184].decode('utf-8')
if compression=='zstd':
if compression.lower()=='zstd':
decompressor = zstandard.ZstdDecompressor()
bmass_data = decompressor.decompress(bmass_data)
bint_data = decompressor.decompress(bint_data)
......@@ -211,6 +213,7 @@ def mzml_decoder(msz_file, mzml_file, compression='auto'):
smzml_file = smzml_data.decode('utf8').splitlines()
# Create file pointers
#print(smzml_file[:2])
total_spec_no = int.from_bytes(bint_data[-4:], byteorder='little')
......@@ -310,5 +313,5 @@ if __name__ == '__main__':
start = time.time()
output_mzml = r'K:\test\test\out2.mzML'
mzml_decoder(msz_output, output_mzml, compression=args.compression)
mzml_decoder(msz_output, output_mzml, compression='auto')
print("total time for unpacking: %ss" % (time.time() - start))
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment