Skip to content

Commit 472d59f

Browse files
authored
Improve PDB output (#34)
- Number residues correctly (1-indexing); - Use HETATOM for ligands;
1 parent 90da6fc commit 472d59f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

chai_lab/data/io/pdb_utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ def get_pdb_atoms(self):
9999
# warning: calling this on cuda tensors is extremely slow
100100
atom_asym_id = self.token_asym_id[self.atom_token_index]
101101
# atom level attributes
102-
atom_residue_index = self.token_residue_index[self.atom_token_index]
102+
atom_residue_index = (
103+
self.token_residue_index[self.atom_token_index] + 1
104+
) # residues are 1-indexed
103105
atom_names = _tensor_to_atom_names(self.atom_ref_name_chars.unsqueeze(0))
104106
atom_res_names = self.token_residue_names[self.atom_token_index]
105107
atom_res_names_strs = [
@@ -121,7 +123,7 @@ def get_pdb_atoms(self):
121123
f"Too many chains for PDB file: {atom_asym_id[atom_index].item()} -- wrapping around"
122124
)
123125
atom = PDBAtom(
124-
record_type="ATOM",
126+
record_type="ATOM" if not self.is_ligand else "HETATM",
125127
atom_index=atom_index,
126128
atom_name=atom_names[atom_index],
127129
alt_loc="",

0 commit comments

Comments
 (0)