Ejemplo n.º 1
0
    def get_coords(self, row, parser, chain, length=9):
        backbone_atoms = self.params['backbone_atoms']
        cb = self.params['cb']
        stored_atoms = self.params['stored_atoms']
        modelid = row['modelid']
        structure = parser.get_structure(modelid, shared.strip_h(row['path']))
        chainstruc = structure[0][chain]
        # Don't enforce length check if length is None
        if length is not None:
            if len(chainstruc) != length:
                raise LoadModelScoresError("%s has %s residues, expected %s" %
                                           (modelid, len(chainstruc), length))
        coordinates = list()
        for x, residue in enumerate(chainstruc):
            het, resi, icode = residue.id
            resname = residue.resname
            if het.strip(): continue
            if icode.strip():
                raise LoadModelScoresError("Can't handle PDB insertion code")
            residue_coordinates = list()
            # Load atoms
            atom_coords = {
                name: residue[name].coord
                for name in backbone_atoms
            }
            if resname == "GLY":
                # Generate virtual CB for GLY
                vectors = {
                    name: residue[name].get_vector()
                    for name in backbone_atoms
                }
                # Center
                n = vectors['N'] - vectors['CA']
                c = vectors['C'] - vectors['CA']
                # Find rotation axis around N for CA-C vector
                rot = PDB.rotaxis(-np.pi * 120.0 / 180.0, c)
                # Apply rotation to CA-N vector
                cb_at_origin = n.left_multiply(rot)
                # Put on top of CA atom
                CB = cb_at_origin + vectors['CA']
                atom_coords[cb] = CB.get_array()
            else:
                atom_coords[cb] = residue[cb].coord

            for name in stored_atoms:
                coords = [float(c) for c in atom_coords[name]]
                residue_coordinates.append(coords)

            assert len(residue_coordinates) == len(stored_atoms)
            coordinates.extend(residue_coordinates)

        if not coordinates:
            raise LoadModelScoresError("No coordinates")
        coordinates = json.dumps(coordinates)

        row = dict(modelid=modelid, di=row['di'], coordinates=coordinates)
        return pd.Series(row)
Ejemplo n.º 2
0
def generate_Cb(residue):
    '''
	creates phantom Cb atom
	'''
    n = residue['N'].get_vector()
    c = residue['C'].get_vector()
    ca = residue['CA'].get_vector()
    n = n - ca
    c = c - ca
    rot = bp.rotaxis(-np.pi * 120.0 / 180.0, c)
    cb_at_origin = n.left_multiply(rot)
    return np.array(list(cb_at_origin + ca))
Ejemplo n.º 3
0
def rotate_throught_bond(bond, angle, rotated_atoms, atoms_fixed):
    # Obtain the axis that we want to use as reference for the rotation
    vector = bond.getCoords()[0] - bond.getCoords()[1]
    vector = bio.Vector(vector)
    # Obtain the rotation matrix for the vector (axis) and the angle (theta)
    rot_mat = bio.rotaxis(angle, vector)
    new_coords = []
    for coords in rotated_atoms.getCoords():
        new_coord = np.dot(coords, rot_mat)
        new_coords.append(new_coord)
    rotated_atoms.setCoords(new_coords)
    structure_result = atoms_fixed + rotated_atoms
    return structure_result
Ejemplo n.º 4
0
def rotation_thought_axis(bond, theta, core_bond, list_of_atoms, fragment_bond,
                          core_structure, fragment_structure, pdb_complex,
                          pdb_fragment, chain_complex, chain_fragment):
    """
    Given a core molecule and a fragment, this function rotates the fragment atoms a certain theta angle around an axis
    (set by the bond).
    :param bond: Bio.PDB.Atom list composed by two elements: [heavy atom of the core, heavy atom of the fragment]
    :param theta: Rotation angle in rads.
    :param core_bond: Bio.PDB.Atom list with two elements: [heavy atom, hydrogen atom]. These two atoms have to be the
    ones participating in the bond of the core that we would like to use as linking point between core and fragment.
    :param list_of_atoms: list_of_atoms: Bio.PDB.Atom list with all the atoms of the fragment. These atoms have to contain
    coordinates.
    :param fragment_bond: Bio.PDB.Atom list with two elements: [hydrogen atom, heavy atom]. These two atoms have to be the
    ones participating in the bond of the fragment that we would like to use as linking point between fragment and core.
    :param core_structure: ProDy molecule that contain only the core ligand.
    :param fragment_structure: ProDy molecule that contain only the fragment ligand.
    :return: ProDy molecule with the core_structure and the fragment_structure rotated around the axis of the bond.
    """
    # Obtain the axis that we want to use as reference for the rotation
    vector = bond[1].get_vector() - bond[0].get_vector()
    # Obtain the rotation matrix for the vector (axis) and the angle (theta)
    rot_mat = bio.rotaxis(theta, vector)
    for atom in list_of_atoms:
        # Multiply the matrix of coordinates for the transpose of the rotation matrix to get the coordinates rotated
        atom.transform(rot_mat, (0, 0, 0))
        transform_coords_from_bio2prody(fragment_structure, list_of_atoms)
    rotated_structure, core_original_atom, fragment_original_atom = join_structures(
        core_bond,
        fragment_bond,
        core_structure,
        fragment_structure,
        pdb_complex=pdb_complex,
        pdb_fragment=pdb_fragment,
        chain_complex=chain_complex,
        chain_fragment=chain_fragment)
    return rotated_structure