def test_am1bcc(): smirks = [] params = [] props = None am1 = nonbonded.AM1BCCHandler(smirks, params, props) obj = am1.serialize() all_handlers = deserialize_handlers(bin_to_str(obj)) am1 = all_handlers[0] np.testing.assert_equal(am1.smirks, am1.smirks) np.testing.assert_equal(am1.params, am1.params) assert am1.props == am1.props
def test_am1_bcc(): # currently takes no parameters smirks = [] params = [] props = None am1h = nonbonded.AM1BCCHandler(smirks, params, props) mol = Chem.AddHs(Chem.MolFromSmiles("C1CNCOC1F")) AllChem.EmbedMolecule(mol) charges = am1h.parameterize(mol) assert len(charges) == mol.GetNumAtoms() new_charges, vjp_fn = jax.vjp(functools.partial(am1h.partial_parameterize, mol=mol))
def test_am1_bcc(): # currently takes no parameters smirks = [] params = [] props = None am1h = nonbonded.AM1BCCHandler(smirks, params, props) mol = Chem.AddHs(Chem.MolFromSmiles("C1CNCOC1F")) AllChem.EmbedMolecule(mol) charges, vjp_fn = am1h.parameterize(mol) assert len(charges) == mol.GetNumAtoms() charges_adjoints = np.random.randn(*charges.shape) assert vjp_fn(charges_adjoints) == None
def test_am1_differences(): ff_raw = open("ff/params/smirnoff_1_1_0_ccc.py").read() ff_handlers = deserialize_handlers(ff_raw) for ccc in ff_handlers: if isinstance(ccc, nonbonded.AM1CCCHandler): break suppl = Chem.SDMolSupplier('tests/data/ligands_40.sdf', removeHs=False) smi = "[H]c1c(OP(=S)(OC([H])([H])C([H])([H])[H])OC([H])([H])C([H])([H])[H])nc(C([H])(C([H])([H])[H])C([H])([H])[H])nc1C([H])([H])[H]" smi = "Clc1c(Cl)c(Cl)c(-c2c(Cl)c(Cl)c(Cl)c(Cl)c2Cl)c(Cl)c1Cl" mol = Chem.MolFromSmiles(smi) mol = Chem.AddHs(mol) mol.SetProp("_Name", "Debug") assert AllChem.EmbedMolecule(mol) == 0 suppl = [mol] am1 = nonbonded.AM1Handler([], [], None) bcc = nonbonded.AM1BCCHandler([], [], None) for mol in suppl: am1_params = am1.parameterize(mol) ccc_params = ccc.parameterize(mol) bcc_params = bcc.parameterize(mol) if np.sum(np.abs(ccc_params - bcc_params)) > 0.1: print(mol.GetProp("_Name"), Chem.MolToSmiles(mol)) print(" AM1 CCC BCC S ?") for atom_idx, atom in enumerate(mol.GetAtoms()): a = am1_params[atom_idx] b = bcc_params[atom_idx] c = ccc_params[atom_idx] print("{:6.2f}".format(a), "{:6.2f}".format(c), "{:6.2f}".format(b), atom.GetSymbol(), end="") if np.abs(b-c) > 0.1: print(" *") else: print(" ") assert 0
def test_am1_differences(): ff_raw = open("ff/params/smirnoff_1_1_0_ccc.py").read() ff_handlers = deserialize(ff_raw) for ccc in ff_handlers: if isinstance(ccc, nonbonded.AM1CCCHandler): break suppl = Chem.SDMolSupplier('tests/ligands_40.sdf', removeHs=False) am1 = nonbonded.AM1Handler([], [], None) bcc = nonbonded.AM1BCCHandler([], [], None) for mol in suppl: am1_params, vjp_fn = am1.parameterize(mol) ccc_params, vjp_fn = ccc.parameterize(mol) bcc_params, vjp_fn = bcc.parameterize(mol) if np.sum(np.abs(ccc_params - bcc_params)) > 0.1: print(mol.GetProp("_Name"), Chem.MolToSmiles(mol)) print(" AM1 CCC BCC S ?") for atom_idx, atom in enumerate(mol.GetAtoms()): a = am1_params[atom_idx] b = bcc_params[atom_idx] c = ccc_params[atom_idx] print("{:6.2f}".format(a), "{:6.2f}".format(c), "{:6.2f}".format(b), atom.GetSymbol(), end="") if np.abs(b - c) > 0.1: print(" *") else: print(" ") assert 0