/* * ligand/joining-residues.cc * * Copyright 2018 by Medical Research Council * Author: Paul Emsley * * This file is part of Coot * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation; either version 3 of the License, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copies of the GNU General Public License and * the GNU Lesser General Public License along with this program; if not, * write to the Free Software Foundation, Inc., 51 Franklin Street, * Fifth Floor, Boston, MA, 02110-1301, USA. * See http://www.gnu.org/licenses/ * */ #include "residue_by_phi_psi.hh" // psi_conditional is meaningful when offset == 1 // phi_conditional is meaningful when offset == -1 (otherwise not, of course) // coot::minimol::fragment coot::residue_by_phi_psi::make_2_res_joining_frag_new(const std::string &chain_id, const connecting_atoms_t ¤t_atom_positions, const double &phi_conditional, const double &psi_conditional, const phi_psi_t &pp1, const phi_psi_t &pp2, int seqnum, int offset // + or - 1 ) const { if (offset == 1) { return make_2_res_joining_frag_new_building_forwards(chain_id, current_atom_positions, psi_conditional, pp1, pp2, seqnum); } else { return make_2_res_joining_frag_new_building_backwards(chain_id, current_atom_positions, phi_conditional, pp1, pp2, seqnum); } } coot::minimol::fragment coot::residue_by_phi_psi::make_2_res_joining_frag_new_building_forwards(const std::string &chain_id, const connecting_atoms_t ¤t_res_pos_in, const double &psi_conditional, const phi_psi_t &pp1, const phi_psi_t &pp2, int seqnum) const { bool debug = false; minimol::fragment frag(chain_id); // we need edit the postions of the reference atoms to add a bit of (useful) jitter connecting_atoms_t current_res_pos = current_res_pos_in; // refs! clipper::Coord_orth ¤t_n = current_res_pos.N_pos; clipper::Coord_orth ¤t_ca = current_res_pos.CA_pos; // add a bit of jitter double rand_lim = 0.25; // 0.1 -> 6.2, 0.3 -> 6.4 ; 0.5 -> 5.9; 0.25 -> 6.4 // I wonder what these numbers are. current_n += clipper::Coord_orth(rand_lim * (util::random()/float (RAND_MAX) - 0.5), rand_lim * (util::random()/float (RAND_MAX) - 0.5), rand_lim * (util::random()/float (RAND_MAX) - 0.5)); current_ca += clipper::Coord_orth(rand_lim * (util::random()/float (RAND_MAX) - 0.5), rand_lim * (util::random()/float (RAND_MAX) - 0.5), rand_lim * (util::random()/float (RAND_MAX) - 0.5)); // in radians std::pair phi_current = current_res_pos.get_phi(); // Check if we have 2 residues (this one and the one upstream) on our starting residue, which // gives us a phi, from which we can make a condtional psi. // // If we don't have 2 residues, then do a normal selection of random phi,psi if (phi_current.first) { minimol::residue res1 = construct_next_res_from_rama_angles(pp1.phi, psi_conditional, pp1.tau, seqnum + 1, current_res_pos); connecting_atoms_t just_built_res(res1[" N "].pos, res1[" CA "].pos, res1[" C "].pos); just_built_res.set_upstream_C(current_res_pos.C_pos); minimol::residue res2 = construct_next_res_from_rama_angles(pp2.phi, pp1.psi, pp2.tau, seqnum + 2, just_built_res); // now set set the occupancy of res2 to 0.5 or so, because we care more that the // first residue is in density for (unsigned int iat=0; iat psi_current = current_res_pos.get_psi(); if (psi_current.first) { // add a bit of jitter double rand_lim = 0.25; current_n += clipper::Coord_orth(rand_lim * (util::random()/float (RAND_MAX) - 0.5), rand_lim * (util::random()/float (RAND_MAX) - 0.5), rand_lim * (util::random()/float (RAND_MAX) - 0.5)); current_ca += clipper::Coord_orth(rand_lim * (util::random()/float (RAND_MAX) - 0.5), rand_lim * (util::random()/float (RAND_MAX) - 0.5), rand_lim * (util::random()/float (RAND_MAX) - 0.5)); double phi_conditional_deg = clipper::Util::rad2d(get_phi_by_random_given_psi(psi_current.second, rama)); minimol::residue res1 = construct_prev_res_from_rama_angles(phi_conditional_deg, pp1.psi, pp1.tau, seqnum - 1, current_res_pos); connecting_atoms_t just_built_res(res1[" N "].pos, res1[" CA "].pos, res1[" C "].pos); just_built_res.set_downstream_N(current_res_pos.N_pos); minimol::residue res2 = construct_prev_res_from_rama_angles(pp1.phi, pp2.psi, pp2.tau, seqnum - 2, just_built_res); for (unsigned int iat=0; iat