Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix atom labeling so they can be named in constraints #226

Closed
wants to merge 7 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions chai_lab/data/sources/rdkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# See the LICENSE file for details.

import logging
from collections import defaultdict
from pathlib import Path

import antipickle
Expand Down Expand Up @@ -157,8 +158,13 @@ def generate(self, smiles: str) -> ConformerData:

AllChem.EmbedMultipleConfs(mol_with_hs, numConfs=1, params=params)
AllChem.RemoveHs(mol_with_hs)
for atom in mol_with_hs.GetAtoms():
atom.SetProp("name", atom.GetSymbol())

element_counter: dict = defaultdict(int)
for i, atom in enumerate(mol_with_hs.GetAtoms()):
elem = atom.GetSymbol()
element_counter[elem] += 1
atom.SetProp("name", elem + str(element_counter[elem]))

retval = self._load_ref_conformer_from_rdkit(mol_with_hs)
retval.atom_names = [a.upper() for a in retval.atom_names]
return retval
Expand Down
Loading