def test_mol2xyz_exception(caffeine_smiles): m = Molecule(caffeine_smiles, 'smiles') m.hydrogens('add') with pytest.raises(ValueError): m.to_xyz() with pytest.raises(ValueError): m.to_xyz('uff')
def test_mol2xyz_UFF(caffeine_smiles): m = Molecule(caffeine_smiles, 'smiles') m.hydrogens('add') m.to_xyz('UFF', ignoreInterfragInteractions=False) assert m.xyz.geometry.shape[0] == m.rdkit_molecule.GetNumAtoms() m.to_xyz('UFF', maxIters=110) assert m.xyz.atomic_symbols.shape[0] == m.rdkit_molecule.GetNumAtoms() assert m.UFF_args['maxIters'] == 110 # check default args m.to_xyz('UFF', **m._default_UFF_args)
def test_mol2xyz_MMFF(caffeine_smiles): m = Molecule(caffeine_smiles, 'smiles') m.hydrogens('add') m.to_xyz('MMFF', maxIters=210) assert m.xyz.geometry.shape[0] == m.rdkit_molecule.GetNumAtoms() m.to_xyz('MMFF', maxIters=110, mmffVariant='MMFF94s') assert m.xyz.atomic_symbols.shape[0] == m.rdkit_molecule.GetNumAtoms() assert m.MMFF_args['mmffVariant'] == 'MMFF94s' # check default args m.to_xyz('MMFF', **m._default_MMFF_args)
def test_hydrogens(caffeine_smiles, caffeine_canonical, caffeine_inchi): m = Molecule(caffeine_smiles, 'smiles') m.to_smiles() assert isinstance(m.rdkit_molecule, Chem.Mol) assert m.smiles == caffeine_canonical # add hydrogens m.hydrogens('add', explicitOnly=False) # canonical smiles with hydrogens m.to_smiles() assert m.smiles == "[H]c1nc2c(c(=O)n(C([H])([H])[H])c(=O)n2C([H])([H])[H])n1C([H])([H])[H]" # test inchi m = Molecule(caffeine_inchi, 'inchi') m.to_inchi() assert m.inchi == caffeine_inchi # add hydrogens m.hydrogens('add') m.to_inchi() assert m.inchi == caffeine_inchi
def bagofbounds(mol2, maxentry): from chemml.chem import Molecule #caffeine_smiles = 'CN1C=NC2=C1C(=O)N(C(=O)N2C)C' #caffeine_smarts = '[#6]-[#7]1:[#6]:[#7]:[#6]2:[#6]:1:[#6](=[#8]):[#7](:[#6](=[#8]):[#7]:2-[#6])-[#6]' #caffeine_inchi = 'InChI=1S/C8H10N4O2/c1-10-4-9-6-5(10)7(13)12(3)8(14)11(6)2/h4H,1-3H3' mol = Molecule(Chem.MolToSmiles(mol2), 'smiles') mol.hydrogens('add') mol.to_xyz(optimizer='MMFF', mmffVariant='MMFF94s', maxIters=300) # 'UFF' print(mol) mol.visualize() #mol.visualize() from chemml.datasets import load_xyz_polarizability from chemml.chem import BagofBonds #coordinates, y = load_xyz_polarizability(mol) bob = BagofBonds(const=1.0) features = bob.represent(mol) print(features) print("number of entry") print(features.shape[1]) if features.shape[1] > maxentry: maxentry = features.shape[1] return features, maxentry
def test_hydrogens_exception(caffeine_smiles): m = Molecule(caffeine_smiles, 'smiles') with pytest.raises(ValueError): m.hydrogens('addHs')
from chemml.chem import Molecule caffeine_smiles = 'CN1C=NC2=C1C(=O)N(C(=O)N2C)C' caffeine_smarts = '[#6]-[#7]1:[#6]:[#7]:[#6]2:[#6]:1:[#6](=[#8]):[#7](:[#6](=[#8]):[#7]:2-[#6])-[#6]' caffeine_inchi = 'InChI=1S/C8H10N4O2/c1-10-4-9-6-5(10)7(13)12(3)8(14)11(6)2/h4H,1-3H3' mol = Molecule(caffeine_smiles, input_type='smiles') mol.hydrogens('add') mol.to_xyz(optimizer='MMFF', mmffVariant='MMFF94s', maxIters=300) # 'UFF' print(mol) mol.visualize() #mol.visualize() from chemml.datasets import load_xyz_polarizability from chemml.chem import BagofBonds #coordinates, y = load_xyz_polarizability(mol) bob = BagofBonds(const= 1.0) features = bob.represent(mol) print(features)