Source code for schrodinger.structutils.pbc_tools
"""
Glean PBC from a Structure
"""
from schrodinger.infra import structure as infrastructure
[docs]def get_pbc(st1, st2, honor_pbc=None):
"""
If the structures are the same, and have a PBC, then return it. Otherwise,
return None.
:type st1: schrodinger.structure.Structure object
:type st2: schrodinger.structure.Structure object
:type honor_pbc: bool
:param honor_pbc: Should a PBC be discovered from the Structure objects?
:rtype: NoneType or schrodinger.infra.structure.PBC
"""
pbc = None
if honor_pbc and (st1 == st2 or st2 is None):
try:
pbc = infrastructure.PBC(st1)
except IndexError:
# PBC properties are not present or are invalid
pbc = None
return pbc