rcsb / mmtf

The specification of the MMTF format for biological structures
http://mmtf.rcsb.org/
44 stars 17 forks source link

Add 3NJW-onlyrequired.mmtf example #39

Closed speleo3 closed 5 years ago

speleo3 commented 5 years ago

3NJW with all optional fields removed.

A file like this should help testing downstream software to comply with the spec and not fail if optional fields are missing. Example: https://github.com/MDAnalysis/mdanalysis/issues/2193

Closes #26

speleo3 commented 5 years ago

File was created with this script:

import struct
import msgpack

pdbid = '3NJW'

optionalkeys = '''unitCell spaceGroup structureId title depositionDate
releaseDate ncsOperatorList bioAssemblyList entityList experimentalMethods
resolution rFree rWork bondAtomList bondOrderList bFactorList atomIdList
altLocList occupancyList secStructList insCodeList sequenceIndexList
chainNameList
'''.split()

with open(pdbid + '.mmtf', 'rb') as f:
    d = msgpack.unpack(f, encoding='utf-8')

if 'bondOrderList' in d:
    n = struct.unpack('>i', d['bondOrderList'][4:8])[0]
    d['numBonds'] -= n

for key in optionalkeys:
    d.pop(key, None)

with open(pdbid + '-onlyrequired.mmtf', 'wb') as f:
    msgpack.pack(d, f, use_bin_type=True)
speleo3 commented 5 years ago

Any reason why this hasn't been merged yet?

speleo3 commented 5 years ago

thanks @josemduarte !