Exemple #1
0
def test_shape_when_none():
    t = md.load(get_fn('frame0.h5'))
    np.hstack((md.compute_phi(t)[1],
               md.compute_psi(t)[1],
               md.compute_chi1(t)[1],
               md.compute_chi2(t)[1],
               md.compute_chi3(t)[1],
               md.compute_chi1(t)[1],
               md.compute_omega(t)[1]))
Exemple #2
0
def test_shape_when_none():
    t = md.load(get_fn('frame0.h5'))
    np.hstack((md.compute_phi(t)[1],
               md.compute_psi(t)[1],
               md.compute_chi1(t)[1],
               md.compute_chi2(t)[1],
               md.compute_chi3(t)[1],
               md.compute_chi1(t)[1],
               md.compute_omega(t)[1]))
def dataset_chi(traj):
    dataset = []
    indices, angles1 = md.compute_chi1(traj)
    indices, angles2 = md.compute_chi2(traj)
    indices, angles3 = md.compute_chi3(traj)
    #indices,angles4 = md.compute_chi4(traj)
    #print(angles1)
    #print(type(angles1))
    #print(len(angles1))
    angles = np.concatenate((angles1, angles2, angles3), axis=1)
    dataset.append(angles)
    print("Done constructing dataset using chi angles")
    return dataset
Exemple #4
0
    def __init__(self, mdtraj_trajectory):
        WrappedPose.__init__(self)
        if md is None:
            print(
                "MDTrajPoseWrapper requires the mdtraj library to be installed"
            )
            raise ImportError

        assert isinstance(mdtraj_trajectory, md.Trajectory)
        assert mdtraj_trajectory.n_frames == 1
        self.trajectory = mdtraj_trajectory

        # RADIANS:
        self.phi_atoms, self.phis = md.compute_phi(self.trajectory)
        self.psi_atoms, self.psis = md.compute_psi(self.trajectory)

        self.chis = [None, None, None, None,
                     None]  # Adding zero element just to make indexing easier
        self.chi_atoms = [None, None, None, None, None]

        self.chi_atoms[1], self.chis[1] = md.compute_chi1(self.trajectory)
        self.chi_atoms[2], self.chis[2] = md.compute_chi2(self.trajectory)
        self.chi_atoms[3], self.chis[3] = md.compute_chi3(self.trajectory)
        self.chi_atoms[4], self.chis[4] = md.compute_chi4(self.trajectory)
Exemple #5
0
sys.stdout.flush()

# define a featurizer
feat = coor.featurizer(topology)

# define basis functions: heavy-atom contact distances, heavy atom coordinates, all torsions
print('define basis functions: heavy-atom contact distances, heavy atom coordinates, all torsions, inverse distances')
print('\n')
sys.stdout.flush()

featurizer = coor.featurizer(topology)
featurizer.add_residue_mindist(residue_pairs='all', scheme='closest-heavy')
featurizer.add_all()
featurizer.add_backbone_torsions(cossin=True)
featurizer.add_chi1_torsions(cossin=True)
indx = md.compute_chi2(traj)[0]
featurizer.add_dihedrals(indx, cossin=True)
indx = md.compute_chi3(traj)[0]
featurizer.add_dihedrals(indx, cossin=True)
indx = md.compute_chi4(traj)[0]
featurizer.add_dihedrals(indx, cossin=True)
indx = md.compute_omega(traj)[0]
featurizer.add_dihedrals(indx, cossin=True)
indx = md.compute_contacts(traj,contacts='all',scheme='closest-heavy')[1]
featurizer.add_custom_func(one_over_d, np.shape(indx)[0])

print(featurizer.describe())
print(featurizer.dimension())
sys.stdout.flush()

