Example #1
0
def write_chirality_file(input_filename, output_filename):
    molecule = ra.parse_topology_file(input_filename)
    atoms = molecule.atoms
    chiral_centres = get_chiral_sets(atoms)
    with open(output_filename, "w") as output_file:
        for atom in sorted(chiral_centres.keys(), cmp=lambda x, y: cmp(x.index, y.index)):
            # Write out the list of chiral atoms and their CIP-ranked neighbours.
            output_string = "{0:>8d}{1:>8d}{2:>8d}{3:>8d}{4:>8d}\n".format(atom.index + 1,
                                                                           *[other_atom.index + 1 for other_atom in
                                                                             chiral_centres[atom]])
            output_file.write(output_string)
Example #2
0
def write_chirality_file(input_filename, output_filename):
    molecule = ra.parse_topology_file(input_filename)
    atoms = molecule.atoms
    chiral_centres = get_chiral_sets(atoms)
    with open(output_filename, "w") as output_file:
        for atom in sorted(chiral_centres.keys(),
                           cmp=lambda x, y: cmp(x.index, y.index)):
            # Write out the list of chiral atoms and their CIP-ranked neighbours.
            output_string = "{0:>8d}{1:>8d}{2:>8d}{3:>8d}{4:>8d}\n".format(
                atom.index + 1,
                *[other_atom.index + 1 for other_atom in chiral_centres[atom]])
            output_file.write(output_string)
Example #3
0
    angles = []
    # For centre atom C and atoms ordered I, J, K and L
    # Calculate dihedral of I-C-L-J
    for atom_list in chiral_centres:
        b1 = coords[atom_list[0]] - coords[atom_list[1]]
        b2 = coords[atom_list[4]] - coords[atom_list[0]]
        b3 = coords[atom_list[2]] - coords[atom_list[4]]
        b1xb2 = np.cross(b1, b2)
        b2xb3 = np.cross(b2, b3)
        b1xb2_x_b2xb3 = np.cross(b1xb2, b2xb3)
        b2_norm = b2 / np.linalg.norm(b2)
        angles.append(
            np.arctan2(np.dot(b1xb2_x_b2xb3, b2_norm), np.dot(b1xb2, b2xb3)))
    return angles


if __name__ == "__main__":
    import rotamer.io.gmin
    molecule = ra.parse_topology_file("../library/coords.prmtop")
    atoms = molecule.atoms
    chiral_centres = get_chiral_sets(atoms)
    chiral_centres_list = [[k.index] + [val.index for val in v]
                           for k, v in chiral_centres.items()]
    # Starting coords
    coords = rotamer.io.amber.read_amber_restart("../library/coords.inpcrd")
    print calculate_chirality(coords.reshape((-1, 3)), chiral_centres_list)
    # Lowest file
    coords = rotamer.io.gmin.read_lowest("../library/lowest")[0]["coords"]
    print calculate_chirality(coords.reshape((-1, 3)), chiral_centres_list)
Example #4
0
def calculate_chirality(coords, chiral_centres):
    import numpy as np

    angles = []
    # For centre atom C and atoms ordered I, J, K and L
    # Calculate dihedral of I-C-L-J
    for atom_list in chiral_centres:
        b1 = coords[atom_list[0]] - coords[atom_list[1]]
        b2 = coords[atom_list[4]] - coords[atom_list[0]]
        b3 = coords[atom_list[2]] - coords[atom_list[4]]
        b1xb2 = np.cross(b1, b2)
        b2xb3 = np.cross(b2, b3)
        b1xb2_x_b2xb3 = np.cross(b1xb2, b2xb3)
        b2_norm = b2 / np.linalg.norm(b2)
        angles.append(np.arctan2(np.dot(b1xb2_x_b2xb3, b2_norm), np.dot(b1xb2, b2xb3)))
    return angles

if __name__ == "__main__":
    import rotamer.io.gmin
    molecule = ra.parse_topology_file("../library/coords.prmtop")
    atoms = molecule.atoms
    chiral_centres = get_chiral_sets(atoms)
    chiral_centres_list = [[k.index] + [val.index for val in v] for k, v in chiral_centres.items()]
    # Starting coords
    coords = rotamer.io.amber.read_amber_restart("../library/coords.inpcrd")
    print calculate_chirality(coords.reshape((-1, 3)), chiral_centres_list)
    # Lowest file
    coords = rotamer.io.gmin.read_lowest("../library/lowest")[0]["coords"]
    print calculate_chirality(coords.reshape((-1, 3)), chiral_centres_list)