in mmcif_utils.py [0:0]
def _parse_residue(residue):
"""Obtains a sparse representation of residue from gemmi"""
# list of atoms in the residue (e.g. N-CA-C-O)
atoms = res_atoms[residue.name]
# ordinal encoding of how far away the parents are
parents = res_parents[residue.name]
# ordinal encoding of how far away the children are
children = res_children[residue.name]
# atoms belonging to chi anglse
chis = res_chis[residue.name]
# accumulate the xyz postions of the atoms, and node_embed encodings
pos, node_embeds = [], []
residue_counter = 0
for atom in atoms:
if atom in residue:
atom = residue[atom]
elif recorrect_name(atom) in residue:
atom = residue[recorrect_name(atom)]
else:
return None
pos.append((atom.pos.x, atom.pos.y, atom.pos.z))
node_embeds.append(
(
residue_names.index(residue.name),
atom_names.index(atom.element.name),
residue_counter,
atom.pos.x,
atom.pos.y,
atom.pos.z,
)
)
residue_counter = residue_counter + 1
# 20-dim mask for each residue for atom existence
exist = [1] * len(parents) + [0] * (20 - len(parents))
# pad the parents and children to 20-dim
parents = parents + [0] * (20 - len(parents))
children = children + [0] * (20 - len(children))
# place the x,y,z coordinates into a numpy array
pos_fill = np.zeros((20, 3))
pos_fill[: len(pos)] = pos
# pad the chi angles
chis = [1] * len(chis) + [0] * (5 - len(chis))
# return the new representation
return parents, children, pos_fill, exist, chis, node_embeds