def test_complex_clusters(mol_file, frag): # load molecules and set aromaticity mols_list = mols_from_mol2(mol_file) for m in mols_list: m.set_aromaticity_mdl() # load smirks list smirks_list = parse_smarts_file("%s_smirks.smarts" % frag) # type molecules with these smirks clusters = create_tuples_for_clusters(smirks_list, mols_list) # smirksify these clusters create_frag = SMIRKSifier(mols_list, clusters, verbose=False, max_layers=2) # try reducing these SMIRKS create_frag.reduce(10)
def test_max_reduction(smiles): """ starting from a single atom with no layers, you should get [*:1] in a minimum of 7 steps """ mol = mol_toolkit.Mol.from_smiles(smiles) cluster_lists = [('1', [[(0, )]])] # create reducer red = SMIRKSifier([mol], cluster_lists, max_layers=0) smirks_list = red.reduce(10) final_smirks = smirks_list[0][1] assert final_smirks == '[*:1]'
def test_more_complex_reducer(): """ Check that all SMIRKSifier class functions at least work """ smiles = ['CC', 'C=C', 'C#C'] mols = [mol_toolkit.Mol.from_smiles(s) for s in smiles] c1 = [[(0, 1)]] * len(smiles) c2 = [[(0, 2)]] * len(smiles) cluster_lists = [('1', c1), ('2', c2)] # create reducer red = SMIRKSifier(mols, cluster_lists, verbose=False) # make sure printing runs: print_smirks(red.current_smirks) # run for a long time (assumed to hit all possible methods) smirks_list = red.reduce(2000)
from chemper.mol_toolkits.mol_toolkit import Mol from chemper.smirksify import SMIRKSifier, print_smirks # make molecules from smiles mols = [Mol.from_smiles('CCO'), Mol.from_smiles('CC=C')] # make clusters for each of the 6 bond types: # carbon-carbon single bond 1 ethanol, 1 propene cc_single = ('cc_single', [[(0, 1)], [(0, 1)]]) # carbon-carbon double bond 0 ethanol, 1 propene cc_double = ('cc_double', [[], [(1, 2)]]) # carbon-oxygen bond 1 ethanol, 0 propene co = ('co', [[(1, 2)], []]) # hydrogen-tetrahedral carbon 5 ethanol, 3 propene hc_tet = ('hc_tet', [[(0, 3), (0, 4), (0, 5), (1, 6), (1, 7)], [(0, 3), (0, 4), (0, 5)]]) # hydrogen-planar carbon bond 0 ethanol, 3 propene hc_plan = ('hc_plan', [[], [(1, 6), (2, 7), (2, 8)]]) # hydrogen-oxygen bond 1 ethanol, 0 propene ho = ('ho', [[(2, 8)], []]) # initiate SMIRKSifier with default max_layers = 5 and verbose = True fier = SMIRKSifier(mols, [cc_single, cc_double, co, hc_tet, hc_plan, ho]) # print initial SMIRKS print_smirks(fier.current_smirks) # Reduce SMIRKS with default 1000 iterations fier.reduce() # print final SMIRKS print_smirks(fier.current_smirks)