How to use the molgrid.SubsettedElementTyper function in molgrid

To help you get started, we’ve selected a few molgrid examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gnina / libmolgrid / test / test_typing.py View on Github external
for t,r in typs:
        if t < 0:
            neg += 1
        elif names[t] == 'Carbon':
            ccnt += 1
            assert r == approx(.76)
        elif names[t] == 'Nitrogen_Oxygen':
            nocnt += 1
            assert r == approx(.66) #aren't any nitrogen

    assert ccnt == 7
    assert nocnt == 1
    assert neg == 8
    
    #can we do an empty list with a catchall?
    t = molgrid.SubsettedElementTyper([])
    assert t.num_types() == 1
    names = list(t.get_type_names())
    assert names[0] == 'GenericAtom'
    typs = [t.get_atom_type_index(a.OBAtom) for a in m.atoms]
    assert len(typs) == 16
    acnt = 0
    neg = 0
    rsum = 0
    for t,r in typs:
        if t < 0:
            neg += 1
        elif t == 0:
            acnt += 1
            rsum += r

    assert acnt == 16
github gnina / libmolgrid / test / test_typing.py View on Github external
ocnt += 1
            assert r == approx(.66)
        if names[t] == 'Hydrogen':
            hcnt += 1
            assert r == approx(.31)
        if names[t] == 'GenericAtom':
            other += 1

    assert ccnt == 7
    assert ocnt == 1
    assert hcnt == 7
    assert other == 1
    
    #now let's try a surjective mapping without a catchall type
    subset = [6,[7,8]]
    t = molgrid.SubsettedElementTyper(subset, catchall=False)

    assert t.num_types() == 2
    names = list(t.get_type_names())
    assert names[1] == 'Nitrogen_Oxygen'
    typs = [t.get_atom_type_index(a.OBAtom) for a in m.atoms]
    assert len(typs) == 16
    ccnt = 0
    nocnt = 0
    neg = 0
    for t,r in typs:
        if t < 0:
            neg += 1
        elif names[t] == 'Carbon':
            ccnt += 1
            assert r == approx(.76)
        elif names[t] == 'Nitrogen_Oxygen':
github gnina / libmolgrid / test / test_typing.py View on Github external
def test_subset_elementtyping():
    m = pybel.readstring('smi','c1c(Cl)cccc1CO')
    m.addh()
    subset = [1,6,7,8]
    t = molgrid.SubsettedElementTyper(subset)
    assert t.num_types() == 5
    names = list(t.get_type_names())
    assert names[4] == 'GenericAtom'
    typs = [t.get_atom_type_index(a.OBAtom) for a in m.atoms]
    assert len(typs) == 16
    ccnt = 0
    ocnt = 0
    hcnt = 0
    other = 0
    for t,r in typs:
        if names[t] == 'Carbon':
            ccnt += 1
            assert r == approx(.76)
        if names[t] == 'Oxygen':
            ocnt += 1
            assert r == approx(.66)