How to use the molgrid.defaultGninaLigandTyper.get_type_radii 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_torch.py View on Github external
def test_coords2grid():
    gmaker = molgrid.GridMaker(resolution=0.5,
                           dimension=23.5,
                           radius_scale=1,
                           radius_type_indexed=True)
    n_types = molgrid.defaultGninaLigandTyper.num_types()
    radii = np.array(list(molgrid.defaultGninaLigandTyper.get_type_radii()),np.float32)
    dims = gmaker.grid_dimensions(n_types)
    grid_size = dims[0] * dims[1] * dims[2] * dims[3]

    c2grid = molgrid.Coords2Grid(gmaker, center=(0,0,0))
    n_atoms = 2
    batch_size = 1
    coords = nn.Parameter(torch.randn(n_atoms, 3,device='cuda'))
    types = nn.Parameter(torch.randn(n_atoms, n_types+1,device='cuda'))
    
    coords.data[0,:] = torch.tensor([ 1,0,0])
    coords.data[1,:] = torch.tensor([-1,0,0])
    types.data[...] = 0
    types.data[:,10] = 1

    batch_radii = torch.tensor(np.tile(radii, (batch_size, 1)), dtype=torch.float32,  device='cuda')
github gnina / libmolgrid / test / test_coordinateset.py View on Github external
def test_coordset_from_mol_vec():
    m = pybel.readstring('smi','c1ccccc1CO')
    m.addh()
    m.make3D()
    
    c = molgrid.CoordinateSet(m) #default gnina ligand types
    c.make_vector_types(True, molgrid.defaultGninaLigandTyper.get_type_radii())
    
    assert c.type_vector.dimension(1) == 15
    assert c.radii.dimension(0) == 15
    assert c.has_vector_types()