Ejemplo n.º 1
0
    # Get a list of dihedrals we are interested in for this residue.
    dihedrals = sorted([
        k[1] for k in amino.def_parameters
        if k[0] == amino_acid and not ('C' in k[1] and 'CA' in k[1])
    ])

    # For each pair of atoms in a dihedral, find their highest-ranked neighbours for defining the dihedral angle.
    dihedral_atoms = {}
    dihedral_moving_atoms = {}
    for atom_pair in dihedrals:
        atom0 = next(n for n in mol_graph.atoms.nodes()
                     if n.name == atom_pair[0] and n.residue == res)
        atom1 = next(n for n in mol_graph.atoms.nodes()
                     if n.name == atom_pair[1] and n.residue == res)
        atom_1 = next(
            atom for atom in chir.chiral_order(mol_graph.atoms, atom0, depth=2)
            if atom != atom1)
        atom2 = next(
            atom for atom in chir.chiral_order(mol_graph.atoms, atom1, depth=2)
            if atom != atom0)
        dihedral_atoms[(atom0.name, atom1.name)] = (atom_1, atom0, atom1,
                                                    atom2)
        # Now find the moving atoms by breaking the dihedral bond and choosing the subgraph containing atom1.
        mol_graph.atoms.remove_edge(atom0, atom1)
        dihedral_moving_atoms[(atom0.name,
                               atom1.name)] = nx.node_connected_component(
                                   mol_graph.atoms, atom1)
        mol_graph.atoms.add_edge(atom0, atom1)

    # Loop through the possible dihedral atom pairs for the amino acid.
    # i is going to form part of the CArray name
Ejemplo n.º 2
0
    mol_graph = ra.create_atoms_and_residues(topology)

    # Get the residue name for the first residue.
    res = next(residue for residue in mol_graph.residues.nodes() if residue.index == 1)

    # Get a list of dihedrals we are interested in for this residue.
    dihedrals = sorted([k[1] for k in amino.def_parameters if k[0] == amino_acid
                                                              and not ('C' in k[1] and 'CA' in k[1])])

    # For each pair of atoms in a dihedral, find their highest-ranked neighbours for defining the dihedral angle.
    dihedral_atoms = {}
    dihedral_moving_atoms = {}
    for atom_pair in dihedrals:
        atom0 = next(n for n in mol_graph.atoms.nodes() if n.name == atom_pair[0] and n.residue == res)
        atom1 = next(n for n in mol_graph.atoms.nodes() if n.name == atom_pair[1] and n.residue == res)
        atom_1 = next(atom for atom in chir.chiral_order(mol_graph.atoms, atom0, depth=2) if atom != atom1)
        atom2 = next(atom for atom in chir.chiral_order(mol_graph.atoms, atom1, depth=2) if atom != atom0)
        dihedral_atoms[(atom0.name, atom1.name)] = (atom_1, atom0, atom1, atom2)
        # Now find the moving atoms by breaking the dihedral bond and choosing the subgraph containing atom1.
        mol_graph.atoms.remove_edge(atom0, atom1)
        dihedral_moving_atoms[(atom0.name, atom1.name)] = nx.node_connected_component(mol_graph.atoms, atom1)
        mol_graph.atoms.add_edge(atom0, atom1)


    # Loop through the possible dihedral atom pairs for the amino acid.
    # i is going to form part of the CArray name
    for i, dihedral in enumerate(dihedrals):
        moving_atom_names = [atom.name for atom in dihedral_moving_atoms[dihedral]]
        carray_name = 'carray_{res}_{ind}'.format(res=amino_acid, ind=str(i))
        print amino_acid, i, dihedral, moving_atom_names, carray_name
        ca = fileh.create_carray(root.MovingAtomsArrays,
Ejemplo n.º 3
0
    dihedral_bonds[res] = [bond[1] for bond in amino.def_parameters.keys() if bond[0] == res.name]
    # print chir.chiral_order(mol_graph.atoms, dihedral_bonds[res][0][0], depth=2)
print dihedral_bonds

# Define all the dihedrals
# Get the atom node in the networkx graph
def get_residue_atom_node(atom_name, residue, graph):
    return next(node for node in graph.nodes() if node.name == atom_name and node.residue == residue)


dihedrals = {}
for res in (res1, res2, res3):
    for atom_pair in dihedral_bonds[res]:
        atom0 = get_residue_atom_node(atom_pair[0], res, mol_graph.atoms)
        atom1 = get_residue_atom_node(atom_pair[1], res, mol_graph.atoms)
        atom_1 = [atom for atom in chir.chiral_order(mol_graph.atoms, atom0, depth=2) if atom != atom1][0]
        atom2 = [atom for atom in chir.chiral_order(mol_graph.atoms, atom1, depth=2) if atom != atom0][0]
        dihedrals[(res, atom0, atom1)] = (atom_1, atom0, atom1, atom2)

# print dihedrals

# Read coords and energies from the lowest file
class LowestFile(object):
    """
    Reads in a lowest file and outputs a dictionary of structure coords, keyed by energy.
    """

    def __init__(self, input_filename):
        self.structures = self.read(input_filename)
        self.structures = self.normalise_structures(self.structures)