How to use the molgrid.Quaternion 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_coordinateset.py View on Github external
def test_coordset_from_mol():
    m = pybel.readstring('smi','c1ccccc1CO')
    m.addh()
    m.make3D()
    
    c = molgrid.CoordinateSet(m,molgrid.ElementIndexTyper())
    oldcoord = c.coords.tonumpy()
    #simple translate
    t = molgrid.Transform(molgrid.Quaternion(), (0,0,0), (1,1,1))
    t.forward(c,c)
    newcoord = c.coords.tonumpy()
    assert np.sum(newcoord-oldcoord) == approx(48)
github gnina / libmolgrid / test / test_transform.py View on Github external
def test_apply_transform():
    '''non-random transform'''
    from molgrid import Transform, Quaternion, float3, MGrid2f, Grid2f
    from math import sqrt
    
    q = Quaternion(sqrt(0.5),0,0,sqrt(0.5)) # //z 90
    nr = Transform(q, float3(0,1,1), float3(2,0,-3))

    #random
    r = Transform(float3(0,1,1), 10.0, True)

    coord_data = [ [0,0,0],
                   [1,0,0],
                   [0,1,0],
                   [0,0,1],
                   [-1,.5,3],
                   [1,1,1],
                   [0,1,1],
                   [.333,.75,-9] ]
  
    coords = MGrid2f(8,3)
    coords2 = MGrid2f(8,3)
github gnina / libmolgrid / test / test_coordinateset.py View on Github external
def test_coordset_from_array():
    
    coords = np.array([[1,0,-1],[1,3,-1],[1,0,-1]],np.float32)
    types = np.array([3,2,1],np.float32)
    radii = np.array([1.5,1.5,1.0],np.float32)
    c = molgrid.CoordinateSet(coords, types, radii, 4)

    oldcoordr = c.coords.tonumpy()
    #simple translate
    t = molgrid.Transform(molgrid.Quaternion(), (0,0,0), (-1,0,1))
    t.forward(c,c)
    newcoord = c.coords.tonumpy()
    
    assert c.coords[1,1] == 3.0
    assert np.sum(newcoord) == approx(3.0)
    
    c2 = c.clone()
    c2.coords[1,1] = 0
    assert c.coords[1,1] == 3.0
github gnina / libmolgrid / test / test_transform.py View on Github external
def test_numpy_apply_transform():
    '''non-random transform'''
    from molgrid import Transform, Quaternion, float3, MGrid2f, Grid2f
    from math import sqrt
    import numpy as np
    
    q = Quaternion(sqrt(0.5),0,0,sqrt(0.5)) # //z 90
    nr = Transform(q, float3(0,1,1), float3(2,0,-3))

    #random
    r = Transform(float3(0,1,1), 10.0, True)

    coord_data = [ [0,0,0],
                   [1,0,0],
                   [0,1,0],
                   [0,0,1],
                   [-1,.5,3],
                   [1,1,1],
                   [0,1,1],
                   [.333,.75,-9] ]
  
    coords = np.array(coord_data,np.float32)
    coords2 = np.zeros((8,3),np.float32)