How to use the chempy.cpv.get_null function in chempy

To help you get started, we’ve selected a few chempy 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 Pymol-Scripts / Pymol-script-repo / OLD / structural_biology_scripts / AngleBetweenHelices.py View on Github external
def _vec_sum(vec_list):
    # this is the same as
    # return numpy.array(vec_list).sum(0).tolist()
    vec = cpv.get_null()
    for x in vec_list:
        vec = cpv.add(vec, x)
    return vec
github Pymol-Scripts / Pymol-script-repo / anglebetweenhelices.py View on Github external
def _vec_sum(vec_list):
    # this is the same as
    # return numpy.array(vec_list).sum(0).tolist()
    vec = cpv.get_null()
    for x in vec_list:
        vec = cpv.add(vec, x)
    return vec
github speleo3 / pymol-psico / psico / querying.py View on Github external
r = gyradius('chain A')
    cmd.pseudoatom('com', pos=x, vdw=r)

SEE ALSO

    gyradius
    '''
    from chempy import cpv
    state, quiet = int(state), int(quiet)
    if state < 0:
        states = [cmd.get_state()]
    elif state == 0:
        states = list(range(1, cmd.count_states(selection)+1))
    else:
        states = [state]
    com = cpv.get_null()
    totmass = 0.0
    for state in states:
        model = cmd.get_model(selection, state)
        for a in model.atom:
            if a.q == 0.0:
                continue
            m = a.get_mass() * a.q
            com = cpv.add(com, cpv.scale(a.coord, m))
            totmass += m
    com = cpv.scale(com, 1./totmass)
    if not quiet:
        print(' Center of Mass: [%8.3f,%8.3f,%8.3f]' % tuple(com))
    return com
github speleo3 / pymol-psico / psico / orientation.py View on Github external
USAGE

    loop_orientation selection [, visualize ]

SEE ALSO

    helix_orientation
    '''
    state, visualize, quiet = int(state), int(visualize), int(quiet)

    coords = dict()
    cmd.iterate_state(state, '(%s) and name N+C' % (selection),
            'coords.setdefault(chain + resi, {})[name] = x,y,z', space=locals())

    vec = cpv.get_null()
    center = cpv.get_null()

    count = 0
    for x in coords.values():
        if 'C' in x and 'N' in x:
            vec = cpv.add(vec, cpv.sub(x['C'], x['N']))
        for coord in x.values():
            center = cpv.add(center, coord)
            count += 1

    if count == 0:
        print('warning: count == 0')
        raise CmdException

    vec = cpv.normalize(vec)
    center = cpv.scale(center, 1./count)
github speleo3 / pymol-psico / psico / orientation.py View on Github external
def _vec_sum(vec_list):
    # this is the same as
    # return numpy.array(vec_list).sum(0).tolist()
    vec = cpv.get_null()
    for x in vec_list:
        vec = cpv.add(vec, x)
    return vec
github Pymol-Scripts / Pymol-script-repo / OLD / structural_biology_scripts / AngleBetweenHelices.py View on Github external
secondary structure.
    Averages direction of N(i)->C(i) pseudo bonds.
 
USAGE
 
    loop_orientation selection [, visualize]
 
SEE ALSO
 
    helix_orientation
    '''
    visualize, quiet = int(visualize), int(quiet)
    stored.x = dict()
    cmd.iterate_state(-1, '(%s) and name N+C' % (selection),
            'stored.x.setdefault(chain + resi, dict())[name] = x,y,z')
    vec = cpv.get_null()
    count = 0
    for x in stored.x.itervalues():
        if 'C' in x and 'N' in x:
            vec = cpv.add(vec, cpv.sub(x['C'], x['N']))
            count += 1
    if count == 0:
        print 'warning: count == 0'
        raise CmdException
    vec = cpv.normalize(vec)
    return _common_orientation(selection, vec, visualize, quiet)
github Pymol-Scripts / Pymol-script-repo / centroid.py View on Github external
def centroid(selection='all', center=0, quiet=1):

    model = cmd.get_model(selection)
    nAtom = len(model.atom)

    centroid = cpv.get_null()

    for a in model.atom:
        centroid = cpv.add(centroid, a.coord)
    centroid = cpv.scale(centroid, 1. / nAtom)

    if not int(quiet):
        print ' centroid: [%8.3f,%8.3f,%8.3f]' % tuple(centroid)

    if int(center):
        cmd.alter_state(1, selection, "(x,y,z)=sub((x,y,z), centroid)",
                        space={'centroid': centroid, 'sub': cpv.sub})

    return centroid