ihmwg / python-ihm

Python package for handling IHM mmCIF and BinaryCIF files
MIT License
14 stars 7 forks source link

Discrepancies in entities assignment #120

Closed aozalevsky closed 1 year ago

aozalevsky commented 1 year ago

XL residues have an empty entity attribute, but it can be accessed as asym.entity (see example below). Is this intended behavior? It can be puzzling if the user is unfamiliar with the python-ihm.


fname = 'PDBDEV_00000016.cif'
try:
    with open(fname, 'r') as f:
        mmcif, = ihm.reader.read(f)
except UnicodeDecodeError:
    with open(fname, 'r', encoding='latin-1') as f:
        mmcif, = ihm.reader.read(f)

restraint = mmcif.restraints[0]
xl = restraint.cross_links[0]

print(xl.residue1.entity)
>>> None

print(xl.residue1.asym.entity)
>>> <ihm.Entity(Nup133)>
benmwebb commented 1 year ago

This is as designed, but I agree it is a little confusing. Residues can represent both

I'll change entity in real residues to be a synonym for asym.entity.