예제 #1
0
def traj_dihedral_calc(ag, dih_list, max_sep, min_sep):
    """
    This function loops over a trajectory to calculate the dihedral of a set
    of atoms supplied in dih_list
    """
    sep_range = max_sep - min_sep
    
    ag_temp = ag
    time_range = ag_temp.trajectory.totaltime - ag_temp.trajectory.time
    
    sep_rate = sep_range/time_range
    
    for ts in ag.trajectory:
        TPA = ag.selectAtoms("resname TPA")
        #Select the 1st, 2nd, 3rd and 4th atoms in the dihedral groups
        r1_TPA = TPA[dih_list[:,0]].positions
        r2_TPA = TPA[dih_list[:,1]].positions
        r3_TPA = TPA[dih_list[:,2]].positions
        r4_TPA = TPA[dih_list[:,3]].positions

        dih_angle = dihedral_calc(r1_TPA, r2_TPA, r3_TPA, r4_TPA)
        dih_angle_deg = np.rad2deg(dih_angle)

        #Calculate the separation at the corresponding ts.time step
        sep = max_sep - sep_rate * ts.time
    
        dih_file.write(str(ts.time) + " " + str(sep) + " ")
    
        for angle in range(np.shape(dih_angle_deg)[0]):
                    dih_file.write(str(dih_angle_deg[angle]) + "  ")
    
        dih_file.write("\n") 

    return dih_angle_deg
예제 #2
0
def single_frame_dihedral_calc(ag, dih_list):
    """
    This function calculates the dihedral angles for the list in dih_list for
    a single frame of a simulation
    """
    TPA = u.selectAtoms("resname TPA")
    #Select the 1st, 2nd, 3rd and 4th atoms in the dihedral groups
    r1_TPA = TPA[dih_list[:,0]].positions
    r2_TPA = TPA[dih_list[:,1]].positions
    r3_TPA = TPA[dih_list[:,2]].positions
    r4_TPA = TPA[dih_list[:,3]].positions


    dih_angle = dihedral_calc(r1_TPA, r2_TPA, r3_TPA, r4_TPA)
    dih_angle_deg = np.rad2deg(dih_angle) 
        
    for angle in range(np.shape(dih_angle_deg)[0]):
        dih_file.write(str(dih_angle_deg[angle]) + "  ")
    
    dih_file.write("\n")    

    return dih_angle_deg