How to use the molgrid.NullIndexTyper 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_example_provider.py View on Github external
def test_make_vector_types_ex_provider(capsys):
    fname = datadir+"/ligonly.types"
    e = molgrid.ExampleProvider(molgrid.NullIndexTyper(),molgrid.defaultGninaLigandTyper, data_root=datadir+"/structs",make_vector_types=True)
    e.populate(fname)
    batch_size = 10
    b = e.next_batch(batch_size)

    gmaker = molgrid.GridMaker(dimension=23.5,radius_type_indexed=True)
    shape = gmaker.grid_dimensions(molgrid.defaultGninaLigandTyper.num_types())
    mgrid = molgrid.MGrid5f(batch_size,*shape)

    c = b[0].merge_coordinates()
    tv = c.type_vector.tonumpy()
    assert tv.shape == (10,14) 
    assert tv[0].sum() == 1.0
    assert tv[0][8] == 1.0
    
    
    e2 = molgrid.ExampleProvider(data_root=datadir+"/structs",make_vector_types=True)
github gnina / libmolgrid / test / test_example_provider.py View on Github external
e = molgrid.ExampleProvider(data_root=datadir+"/structs",make_vector_types=True)
    e.populate(fname)
    batch_size = 10
    b = e.next_batch(batch_size)
    sum = molgrid.MGrid2f(batch_size, e.num_types())
    b.sum_types(sum)
    sum2 = np.zeros(sum.shape,np.float32)
    b.sum_types(sum2)
    sum3 = torch.empty(sum.shape,dtype=torch.float32,device='cuda')
    b.sum_types(sum3)
    np.testing.assert_allclose(sum.tonumpy(),sum3.detach().cpu().numpy(),atol=1e-5)
    np.testing.assert_allclose(sum.tonumpy(),sum2,atol=1e-5)
    np.testing.assert_allclose(sum[0].tonumpy(), [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 2., 3., 0.,
       0., 0., 0., 0., 0., 2., 2., 1., 0., 0., 0.], atol=1e-5)

    e = molgrid.ExampleProvider(molgrid.NullIndexTyper(), molgrid.defaultGninaLigandTyper, data_root=datadir+"/structs",make_vector_types=True)
    e.populate(fname)
    b = e.next_batch(batch_size)
    sum = molgrid.MGrid2f(batch_size, e.num_types())
    b.sum_types(sum)
    np.testing.assert_allclose(sum[0].tonumpy(), [ 2., 3., 0.,
       0., 0., 0., 0., 0., 2., 2., 1., 0., 0., 0.], atol=1e-5)
github gnina / libmolgrid / test / test_typing.py View on Github external
def test_nulltyping():
    m = pybel.readstring('smi','c1ccccc1CO')
    m.addh()
    t = molgrid.NullIndexTyper()
    typs = [t.get_atom_type_index(a.OBAtom) for a in m.atoms]

    assert t.num_types() == 0
    for t,r in typs:
        assert t == -1
        assert r == 0.0