How to use the molgrid.Example 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.py View on Github external
def test_examplevec():
    m = pybel.readstring('smi','c1ccccc1CO')
    m.addh()
    m.make3D()
    
    c = molgrid.CoordinateSet(m,molgrid.ElementIndexTyper())
    c2 = molgrid.CoordinateSet(m)

    c2.make_vector_types() #this should not screw up index types
    
    ex = molgrid.Example()
    ex.coord_sets.append(c)
    ex.labels.append(0)
    
    ex2 = molgrid.Example()
    ex2.coord_sets.append(c2)
    ex2.labels.append(1)
    
    evec = molgrid.ExampleVec([ex,ex2])
github gnina / libmolgrid / test / test_example.py View on Github external
def test_example_merge():
    m = pybel.readstring('smi','c1ccccc1CO')
    m.addh()
    m.make3D()
    
    c = molgrid.CoordinateSet(m,molgrid.ElementIndexTyper())
    c2 = molgrid.CoordinateSet(m)

    c2.make_vector_types() #this should not screw up index types
    
    ex = molgrid.Example()
    ex.coord_sets.append(c)
    ex.coord_sets.append(c2)
    assert ex.num_types() == (c.max_type + c2.max_type)
    assert ex.num_coordinates() == (c.coords.dimension(0)+c2.type_index.size())
    
    c3 = ex.merge_coordinates()
    assert c3.coords.tonumpy().shape == (24,3)
    
    t = np.concatenate([c.type_index.tonumpy(),c2.type_index.tonumpy()+c.max_type])
    assert np.array_equal(t, c3.type_index.tonumpy())
    
    #test merging without unique types, which makes no sense
    c4 = ex.merge_coordinates(0,False)
    assert c4.coords.tonumpy().shape == (24,3)
    t = np.concatenate([c.type_index.tonumpy(),c2.type_index.tonumpy()])
    assert np.array_equal(t, c4.type_index.tonumpy())
github gnina / libmolgrid / test / test_example.py View on Github external
def test_examplevec():
    m = pybel.readstring('smi','c1ccccc1CO')
    m.addh()
    m.make3D()
    
    c = molgrid.CoordinateSet(m,molgrid.ElementIndexTyper())
    c2 = molgrid.CoordinateSet(m)

    c2.make_vector_types() #this should not screw up index types
    
    ex = molgrid.Example()
    ex.coord_sets.append(c)
    ex.labels.append(0)
    
    ex2 = molgrid.Example()
    ex2.coord_sets.append(c2)
    ex2.labels.append(1)
    
    evec = molgrid.ExampleVec([ex,ex2])