Skip to content

Commit

Permalink
support reading a bytearray (as found in hadoop seq file)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkoes committed Oct 6, 2023
1 parent 7102c7b commit 4d4a732
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions prody/proteins/mmtffile.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def parseMMTF(mmtf_struc, **kwargs):
"""
try:
from mmtf import fetch, parse
import gzip, msgpack
import mmtf
except ImportError:
raise ImportError("Install mmtf to read in mmtf structure objects (e.g. pip install mmtf-python)")
Expand Down Expand Up @@ -107,6 +108,13 @@ def parseMMTF(mmtf_struc, **kwargs):
.format(mmtf_struc))
mmtf_struc = structure
title = mmtf_struc.structure_id
elif type(mmtf_struc)==bytearray:
data = gzip.decompress(mmtf_struc)
unpack = msgpack.unpackb(data)
dec = mmtf.MMTFDecoder()
dec.decode_data(unpack)
mmtf_struc = dec


#if none of the above loops are entered, user should have passed a mmtf structure object
if title is None:
Expand Down

0 comments on commit 4d4a732

Please sign in to comment.