def _calculate_O_coordinates(position_CA, position_C, position_N, residue): """ Calculate coordinates for the O atom. @param position_CA: Coordinates of the CA atom @type position_CA: Vector @param position_C: Coordinates of the C atom @type position_C: Vector @param position_N: Coordinates of the N atom @type position_N: Vector @param residue: Amino acid. @type residue: str @rtype: Vector @return: The calculated O position """ angle_O_C_N = ANGLE_O_C_N[residue] * pi / 180 bond_length_C_N = BOND_LENGTH_C_N[residue] D = Vector( BOND_LENGTH_C_O * cos(angle_O_C_N), BOND_LENGTH_C_O * sin(angle_O_C_N), 0) bc = (position_N - position_C) / bond_length_C_N n = ((position_C - position_CA) ** bc).normalized() nbc = bc ** n basis_change = numpy.array((bc, nbc, n)).transpose() return D.left_multiply(basis_change) + position_C
def _place_backbone_atoms(coords, angles, cis, aa_seq): """ Place atoms that are in the backbone. @param coords: Array where the coordinates are to be saved. @type coords: numpy.array @param angles: Angles. @type angles: list(float) @param cis: Conformation of the peptide bonds. @type cis: list(int) @param aa_seq: Amino acid sequence. @type aa_seq: list(int) """ for i in xrange(len(aa_seq)): current_res = index_to_three(aa_seq[i]) current_atom = 'N' prev_atom = 'C' prev_prev_atom = 'CA' for j in xrange(backbone_atoms): index = i * atoms_per_residue + j if i == 0 and current_atom == 'N': coords[:,index] = 0 elif i == 0 and current_atom == 'CA': coords[:,index] = 0 coords[X][index] = get_bond_length( current_atom, prev_atom, current_res) else: v1 = _create_vector(coords, index, j, 1) v2 = _create_vector(coords, index, j, 2) if i == 0 and current_atom == 'C': v3 = Vector(0, -1.0, 0) else: v3 = _create_vector(coords, index, j, 3) angle = get_bond_angle( prev_prev_atom, prev_atom, current_atom, current_res) dihedral = _calculate_dihedral(prev_atom, angles, cis, i) bond_length = get_bond_length(prev_atom, current_atom, current_res) bond_length_prev = get_bond_length( prev_prev_atom, prev_atom, current_res) D = Vector( bond_length * cos(pi - angle), bond_length * cos(pi - dihedral) * sin(pi - angle), bond_length * sin(pi - dihedral) * sin(pi - angle), ) bc = (v1 - v2) / bond_length_prev n = ((v1 - v3) ** bc).normalized() nbc = bc ** n basis_change = numpy.array((bc, nbc, n)).transpose() D = D.left_multiply(basis_change) + v1 coords[:,index] = D prev_prev_atom = prev_atom prev_atom = current_atom current_atom = ATOMS[(ATOMS.index(current_atom) + 1) % backbone_atoms]