Beispiel #1
0
def test_asa_0():
    conf = get("native.pdb")
    n_atoms = conf["XYZList"].shape[1]
    angle_indices = np.array(list(itertools.combinations(range(n_atoms), 3)))

    a1 = bond_angles(conf["XYZList"], angle_indices)
    a2 = __bond_angles(conf["XYZList"], angle_indices)
    eq(a1, a2)
Beispiel #2
0
def get_redundant_internal_coordinates(trajectory, **kwargs):
    """Compute internal coordinates from the cartesian coordinates
    
    This extracts all of the bond lengths, bond angles and dihedral angles
    from every frame in a trajectory.

    Parameters
    ----------
    trajectory : msmbuilder.Trajectory
        Trajectory object containing the internal coordinates

    Additional Parameters
    ---------------------
    ibonds : np.ndarray, optional, shape[n_bonds, 2], dtype=int
        Each row gives the indices of two atoms involved in a bond
    iangles : np.ndarray, optional shape[n_angles, 3], dtype=int
        Each row gives the indices of three atoms which together make an angle
    idihedrals : np.ndarray, optional, shape[n_dihedrals, 4], dtype=int
        Each row gives the indices of the four atoms which together make a
        dihedral
    
    Notes
    -----
    ibonds, iangles, and idihedrals will be computed usig the first
    frame in the trajectory, if not supplied
    
    Returns
    -------
    internal_coords : np.ndarray, shape=[n_frames, n_bonds+n_angles+n_dihedrals]
        All of the internal coordinates collected into a big array, such that
        internal_coords[i,j] gives the jth coordinate for the ith frame.
    """
    
    if 'ibonds' in kwargs and  'iangles' in kwargs and 'idihedrals' in kwargs:
        ibonds = kwargs['ibonds']
        iangles = kwargs['iangles']
        idihedrals = kwargs['idihedrals']
    else:
        ibonds, iangles, idihedrals = get_connectivity(trajectory)
    
    # convert everything to the right shape and C ordering, since
    # all of these methods are in C and are going to need things to be
    # the right type. The methods will all do a copy for things that
    # aren't the right type, but hopefully we can only do the copy once
    # instead of three times if xyzlist really does need to be reordered
    # in memory
    
    xyzlist = np.array(trajectory['XYZList'], dtype=np.float32, order='c')
    ibonds = np.array(ibonds, dtype=np.int32, order='c')
    iangles = np.array(iangles, dtype=np.int32, order='c')
    idihedrals = np.array(idihedrals, dtype=np.int32, order='c')
    
    b = atom_distances(xyzlist, ibonds)
    a = bond_angles(xyzlist, iangles)
    d = compute_dihedrals(xyzlist, idihedrals, degrees=False)
    
    return np.hstack((b, a, d))