Пример #1
0
def test_failed_layers():
    mol1 = mol_toolkit.Mol.from_smiles('CCC')
    mol2 = mol_toolkit.Mol.from_smiles('CCCC')
    # cluster 1 has bond 0-1 in mol1
    # cluster 2 has bond 0-1 and 2-3 in mol2
    # the only way to distinguish these is
    # with more than 1 layer so max_layers = 0 will fail
    clusters = [('1', [[(0, 1)], []]), ('2', [[], [(0, 1), (3, 2)]])]
    with pytest.raises(ClusteringError):
        red = SMIRKSifier([mol1, mol2], clusters, max_layers=0)
        print(red.current_smirks)
        print_smirks(red.current_smirks)
Пример #2
0
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)
Пример #3
0
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)