def read_coords(self, inpcrd_filename):
     """ Reads coordinates from a file into the Atoms of the Molecule. """
     coords = np.array(read_amber_restart(inpcrd_filename)).reshape((-1, 3))
     # Sanity check that there are 3 coordinates per atom
     if len(coords) != self.num_atoms():
         raise ex.RuntimeError("Incorrect number of coordinates read into molecule.")
     # Now run through the list of atoms (sorted by index) and coordinates
     for atom, xyz in itertools.izip(sorted(self.atoms.nodes(), key=op.attrgetter("index")), coords):
         atom.coords = xyz
示例#2
0
import os
import site
import sys
# Add
site.addsitedir(os.path.normpath(sys.argv[0] + "/../.."))
import rotamer.io.amber as amber_io
import rotamer.io.gmin as gmin_io

if __name__ == "__main__":
    if sys.argv[1] == "init":
        pass
    elif sys.argv[1] == "move":
        coords = amber_io.read_amber_restart(".coords_before_rotamer.rst")
        coords = coords * 100
        gmin_io.write_coords(coords, ".coords_after_rotamer.rst")
示例#3
0
    ress, maps = molecule.identify_residues()
    sc_dihedrals = []
    for k, v in map_dihedrals(ress, maps).items():
        for idx, dihedral in enumerate(v):
            k.dihedrals["chi" + str(idx + 1)] = Dihedral(dihedral)
            sc_dihedrals.append(dihedral)
    return sc_dihedrals


if __name__ == "__main__":
    import os.path
    import numpy as np

    topology_data = amber.read_topology(
        os.path.normpath("../tests/data/ARG_LYS_ASN.prmtop"))
    coords = np.array(
        read_amber_restart(
            os.path.normpath("../tests/data/ARG_LYS_ASN.inpcrd"))).reshape(
                (-1, 3))
    molecule = amber.create_molecule(topology_data)
    phi_psi_dihedrals(molecule)
    sidechain_dihedrals(molecule)
    for res in sorted(molecule.residues, key=lambda x: x.index)[1:4]:
        print "========================"
        print res
        for k, v in res.dihedrals.items():
            # print k, v.measure_dihedral(coords) * 180.0 / np.pi
            new_coords = v.set_dihedral(coords, -45.0 * np.pi / 180.0)
            print k, v.measure_dihedral(
                coords) * 180.0 / np.pi, v.measure_dihedral(
                    new_coords) * 180.0 / np.pi