# use featurizer to read in trajectories
Exemple #6
0
def traj_dihedral_classes(trajin, dihedral_classes):
    #
    dihedrals_temp = None
    dihedral_ids_temp = None

    for dihedral_class in dihedral_classes:
        #
        #print("Loading {:s} angles...".format(dihedral_class))

        if re.match("phi", dihedral_class):
            #
            phi_atoms, phi = md.compute_phi(trajin)

            if dihedrals_temp is None:
                #
                dihedrals_temp = np.cos(phi)

                dihedral_ids_temp = extract_res_info(trajin.top, phi_atoms,
                                                     "phi")
            #
            else:
                #
                dihedrals_temp = np.append(dihedrals_temp, np.cos(phi), axis=1)

                dihedral_ids_temp = np.append(dihedral_ids_temp,
                                              extract_res_info(
                                                  trajin.top, phi_atoms,
                                                  "phi"),
                                              axis=0)
            #
        #

        if re.match("psi", dihedral_class):
            #
            psi_atoms, psi = md.compute_psi(trajin)

            if dihedrals_temp is None:
                #
                dihedrals_temp = np.sin(psi)

                dihedral_ids_temp = extract_res_info(trajin.top, psi_atoms,
                                                     "psi")
            #
            else:
                #
                dihedrals_temp = np.append(dihedrals_temp, np.sin(psi), axis=1)

                dihedral_ids_temp = np.append(dihedral_ids_temp,
                                              extract_res_info(
                                                  trajin.top, psi_atoms,
                                                  "psi"),
                                              axis=0)
            #
        #

        if re.match("chi1", dihedral_class):
            #
            chi1_atoms, chi1 = md.compute_chi1(trajin)

            if dihedrals_temp is None:
                #
                dihedrals_temp = np.sin(chi1)

                dihedral_ids_temp = extract_res_info(trajin.top, chi1_atoms,
                                                     "chi1")
            #
            else:
                #
                dihedrals_temp = np.append(dihedrals_temp,
                                           np.sin(chi1),
                                           axis=1)

                dihedral_ids_temp = np.append(dihedral_ids_temp,
                                              extract_res_info(
                                                  trajin.top, chi1_atoms,
                                                  "chi1"),
                                              axis=0)
            #
        #

        if re.match("chi2", dihedral_class):
            #
            chi2_atoms, chi2 = md.compute_chi2(trajin)

            if dihedrals_temp is None:
                #
                dihedrals_temp = np.sin(chi2)

                dihedral_ids_temp = extract_res_info(trajin.top, chi2_atoms,
                                                     "chi2")
            #
            else:
                #
                dihedrals_temp = np.append(dihedrals_temp,
                                           np.sin(chi2),
                                           axis=1)

                dihedral_ids_temp = np.append(dihedral_ids_temp,
                                              extract_res_info(
                                                  trajin.top, chi2_atoms,
                                                  "chi2"),
                                              axis=0)
            #
        #

        if re.match("chi3", dihedral_class):
            #
            chi3_atoms, chi3 = md.compute_chi3(trajin)

            if dihedrals_temp is None:
                #
                dihedrals_temp = np.sin(chi3)

                dihedral_ids_temp = extract_res_info(trajin.top, chi3_atoms,
                                                     "chi3")
            #
            else:
                #
                dihedrals_temp = np.append(dihedrals_temp,
                                           np.sin(chi3),
                                           axis=1)

                dihedral_ids_temp = np.append(dihedral_ids_temp,
                                              extract_res_info(
                                                  trajin.top, chi3_atoms,
                                                  "chi3"),
                                              axis=0)
            #
        #

        if re.match("chi4", dihedral_class):
            #
            chi4_atoms, chi4 = md.compute_chi4(trajin)

            if dihedrals_temp is None:
                #
                dihedrals_temp = np.sin(chi4)

                dihedral_ids_temp = extract_res_info(trajin.top, chi4_atoms,
                                                     "chi4")
            #
            else:
                #
                dihedrals_temp = np.append(dihedrals_temp,
                                           np.sin(chi4),
                                           axis=1)

                dihedral_ids_temp = np.append(dihedral_ids_temp,
                                              extract_res_info(
                                                  trajin.top, chi4_atoms,
                                                  "chi4"),
                                              axis=0)
            #
        #

        if dihedral_class is None:
            #
            raise Exception(
                "Feature format \"{:s}\" is invalid in a dihedral class measurement context."
                .format(dihedral_class))
        #
    #

    return (dihedrals_temp, dihedral_ids_temp)
files = open(main_files, 'w')
char = ''
for frame_cur in range(0, frame):
    for index in range(0, angle_mount):
        phi_cur = phi[1][frame_cur][index]
        psi_cur = psi[1][frame_cur][index]
        char = '%10.6lf %10.6lf %s' % (phi_cur, psi_cur, char)
    char = '%s \n' % (char)
    files.write(char)
    char = ''
files.close()

files = open(side_files, 'w')
chi1 = md.compute_chi1(traj)
chi2 = md.compute_chi2(traj)
chi3 = md.compute_chi3(traj)
chi4 = md.compute_chi4(traj)
for frame_cur in range(0, frame):
    for index in range(0, len(chi1[0])):
        chi_cur = chi1[1][frame_cur][index]
        char = '%10.6lf %s' % (chi_cur, char)
    for index in range(0, len(chi2[0])):
        chi_cur = chi2[1][frame_cur][index]
        char = '%10.6lf %s' % (chi_cur, char)
    for index in range(0, len(chi3[0])):
        chi_cur = chi3[1][frame_cur][index]
        char = '%10.6lf %s' % (chi_cur, char)
    for index in range(0, len(chi4[0])):
        chi_cur = chi4[1][frame_cur][index]
        char = '%10.6lf %s' % (chi_cur, char)