Exemplo n.º 1
0
def test_vocabulary_legal_at_atom():
    vocab = vocabulary.Vocabulary()
    test_mol = [me.get_mol(s) for s in test_smiles]

    for mol in test_mol:
        for atom in mol.GetAtoms():
            assert vocab.legal_at_atom(atom) == me.legal_at_atom(mol, atom, vocab.vocab)
def test_action_to_integer_roundtrip_delete():
    mol = me.get_mol(
        'CCCCCCC1=NN2C(=N)/C(=C\\c3cc(C)n(-c4ccc(C)cc4C)c3C)C(=O)N=C2S1')
    vocab = vocabulary.Vocabulary()
    act = me.enumerate_deletion_actions(mol)[1]

    action_roundtrip = roundtrip_action(act, vocab, mol)

    assert list(act.to_array()) == list(action_roundtrip.to_array())
Exemplo n.º 3
0
def test_vocabulary_legal_at_bond():
    vocab = vocabulary.Vocabulary()
    test_mol = [me.get_mol(s) for s in test_smiles]

    for mol in test_mol:
        for bond in mol.GetBonds():
            if not bond.IsInRing():
                continue

            assert vocab.legal_at_bond(bond) == me.legal_at_bond(mol, bond, vocab.vocab)
def test_action_to_integer_roundtrip_insert_atom():
    mol = me.get_mol(
        'CCCCCCC1=NN2C(=N)/C(=C\\c3cc(C)n(-c4ccc(C)cc4C)c3C)C(=O)N=C2S1')
    vocab = vocabulary.Vocabulary()
    act = me.generate_random_atom_insert(mol,
                                         mol.GetAtomWithIdx(1),
                                         vocab,
                                         rng=np.random.RandomState(20))

    action_roundtrip = roundtrip_action(act, vocab, mol)

    assert list(act.to_array()) == list(action_roundtrip.to_array())
def test_action_canonical_roundtrip(seed):
    mol = me.get_mol(
        'CCCCCCC1=NN2C(=N)/C(=C\\c3cc(C)n(-c4ccc(C)cc4C)c3C)C(=O)N=C2S1')
    vocab = vocabulary.Vocabulary()

    act = me.generate_random_atom_insert(mol,
                                         mol.GetAtomWithIdx(1),
                                         vocab,
                                         rng=np.random.RandomState(seed))

    encoder = ar.VocabInsertEncoder(vocab)
    result, offsets, lengths = action_mol_to_integer(act, mol, encoder)
    action_roundtrip = ar.integer_to_action(result, lengths, encoder)

    assert (action_mol_to_integer(act, mol,
                                  encoder)[0] == action_mol_to_integer(
                                      action_roundtrip, mol, encoder)[0])