Skip to content

Commit 363f7f7

Browse files
committed
remove all hydrogens of template residue SMILES to prevent crashes
1 parent 5ec65da commit 363f7f7

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/test_rdkittools.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,25 @@ def _cmp(mol, ref_mol):
6161
_cmp(mol, ref_mol)
6262

6363

64+
def _test_templateResidueFromSmiles_incorrect_smiles():
65+
import numpy as np
66+
67+
testdir = os.path.join(curr_dir, "test_molecule", "test_templating")
68+
start_file = os.path.join(testdir, "BEN.pdb")
69+
70+
sel = "resname BEN"
71+
incorrect_smiles = "[H]/N=C(\\c1ccccc1)/N"
72+
73+
mol = Molecule(start_file)
74+
mol.templateResidueFromSmiles(sel, incorrect_smiles, addHs=False, guessBonds=True)
75+
76+
ben = mol.copy(sel=sel)
77+
assert ben.numAtoms == 9
78+
assert ben.numBonds == 9
79+
assert np.all(ben.formalcharge == 0)
80+
assert "2" in ben.bondtype
81+
82+
6483
@pytest.mark.parametrize("file", ("1STP_BTN.cif", "BEN_pH7.4.cif"))
6584
def _test_toRDKitMol(file):
6685
testdir = os.path.join(curr_dir, "test_molecule", "test_templating")

0 commit comments

Comments
 (0)