| 1 | /* ideal/torsion-bonds.cc |
| 2 | * |
| 3 | * Copyright 2015 by Medical Research Council |
| 4 | * Author: Paul Emsley |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU Lesser General Public License as published |
| 8 | * by the Free Software Foundation; either version 3 of the License, or (at |
| 9 | * your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, but |
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Lesser General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License and |
| 17 | * the GNU Lesser General Public License along with this program; if not, |
| 18 | * write to the Free Software Foundation, Inc., 51 Franklin Street, |
| 19 | * Fifth Floor, Boston, MA, 02110-1301, USA. |
| 20 | */ |
| 21 | |
| 22 | #include <algorithm> |
| 23 | #include <cstdlib> |
| 24 | |
| 25 | #ifdef USE_BACKWARD |
| 26 | #include <utils/backward.hpp> |
| 27 | #endif |
| 28 | |
| 29 | #include "simple-restraint.hh"cxx . . $ `<file>/ideal/simple-restraint.hh`/ |
| 30 | #include "coot-utils/coot-map-heavy.hh"cxx . . $ `<file>/coot-utils/coot-map-heavy.hh`/ |
| 31 | |
| 32 | #include "coot-utils/coot-coord-extras.hh"cxx . . $ `<file>/coot-utils/coot-coord-extras.hh`/ |
| 33 | #include "coot-utils/contact-info.hh"cxx . . $ `<file>/coot-utils/contact-info.hh`/ |
| 34 | #include "coot-utils/atom-tree.hh"cxx . . $ `<file>/coot-utils/atom-tree.hh`/ |
| 35 | |
| 36 | #include "torsion-bonds.hh"cxx . . $ `<file>/ideal/torsion-bonds.hh`/ |
| 37 | |
| 38 | #include "utils/logging.hh"cxx . . $ `<file>/utils/logging.hh`/ |
| 39 | extern loggingcxx . . $ logging# loggercxx . . $ logger.; |
| 40 | |
| 41 | |
| 42 | // this can throw an exception |
| 43 | // |
| 44 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *, mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *> > |
| 45 | cootcxx . . $ coot/::torsionable_bondscxx . . $ coot/torsionable_bonds(4f7d7044de544566).(int imol, mmdbcxx . . $ mmdb/::Managercxx . . $ mmdb/Manager# *mol, mmdbcxx . . $ mmdb/::PPAtomcxx . . $ mmdb/PPAtom# atom_selection, |
| 46 | int n_selected_atoms, |
| 47 | protein_geometrycxx . . $ coot/protein_geometry# *geom_p) { |
| 48 | |
| 49 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *, mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *> > vcxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 50 | bool include_pyranose_ring_torsions_flag = false; |
| 51 | |
| 52 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *> residuescxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 53 | stdcxx . . $ std/::mapcxx . . $ std/map#<mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *, stdcxx . . $ std/::vectorcxx . . $ std/vector#<int> > atoms_in_residuecxx . . $ std/map#map(49f6e7a06ebc5aa8).; |
| 54 | // fill residues and atoms_in_residue |
| 55 | for (int i=0; i<n_selected_atoms; i++) { |
| 56 | mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *r = atom_selection[i]->residuecxx . . $ mmdb/Atom#residue.; |
| 57 | if (stdcxx . . $ std/::findcxx . . $ std/find(a92da12e15934614).(residues.begincxx . . $ std/vector#begin(55a6de06420d4903).(), residues.endcxx . . $ std/vector#end(55a6de06420d4903).(), r) ==cxx . . $ __gnu_cxx/`operator==`(d2eded1addd76ab7). residues.endcxx . . $ std/vector#end(55a6de06420d4903).()) |
| 58 | residues.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(r); |
| 59 | atoms_in_residue[cxx . . $ std/map#`operator[]`(bbd415b616967878).r].push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(i); |
| 60 | } |
| 61 | stdcxx . . $ std/::mapcxx . . $ std/map#<mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *, dictionary_residue_restraints_tcxx . . $ coot/dictionary_residue_restraints_t#> res_restraintscxx . . $ std/map#map(49f6e7a06ebc5aa8).; |
| 62 | for (unsigned int ires=0; ires<residues.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); ires++) { |
| 63 | stdcxx . . $ std/::stringcxx . . $ std/string# rn = residuescxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).ires]->GetResNamecxx . . $ mmdb/Residue#GetResName(41208ce6ca65dd58).(); |
| 64 | stdcxx . . $ std/::paircxx . . $ std/pair#<bool, dictionary_residue_restraints_tcxx . . $ coot/dictionary_residue_restraints_t#> rest = |
| 65 | geom_p->get_monomer_restraintscxx . . $ coot/protein_geometry#get_monomer_restraints(a55f7295d433dd41).(rn, imol); |
| 66 | if (! rest.firstcxx . . $ std/pair#first.) { |
| 67 | stdcxx . . $ std/::stringcxx . . $ std/string# m = "Restraints not found for type "cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).; |
| 68 | m +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). rn; |
| 69 | throw stdcxx . . $ std/::runtime_errorcxx . . $ std/runtime_error#(m); |
| 70 | } |
| 71 | res_restraints[cxx . . $ std/map#`operator[]`(bbd415b616967878).residues[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).ires]] =cxx . . $ coot/dictionary_residue_restraints_t#`operator=`(494fbb4305d2616a). rest.secondcxx . . $ std/pair#second.; |
| 72 | } |
| 73 | |
| 74 | for (unsigned int ires=0; ires<residues.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); ires++) { |
| 75 | // a coot-coord-extras function |
| 76 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *, mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *> > v_inner = |
| 77 | torsionable_bonds_monomer_internalcxx . . $ coot/torsionable_bonds_monomer_internal(e2b5ab5e6afee1c7).(residues[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).ires], |
| 78 | atom_selection, |
| 79 | n_selected_atoms, |
| 80 | include_pyranose_ring_torsions_flag, |
| 81 | geom_p); |
| 82 | // std::cout << "found " << v_inner.size() << " monomer internal torsions for " |
| 83 | // << residues[ires]->GetResName() << std::endl; |
| 84 | for (unsigned int ip=0; ip<v_inner.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); ip++) |
| 85 | v.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(v_inner[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).ip]); |
| 86 | } |
| 87 | |
| 88 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *, mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *> > v_link = |
| 89 | cootcxx . . $ coot/::torsionable_link_bondscxx . . $ coot/torsionable_link_bonds(56bd73ef7385fef2).(residuescxx . . $ std/vector#vector(a1201200cf0efa42)., mol, geom_p); |
| 90 | for (unsigned int il=0; il<v_link.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); il++) |
| 91 | v.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(v_link[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).il]); |
| 92 | |
| 93 | if (0) // debug |
| 94 | for (unsigned int ipair=0; ipair<v.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); ipair++) { |
| 95 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " torsionable bond: " |
| 96 | <<cxx . . $ coot/`operator<<`(f8fcd6198bb35afb). atom_spec_tcxx . . $ coot/atom_spec_t#(v[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).ipair].firstcxx . . $ std/pair#first.) <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " |
| 97 | <<cxx . . $ coot/`operator<<`(f8fcd6198bb35afb). atom_spec_tcxx . . $ coot/atom_spec_t#(v[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).ipair].secondcxx . . $ std/pair#second.) |
| 98 | <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 99 | } |
| 100 | |
| 101 | return vcxx . . $ std/vector#vector(6f559d22b039ccdb).; |
| 102 | } |
| 103 | |
| 104 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *, mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *> > |
| 105 | cootcxx . . $ coot/::torsionable_link_bondscxx . . $ coot/torsionable_link_bonds(56bd73ef7385fef2).(stdcxx . . $ std/::vectorcxx . . $ std/vector#<mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *> residues_in, |
| 106 | mmdbcxx . . $ mmdb/::Managercxx . . $ mmdb/Manager# *mol, protein_geometrycxx . . $ coot/protein_geometry# *geom_p) { |
| 107 | |
| 108 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *, mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *> > vcxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 109 | |
| 110 | if (! mol) |
| 111 | return vcxx . . $ std/vector#vector(6f559d22b039ccdb).; |
| 112 | |
| 113 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<bool, mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *> > residuescxx . . $ std/vector#vector(83fdeebbe0501a83).(residues_in.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).()); |
| 114 | for (unsigned int i=0; i<residues_in.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); i++) |
| 115 | residues[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i] =cxx . . $ std/pair#`operator=`(ab9ebd0b824095ec). stdcxx . . $ std/pair#pair(62e1774a2dc03c82).::paircxx . . $ std/pair#<bool, mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *> (0, residues_in[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i]); |
| 116 | |
| 117 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<atom_spec_tcxx . . $ coot/atom_spec_t#> dummy_fixed_atom_specscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 118 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<mmdbcxx . . $ mmdb/::Linkcxx . . $ mmdb/Link#> linkscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 119 | clippercxx . . $ clipper/::Xmapcxx . . $ clipper/Xmap#<float> dummy_xmapcxx . . $ clipper/Xmap#Xmap(49f6e7a06ebc5aa8).; |
| 120 | cootcxx . . $ coot/::restraints_container_tcxx . . $ coot/restraints_container_t# restraintscxx . . $ coot/restraints_container_t#restraints_container_t(77762fd271e46213).(residues, links, *geom_p, mol, dummy_fixed_atom_specs, &dummy_xmap); |
| 121 | bonded_pair_container_tcxx . . $ coot/bonded_pair_container_t# bpc = restraints.bonded_residues_from_res_veccxx . . $ coot/restraints_container_t#bonded_residues_from_res_vec(1f321814dc0d6463).(*geom_p); |
| 122 | |
| 123 | // add in the torsion: CB-CG-ND2-C1 (Psi-N) |
| 124 | // add in the torsion: CG-ND2-C1-O5 (Phi-N) |
| 125 | // t.geom.link_add_torsion("NAG-ASN", 1, 2, 2, 2, " C1 ", "ND2 ", " CG ", " CB ", 180, 40, 3, "Psi-N"); |
| 126 | // t.geom.link_add_torsion("NAG-ASN", 1, 1, 2, 2, " O5 ", " C1 ", "ND2 ", " CG ", 180, 40, 3, "Psi-N"); |
| 127 | |
| 128 | // std::cout << "found LINKR linked pairs:\n " << bpc; |
| 129 | |
| 130 | for (unsigned int i=0; i<bpc.bonded_residuescxx . . $ coot/bonded_pair_container_t#bonded_residues..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); i++) { |
| 131 | dictionary_residue_link_restraints_tcxx . . $ coot/dictionary_residue_link_restraints_t# link = geom_p->linkcxx . . $ coot/protein_geometry#link(848f04020ded7a2e).(bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].link_typecxx . . $ coot/bonded_pair_t#link_type.); |
| 132 | if (link.link_idcxx . . $ coot/dictionary_residue_link_restraints_t#link_id. != "") { |
| 133 | if (0) |
| 134 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " dictionary link found " <<cxx . . $ std/`operator<<`(88df5bef833f7f83). link.link_idcxx . . $ coot/dictionary_residue_link_restraints_t#link_id. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " with " |
| 135 | <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). link.link_bond_restraintcxx . . $ coot/dictionary_residue_link_restraints_t#link_bond_restraint..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " bond restraints and " |
| 136 | <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). link.link_torsion_restraintcxx . . $ coot/dictionary_residue_link_restraints_t#link_torsion_restraint..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " link torsions " <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 137 | |
| 138 | for (unsigned int ib=0; ib<link.link_bond_restraintcxx . . $ coot/dictionary_residue_link_restraints_t#link_bond_restraint..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); ib++) { |
| 139 | // we need to get the atoms and add them to "pairs". |
| 140 | |
| 141 | if (0) |
| 142 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " |
| 143 | <<cxx . . $ std/`operator<<`(88df5bef833f7f83). link.link_bond_restraintcxx . . $ coot/dictionary_residue_link_restraints_t#link_bond_restraint.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).ib].atom_id_1_4ccxx . . $ coot/basic_dict_restraint_t#atom_id_1_4c(219584694fe2b248).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " |
| 144 | <<cxx . . $ std/basic_ostream#`operator<<`(23b6575433a77e57). link.link_bond_restraintcxx . . $ coot/dictionary_residue_link_restraints_t#link_bond_restraint.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).ib].atom_1_comp_idcxx . . $ coot/dict_link_bond_restraint_t#atom_1_comp_id. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " to " |
| 145 | <<cxx . . $ std/`operator<<`(88df5bef833f7f83). link.link_bond_restraintcxx . . $ coot/dictionary_residue_link_restraints_t#link_bond_restraint.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).ib].atom_id_2_4ccxx . . $ coot/basic_dict_restraint_t#atom_id_2_4c(219584694fe2b248).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " |
| 146 | <<cxx . . $ std/basic_ostream#`operator<<`(23b6575433a77e57). link.link_bond_restraintcxx . . $ coot/dictionary_residue_link_restraints_t#link_bond_restraint.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).ib].atom_2_comp_idcxx . . $ coot/dict_link_bond_restraint_t#atom_2_comp_id. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " |
| 147 | <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " of " |
| 148 | <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].res_1cxx . . $ coot/bonded_pair_t#res_1.->GetResNamecxx . . $ mmdb/Residue#GetResName(41208ce6ca65dd58).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " to " |
| 149 | <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].res_2cxx . . $ coot/bonded_pair_t#res_2.->GetResNamecxx . . $ mmdb/Residue#GetResName(41208ce6ca65dd58).() |
| 150 | <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 151 | |
| 152 | mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *link_atom_1 = bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].res_1cxx . . $ coot/bonded_pair_t#res_1.->GetAtomcxx . . $ mmdb/Residue#GetAtom(aa774886b7cb8f8a).(link.link_bond_restraintcxx . . $ coot/dictionary_residue_link_restraints_t#link_bond_restraint.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).ib].atom_id_1_4ccxx . . $ coot/basic_dict_restraint_t#atom_id_1_4c(219584694fe2b248).().c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 153 | mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *link_atom_2 = bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].res_2cxx . . $ coot/bonded_pair_t#res_2.->GetAtomcxx . . $ mmdb/Residue#GetAtom(aa774886b7cb8f8a).(link.link_bond_restraintcxx . . $ coot/dictionary_residue_link_restraints_t#link_bond_restraint.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).ib].atom_id_2_4ccxx . . $ coot/basic_dict_restraint_t#atom_id_2_4c(219584694fe2b248).().c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 154 | if (link_atom_1 && link_atom_2) { |
| 155 | stdcxx . . $ std/::paircxx . . $ std/pair#<mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *, mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *> paircxx . . $ std/pair#pair(62e1774a2dc03c82).(link_atom_1, link_atom_2); |
| 156 | v.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(pair); |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | |
| 161 | // Add in link torsion atoms if they were not already added |
| 162 | // above (because they were link bond restraints) |
| 163 | // |
| 164 | for (unsigned int it=0; it<link.link_torsion_restraintcxx . . $ coot/dictionary_residue_link_restraints_t#link_torsion_restraint..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); it++) { |
| 165 | mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *res_for_at_2 = bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].res_1cxx . . $ coot/bonded_pair_t#res_1.; |
| 166 | mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *res_for_at_3 = bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].res_1cxx . . $ coot/bonded_pair_t#res_1.; |
| 167 | if (link.link_torsion_restraintcxx . . $ coot/dictionary_residue_link_restraints_t#link_torsion_restraint.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).it].atom_2_comp_idcxx . . $ coot/dict_link_torsion_restraint_t#atom_2_comp_id. == 1) res_for_at_2 = bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].res_1cxx . . $ coot/bonded_pair_t#res_1.; |
| 168 | if (link.link_torsion_restraintcxx . . $ coot/dictionary_residue_link_restraints_t#link_torsion_restraint.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).it].atom_2_comp_idcxx . . $ coot/dict_link_torsion_restraint_t#atom_2_comp_id. == 2) res_for_at_2 = bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].res_2cxx . . $ coot/bonded_pair_t#res_2.; |
| 169 | if (link.link_torsion_restraintcxx . . $ coot/dictionary_residue_link_restraints_t#link_torsion_restraint.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).it].atom_3_comp_idcxx . . $ coot/dict_link_torsion_restraint_t#atom_3_comp_id. == 1) res_for_at_3 = bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].res_1cxx . . $ coot/bonded_pair_t#res_1.; |
| 170 | if (link.link_torsion_restraintcxx . . $ coot/dictionary_residue_link_restraints_t#link_torsion_restraint.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).it].atom_3_comp_idcxx . . $ coot/dict_link_torsion_restraint_t#atom_3_comp_id. == 2) res_for_at_3 = bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].res_2cxx . . $ coot/bonded_pair_t#res_2.; |
| 171 | |
| 172 | if (res_for_at_2 && res_for_at_3) { |
| 173 | mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *link_atom_1 = res_for_at_2->GetAtomcxx . . $ mmdb/Residue#GetAtom(aa774886b7cb8f8a).(link.link_torsion_restraintcxx . . $ coot/dictionary_residue_link_restraints_t#link_torsion_restraint.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).it].atom_id_2_4ccxx . . $ coot/basic_dict_restraint_t#atom_id_2_4c(219584694fe2b248).().c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 174 | mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *link_atom_2 = res_for_at_3->GetAtomcxx . . $ mmdb/Residue#GetAtom(aa774886b7cb8f8a).(link.link_torsion_restraintcxx . . $ coot/dictionary_residue_link_restraints_t#link_torsion_restraint.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).it].atom_id_3_4ccxx . . $ coot/dict_link_torsion_restraint_t#atom_id_3_4c(219584694fe2b248).().c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 175 | |
| 176 | if (link_atom_1 && link_atom_2) { |
| 177 | stdcxx . . $ std/::paircxx . . $ std/pair#<mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *, mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *> paircxx . . $ std/pair#pair(62e1774a2dc03c82).(link_atom_1, link_atom_2); |
| 178 | if (stdcxx . . $ std/::findcxx . . $ std/find(a92da12e15934614).(v.begincxx . . $ std/vector#begin(55a6de06420d4903).(), v.endcxx . . $ std/vector#end(55a6de06420d4903).(), pair) ==cxx . . $ __gnu_cxx/`operator==`(d2eded1addd76ab7). v.endcxx . . $ std/vector#end(55a6de06420d4903).()) |
| 179 | v.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(pair); |
| 180 | } |
| 181 | } |
| 182 | } |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | |
| 187 | if (0) { |
| 188 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "---------------- torsionable_link_bonds() returns: " <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 189 | for (unsigned int i=0; i<v.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); i++) { |
| 190 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). i <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " <<cxx . . $ coot/`operator<<`(f8fcd6198bb35afb). atom_spec_tcxx . . $ coot/atom_spec_t#(v[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i].firstcxx . . $ std/pair#first.) <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " - " |
| 191 | <<cxx . . $ coot/`operator<<`(f8fcd6198bb35afb). atom_spec_tcxx . . $ coot/atom_spec_t#(v[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i].secondcxx . . $ std/pair#second.) <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | return vcxx . . $ std/vector#vector(6f559d22b039ccdb).; |
| 196 | } |
| 197 | |
| 198 | |
| 199 | // And the atom_quad version of the above 2 functions (for setting link torsions) |
| 200 | // |
| 201 | // this can throw an exception |
| 202 | // |
| 203 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<cootcxx . . $ coot/::torsion_atom_quadcxx . . $ coot/torsion_atom_quad#> |
| 204 | cootcxx . . $ coot/::torsionable_quadscxx . . $ coot/torsionable_quads(53c95b5d9624d931).(int imol, mmdbcxx . . $ mmdb/::Managercxx . . $ mmdb/Manager# *mol, mmdbcxx . . $ mmdb/::PPAtomcxx . . $ mmdb/PPAtom# atom_selection, |
| 205 | int n_selected_atoms, |
| 206 | protein_geometrycxx . . $ coot/protein_geometry# *geom_p) { |
| 207 | |
| 208 | bool pyranose_ring_torsion_flag = false; // no thanks |
| 209 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<torsion_atom_quadcxx . . $ coot/torsion_atom_quad#> quadscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 210 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *> residuescxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 211 | for (int i=0; i<n_selected_atoms; i++) { |
| 212 | mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *r = atom_selection[i]->residuecxx . . $ mmdb/Atom#residue.; |
| 213 | if (stdcxx . . $ std/::findcxx . . $ std/find(a92da12e15934614).(residues.begincxx . . $ std/vector#begin(55a6de06420d4903).(), residues.endcxx . . $ std/vector#end(55a6de06420d4903).(), r) ==cxx . . $ __gnu_cxx/`operator==`(d2eded1addd76ab7). residues.endcxx . . $ std/vector#end(55a6de06420d4903).()) |
| 214 | residues.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(r); |
| 215 | } |
| 216 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<torsion_atom_quadcxx . . $ coot/torsion_atom_quad#> link_quads = |
| 217 | torsionable_link_quadscxx . . $ coot/torsionable_link_quads(d50c169754822d67).(imol, residuescxx . . $ std/vector#vector(a1201200cf0efa42)., mol, geom_p); |
| 218 | for (unsigned int iquad=0; iquad<link_quads.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); iquad++) |
| 219 | quads.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(link_quads[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iquad]); |
| 220 | for (unsigned int ires=0; ires<residues.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); ires++) { |
| 221 | mmdbcxx . . $ mmdb/::PPAtomcxx . . $ mmdb/PPAtom# residue_atoms = 0; |
| 222 | int n_residue_atoms; |
| 223 | residues[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).ires]->GetAtomTablecxx . . $ mmdb/Residue#GetAtomTable(9d9941bd98e0b231).(residue_atoms, n_residue_atoms); |
| 224 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<torsion_atom_quadcxx . . $ coot/torsion_atom_quad#> monomer_quads = |
| 225 | torsionable_bonds_monomer_internal_quadscxx . . $ coot/torsionable_bonds_monomer_internal_quads(a056c11ba3296b84).(residues[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).ires], residue_atoms, |
| 226 | n_residue_atoms, |
| 227 | pyranose_ring_torsion_flag, geom_p); |
| 228 | for (unsigned int iquad=0; iquad<monomer_quads.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); iquad++) |
| 229 | quads.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(monomer_quads[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iquad]); |
| 230 | } |
| 231 | return quadscxx . . $ std/vector#vector(6f559d22b039ccdb).; |
| 232 | } |
| 233 | |
| 234 | |
| 235 | // And the atom_quad version of that (for setting link torsions) |
| 236 | // |
| 237 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<cootcxx . . $ coot/::torsion_atom_quadcxx . . $ coot/torsion_atom_quad#> |
| 238 | cootcxx . . $ coot/::torsionable_link_quadscxx . . $ coot/torsionable_link_quads(d50c169754822d67).(int imol, |
| 239 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *> residues_in, |
| 240 | mmdbcxx . . $ mmdb/::Managercxx . . $ mmdb/Manager# *mol, protein_geometrycxx . . $ coot/protein_geometry# *geom_p) { |
| 241 | |
| 242 | if (false) { |
| 243 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "DEBUG:: torsionable_link_quads called with residues in size " |
| 244 | <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). residues_in.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).() <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 245 | for (unsigned int i=0; i<residues_in.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); i++) { |
| 246 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "DEBUG:: " <<cxx . . $ coot/`operator<<`(864abc555d23019c). cootcxx . . $ coot/::residue_spec_tcxx . . $ coot/residue_spec_t#(residues_in[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i]) <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 247 | } |
| 248 | loggercxx . . $ logger..logcxx . . $ logging#log(7fe8e94b8f0ade38).(log_tcxx . . $ log_t#::DEBUGcxx . . $ log_t#DEBUG., loggingcxx . . $ logging#::ltwcxx . . $ logging#ltw#("torsionable_link_quads called with residues in size"), |
| 249 | loggingcxx . . $ logging#::ltwcxx . . $ logging#ltw#(residues_in.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).())); |
| 250 | for (unsigned int i=0; i<residues_in.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); i++) |
| 251 | loggercxx . . $ logger..logcxx . . $ logging#log(aa04b0d416afa0e1).(log_tcxx . . $ log_t#::DEBUGcxx . . $ log_t#DEBUG., residue_spec_tcxx . . $ coot/residue_spec_t#(residues_in[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i]).formatcxx . . $ coot/residue_spec_t#format(219584694fe2b248).()); |
| 252 | } |
| 253 | |
| 254 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<torsion_atom_quadcxx . . $ coot/torsion_atom_quad#> quadscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 255 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<bool, mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *> > residuescxx . . $ std/vector#vector(83fdeebbe0501a83).(residues_in.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).()); |
| 256 | for (unsigned int i=0; i<residues_in.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); i++) |
| 257 | residues[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i] =cxx . . $ std/pair#`operator=`(ab9ebd0b824095ec). stdcxx . . $ std/pair#pair(62e1774a2dc03c82).::paircxx . . $ std/pair#<bool, mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *> (0, residues_in[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i]); |
| 258 | |
| 259 | // We want a quick way of getting to the restaints of an atom's |
| 260 | // residue (link_atom_1 and link_atom_2 below). |
| 261 | // So here we set up res_restraints map indexed by a mmdb::Residue *. |
| 262 | // |
| 263 | stdcxx . . $ std/::mapcxx . . $ std/map#<mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *, dictionary_residue_restraints_tcxx . . $ coot/dictionary_residue_restraints_t#> res_restraintscxx . . $ std/map#map(49f6e7a06ebc5aa8).; |
| 264 | for (unsigned int ires=0; ires<residues_in.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); ires++) { |
| 265 | stdcxx . . $ std/::stringcxx . . $ std/string# rn = residues_incxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).ires]->GetResNamecxx . . $ mmdb/Residue#GetResName(41208ce6ca65dd58).(); |
| 266 | stdcxx . . $ std/::paircxx . . $ std/pair#<bool, dictionary_residue_restraints_tcxx . . $ coot/dictionary_residue_restraints_t#> rest = geom_p->get_monomer_restraintscxx . . $ coot/protein_geometry#get_monomer_restraints(a55f7295d433dd41).(rn, imol); |
| 267 | if (! rest.firstcxx . . $ std/pair#first.) { |
| 268 | stdcxx . . $ std/::stringcxx . . $ std/string# m = "Restraints not found for type "cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).; |
| 269 | m +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). rn; |
| 270 | throw stdcxx . . $ std/::runtime_errorcxx . . $ std/runtime_error#(m); |
| 271 | } |
| 272 | res_restraints[cxx . . $ std/map#`operator[]`(bbd415b616967878).residues_in[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).ires]] =cxx . . $ coot/dictionary_residue_restraints_t#`operator=`(494fbb4305d2616a). rest.secondcxx . . $ std/pair#second.; |
| 273 | } |
| 274 | |
| 275 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<atom_spec_tcxx . . $ coot/atom_spec_t#> dummy_fixed_atom_specscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 276 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<mmdbcxx . . $ mmdb/::Linkcxx . . $ mmdb/Link#> linkscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 277 | clippercxx . . $ clipper/::Xmapcxx . . $ clipper/Xmap#<float> dummy_xmapcxx . . $ clipper/Xmap#Xmap(49f6e7a06ebc5aa8).; |
| 278 | restraints_container_tcxx . . $ coot/restraints_container_t# restraintscxx . . $ coot/restraints_container_t#restraints_container_t(77762fd271e46213).(residues, links, *geom_p, mol, dummy_fixed_atom_specs, &dummy_xmap); |
| 279 | bonded_pair_container_tcxx . . $ coot/bonded_pair_container_t# bpc = restraints.bonded_residues_from_res_veccxx . . $ coot/restraints_container_t#bonded_residues_from_res_vec(1f321814dc0d6463).(*geom_p); |
| 280 | |
| 281 | for (unsigned int i=0; i<bpc.bonded_residuescxx . . $ coot/bonded_pair_container_t#bonded_residues..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); i++) { |
| 282 | |
| 283 | const dictionary_residue_link_restraints_tcxx . . $ coot/dictionary_residue_link_restraints_t# &link = geom_p->linkcxx . . $ coot/protein_geometry#link(848f04020ded7a2e).(bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].link_typecxx . . $ coot/bonded_pair_t#link_type.); |
| 284 | |
| 285 | // In a NAG-ASN link the first residue should be the NAG and residue-2 should be the ASN. |
| 286 | // |
| 287 | // std::cout << "DEBUG:: link-idx: " << i << " link_id: \"" << link.link_id << "\"" << std::endl; |
| 288 | |
| 289 | if (link.link_idcxx . . $ coot/dictionary_residue_link_restraints_t#link_id. != "") { |
| 290 | |
| 291 | // Don't use bonds - use link torsions if you can. |
| 292 | // |
| 293 | // std::cout << "DEBUG:: link " << link.link_id << " has " << link.link_torsion_restraint.size() |
| 294 | // << " torsion restraints " << std::endl; |
| 295 | |
| 296 | if (link.link_torsion_restraintcxx . . $ coot/dictionary_residue_link_restraints_t#link_torsion_restraint..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).() > 0) { |
| 297 | |
| 298 | for (unsigned int il=0; il<link.link_torsion_restraintcxx . . $ coot/dictionary_residue_link_restraints_t#link_torsion_restraint..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); il++) { |
| 299 | // std::cout << "----------- link torsion restraint " << il << std::endl; |
| 300 | const dict_link_torsion_restraint_tcxx . . $ coot/dict_link_torsion_restraint_t# &rest = link.link_torsion_restraintcxx . . $ coot/dictionary_residue_link_restraints_t#link_torsion_restraint.[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).il]; |
| 301 | if (rest.is_pyranose_ring_torsioncxx . . $ coot/dict_link_torsion_restraint_t#is_pyranose_ring_torsion(50ce9a9e25b4a850).()) { |
| 302 | // pass |
| 303 | // std::cout << " link # " << il << " is pyranose ring torsion # PASS" << std::endl; |
| 304 | loggercxx . . $ logger..logcxx . . $ logging#log(136b797fd534cffb).(log_tcxx . . $ log_t#::INFOcxx . . $ log_t#INFO., " link #"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., il, "is pyranose ring torsion # PASS"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).); |
| 305 | |
| 306 | if (false) { // debug |
| 307 | mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *r_1 = bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].res_1cxx . . $ coot/bonded_pair_t#res_1.; |
| 308 | mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *r_2 = bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].res_1cxx . . $ coot/bonded_pair_t#res_1.; |
| 309 | mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *r_3 = bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].res_1cxx . . $ coot/bonded_pair_t#res_1.; |
| 310 | mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *r_4 = bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].res_1cxx . . $ coot/bonded_pair_t#res_1.; |
| 311 | if (rest.atom_1_comp_idcxx . . $ coot/dict_link_torsion_restraint_t#atom_1_comp_id. == 2) |
| 312 | r_1 = bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].res_2cxx . . $ coot/bonded_pair_t#res_2.; |
| 313 | if (rest.atom_2_comp_idcxx . . $ coot/dict_link_torsion_restraint_t#atom_2_comp_id. == 2) |
| 314 | r_2 = bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].res_2cxx . . $ coot/bonded_pair_t#res_2.; |
| 315 | if (rest.atom_3_comp_idcxx . . $ coot/dict_link_torsion_restraint_t#atom_3_comp_id. == 2) |
| 316 | r_3 = bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].res_2cxx . . $ coot/bonded_pair_t#res_2.; |
| 317 | if (rest.atom_4_comp_idcxx . . $ coot/dict_link_torsion_restraint_t#atom_4_comp_id. == 2) |
| 318 | r_4 = bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].res_2cxx . . $ coot/bonded_pair_t#res_2.; |
| 319 | mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *link_atom_1 = r_1->GetAtomcxx . . $ mmdb/Residue#GetAtom(aa774886b7cb8f8a).(rest.atom_id_1_4ccxx . . $ coot/basic_dict_restraint_t#atom_id_1_4c(219584694fe2b248).().c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 320 | mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *link_atom_2 = r_2->GetAtomcxx . . $ mmdb/Residue#GetAtom(aa774886b7cb8f8a).(rest.atom_id_2_4ccxx . . $ coot/basic_dict_restraint_t#atom_id_2_4c(219584694fe2b248).().c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 321 | mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *link_atom_3 = r_3->GetAtomcxx . . $ mmdb/Residue#GetAtom(aa774886b7cb8f8a).(rest.atom_id_3_4ccxx . . $ coot/dict_link_torsion_restraint_t#atom_id_3_4c(219584694fe2b248).().c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 322 | mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *link_atom_4 = r_4->GetAtomcxx . . $ mmdb/Residue#GetAtom(aa774886b7cb8f8a).(rest.atom_id_4_4ccxx . . $ coot/dict_link_torsion_restraint_t#atom_id_4_4c(219584694fe2b248).().c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 323 | |
| 324 | // std::cout << " link # " << il << " has link_atoms: " |
| 325 | // << atom_spec_t(link_atom_1) << " " << atom_spec_t(link_atom_2) << " " |
| 326 | // << atom_spec_t(link_atom_3) << " " << atom_spec_t(link_atom_4) << " " |
| 327 | // << std::endl; |
| 328 | loggercxx . . $ logger..logcxx . . $ logging#log(86c7a9436785fa93).(log_tcxx . . $ log_t#::INFOcxx . . $ log_t#INFO., {cxx . . $ std/vector#vector(9619226211e5a241)." link #", il, "has link_atoms:", |
| 329 | atom_spec_tcxx . . $ coot/atom_spec_t#(link_atom_1).formatcxx . . $ coot/atom_spec_t#format(219584694fe2b248).(), |
| 330 | atom_spec_tcxx . . $ coot/atom_spec_t#(link_atom_2).formatcxx . . $ coot/atom_spec_t#format(219584694fe2b248).(), |
| 331 | atom_spec_tcxx . . $ coot/atom_spec_t#(link_atom_3).formatcxx . . $ coot/atom_spec_t#format(219584694fe2b248).(), |
| 332 | atom_spec_tcxx . . $ coot/atom_spec_t#(link_atom_4).formatcxx . . $ coot/atom_spec_t#format(219584694fe2b248).()}); |
| 333 | |
| 334 | } |
| 335 | } else { |
| 336 | mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *r_1 = bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].res_1cxx . . $ coot/bonded_pair_t#res_1.; |
| 337 | mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *r_2 = bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].res_1cxx . . $ coot/bonded_pair_t#res_1.; |
| 338 | mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *r_3 = bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].res_1cxx . . $ coot/bonded_pair_t#res_1.; |
| 339 | mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *r_4 = bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].res_1cxx . . $ coot/bonded_pair_t#res_1.; |
| 340 | if (rest.atom_1_comp_idcxx . . $ coot/dict_link_torsion_restraint_t#atom_1_comp_id. == 2) |
| 341 | r_1 = bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].res_2cxx . . $ coot/bonded_pair_t#res_2.; |
| 342 | if (rest.atom_2_comp_idcxx . . $ coot/dict_link_torsion_restraint_t#atom_2_comp_id. == 2) |
| 343 | r_2 = bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].res_2cxx . . $ coot/bonded_pair_t#res_2.; |
| 344 | if (rest.atom_3_comp_idcxx . . $ coot/dict_link_torsion_restraint_t#atom_3_comp_id. == 2) |
| 345 | r_3 = bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].res_2cxx . . $ coot/bonded_pair_t#res_2.; |
| 346 | if (rest.atom_4_comp_idcxx . . $ coot/dict_link_torsion_restraint_t#atom_4_comp_id. == 2) |
| 347 | r_4 = bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].res_2cxx . . $ coot/bonded_pair_t#res_2.; |
| 348 | mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *link_atom_1 = r_1->GetAtomcxx . . $ mmdb/Residue#GetAtom(aa774886b7cb8f8a).(rest.atom_id_1_4ccxx . . $ coot/basic_dict_restraint_t#atom_id_1_4c(219584694fe2b248).().c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 349 | mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *link_atom_2 = r_2->GetAtomcxx . . $ mmdb/Residue#GetAtom(aa774886b7cb8f8a).(rest.atom_id_2_4ccxx . . $ coot/basic_dict_restraint_t#atom_id_2_4c(219584694fe2b248).().c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 350 | mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *link_atom_3 = r_3->GetAtomcxx . . $ mmdb/Residue#GetAtom(aa774886b7cb8f8a).(rest.atom_id_3_4ccxx . . $ coot/dict_link_torsion_restraint_t#atom_id_3_4c(219584694fe2b248).().c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 351 | mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *link_atom_4 = r_4->GetAtomcxx . . $ mmdb/Residue#GetAtom(aa774886b7cb8f8a).(rest.atom_id_4_4ccxx . . $ coot/dict_link_torsion_restraint_t#atom_id_4_4c(219584694fe2b248).().c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 352 | |
| 353 | // std::cout << " link # " << il << " has residues " |
| 354 | // << residue_spec_t(r_1) << " " << residue_spec_t(r_2) |
| 355 | // << " " |
| 356 | // << residue_spec_t(r_3) << " " << residue_spec_t(r_4) |
| 357 | // << std::endl; |
| 358 | // std::cout << " link # " << il << " has link_atoms: " |
| 359 | // << atom_spec_t(link_atom_1) << " " << atom_spec_t(link_atom_2) << " " |
| 360 | // << atom_spec_t(link_atom_3) << " " << atom_spec_t(link_atom_4) << " " |
| 361 | // << std::endl; |
| 362 | |
| 363 | loggercxx . . $ logger..logcxx . . $ logging#log(86c7a9436785fa93).(log_tcxx . . $ log_t#::INFOcxx . . $ log_t#INFO., {cxx . . $ std/vector#vector(9619226211e5a241)." link #", il, "has residues", |
| 364 | residue_spec_tcxx . . $ coot/residue_spec_t#(r_1).formatcxx . . $ coot/residue_spec_t#format(219584694fe2b248).(), |
| 365 | residue_spec_tcxx . . $ coot/residue_spec_t#(r_2).formatcxx . . $ coot/residue_spec_t#format(219584694fe2b248).(), |
| 366 | residue_spec_tcxx . . $ coot/residue_spec_t#(r_3).formatcxx . . $ coot/residue_spec_t#format(219584694fe2b248).(), |
| 367 | residue_spec_tcxx . . $ coot/residue_spec_t#(r_4).formatcxx . . $ coot/residue_spec_t#format(219584694fe2b248).()}); |
| 368 | loggercxx . . $ logger..logcxx . . $ logging#log(86c7a9436785fa93).(log_tcxx . . $ log_t#::INFOcxx . . $ log_t#INFO., {cxx . . $ std/vector#vector(9619226211e5a241)." link #", il, "has link_atoms:", |
| 369 | atom_spec_tcxx . . $ coot/atom_spec_t#(link_atom_1).formatcxx . . $ coot/atom_spec_t#format(219584694fe2b248).(), |
| 370 | atom_spec_tcxx . . $ coot/atom_spec_t#(link_atom_2).formatcxx . . $ coot/atom_spec_t#format(219584694fe2b248).(), |
| 371 | atom_spec_tcxx . . $ coot/atom_spec_t#(link_atom_3).formatcxx . . $ coot/atom_spec_t#format(219584694fe2b248).(), |
| 372 | atom_spec_tcxx . . $ coot/atom_spec_t#(link_atom_4).formatcxx . . $ coot/atom_spec_t#format(219584694fe2b248).()}); |
| 373 | |
| 374 | if (link_atom_1 && link_atom_2 && link_atom_3 && link_atom_4) { |
| 375 | torsion_atom_quadcxx . . $ coot/torsion_atom_quad# qcxx . . $ coot/torsion_atom_quad#torsion_atom_quad(b723814abe5a495d).(link_atom_1, link_atom_2, link_atom_3, link_atom_4, |
| 376 | rest.anglecxx . . $ coot/dict_link_torsion_restraint_t#angle(21b6c25e127938e2).(), |
| 377 | rest.angle_esdcxx . . $ coot/dict_link_torsion_restraint_t#angle_esd(21b6c25e127938e2).(), |
| 378 | rest.periodcxx . . $ coot/dict_link_torsion_restraint_t#period(455f465bc33b4cdf).()); |
| 379 | q.namecxx . . $ coot/atom_quad#name. =cxx . . $ std/__cxx11/basic_string#`operator=`(36befb0d0c9f966). rest.idcxx . . $ coot/dict_link_torsion_restraint_t#id(219584694fe2b248).(); |
| 380 | quads.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(q); |
| 381 | } |
| 382 | } |
| 383 | } |
| 384 | |
| 385 | } else { |
| 386 | |
| 387 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "INFO:: link torsion generated from link bond restraint" <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 388 | |
| 389 | // bleugh... OK, no torsion restraints. |
| 390 | // So use a bond restaint to make one torsion (around the link bond). |
| 391 | // |
| 392 | for (unsigned int ib=0; ib<link.link_bond_restraintcxx . . $ coot/dictionary_residue_link_restraints_t#link_bond_restraint..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); ib++) { |
| 393 | mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *link_atom_1 = bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].res_1cxx . . $ coot/bonded_pair_t#res_1.->GetAtomcxx . . $ mmdb/Residue#GetAtom(aa774886b7cb8f8a).(link.link_bond_restraintcxx . . $ coot/dictionary_residue_link_restraints_t#link_bond_restraint.[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).ib].atom_id_1_4ccxx . . $ coot/basic_dict_restraint_t#atom_id_1_4c(219584694fe2b248).().c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 394 | mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *link_atom_2 = bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].res_2cxx . . $ coot/bonded_pair_t#res_2.->GetAtomcxx . . $ mmdb/Residue#GetAtom(aa774886b7cb8f8a).(link.link_bond_restraintcxx . . $ coot/dictionary_residue_link_restraints_t#link_bond_restraint.[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).ib].atom_id_2_4ccxx . . $ coot/basic_dict_restraint_t#atom_id_2_4c(219584694fe2b248).().c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 395 | if (link_atom_1 && link_atom_2) { |
| 396 | // What are the neightbours of link_atom_1 (and link_atom_2)? |
| 397 | // Try to find a non-hydrogen atom to which it is bonded. |
| 398 | bool H_flag = false; |
| 399 | stdcxx . . $ std/::stringcxx . . $ std/string# atom_name_1 = link_atom_1cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).->namecxx . . $ mmdb/Atom#name.; |
| 400 | stdcxx . . $ std/::stringcxx . . $ std/string# atom_name_2 = link_atom_2cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).->namecxx . . $ mmdb/Atom#name.; |
| 401 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#> n1cxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 402 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#> n2cxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 403 | n1 =cxx . . $ std/vector#`operator=`(1104576815caab1a). res_restraints[cxx . . $ std/map#`operator[]`(bbd415b616967878).link_atom_1->residuecxx . . $ mmdb/Atom#residue.].neighbourscxx . . $ coot/dictionary_residue_restraints_t#neighbours(660e351e73d47874).(atom_name_1, H_flag); |
| 404 | n2 =cxx . . $ std/vector#`operator=`(1104576815caab1a). res_restraints[cxx . . $ std/map#`operator[]`(bbd415b616967878).link_atom_2->residuecxx . . $ mmdb/Atom#residue.].neighbourscxx . . $ coot/dictionary_residue_restraints_t#neighbours(660e351e73d47874).(atom_name_2, H_flag); |
| 405 | if (n1.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).() && n2.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).()) { |
| 406 | stdcxx . . $ std/::stringcxx . . $ std/string# neigbhour_1_name = n1cxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5).[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0]; |
| 407 | stdcxx . . $ std/::stringcxx . . $ std/string# neigbhour_2_name = n2cxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5).[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0]; |
| 408 | mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *n_at_1 = bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].res_1cxx . . $ coot/bonded_pair_t#res_1.->GetAtomcxx . . $ mmdb/Residue#GetAtom(aa774886b7cb8f8a).(neigbhour_1_name.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 409 | mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *n_at_2 = bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].res_2cxx . . $ coot/bonded_pair_t#res_2.->GetAtomcxx . . $ mmdb/Residue#GetAtom(aa774886b7cb8f8a).(neigbhour_2_name.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 410 | if (n_at_1 && n_at_2) { |
| 411 | torsion_atom_quadcxx . . $ coot/torsion_atom_quad# qcxx . . $ coot/torsion_atom_quad#torsion_atom_quad(b723814abe5a495d).(n_at_1, link_atom_1, link_atom_2, n_at_2, |
| 412 | -84, 40, 3); // synthetic values |
| 413 | // If link is NAG-ASN then this torsion is phi (C1-ND2) |
| 414 | q.namecxx . . $ coot/atom_quad#name. =cxx . . $ std/__cxx11/basic_string#`operator=`(36befb0d0c9f966). "Bond-derived synthetic torsion-phi-" +cxx . . $ std/operator+(39ed2c165380f78e). utilcxx . . $ coot/util/::int_to_stringcxx . . $ coot/util/int_to_string(7eb93f795f0defb3).(ib); |
| 415 | quads.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(q); |
| 416 | |
| 417 | // also we need psi, CB, CG, ND2, C1 (of NAG) |
| 418 | // |
| 419 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#> n3cxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 420 | n3 =cxx . . $ std/vector#`operator=`(1104576815caab1a). res_restraints[cxx . . $ std/map#`operator[]`(bbd415b616967878).link_atom_2->residuecxx . . $ mmdb/Atom#residue.].neighbourscxx . . $ coot/dictionary_residue_restraints_t#neighbours(660e351e73d47874).(atom_name_2, H_flag); |
| 421 | if (n3.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).()) { |
| 422 | mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *n_at_3 = bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].res_2cxx . . $ coot/bonded_pair_t#res_2.->GetAtomcxx . . $ mmdb/Residue#GetAtom(aa774886b7cb8f8a).(n3[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0].c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 423 | if (n_at_3) { |
| 424 | torsion_atom_quadcxx . . $ coot/torsion_atom_quad# qcxx . . $ coot/torsion_atom_quad#torsion_atom_quad(b723814abe5a495d).(link_atom_1, link_atom_2, n_at_2, n_at_3, |
| 425 | 185.1, 40, 3); // synthetic values |
| 426 | // If link is NAG-ASN then this torsion is phi (C1-ND2) |
| 427 | q.namecxx . . $ coot/atom_quad#name. =cxx . . $ std/__cxx11/basic_string#`operator=`(36befb0d0c9f966). "Bond-derived synthetic torsion-psi-" +cxx . . $ std/operator+(39ed2c165380f78e). utilcxx . . $ coot/util/::int_to_stringcxx . . $ coot/util/int_to_string(7eb93f795f0defb3).(ib); |
| 428 | // quads.push_back(q); |
| 429 | } |
| 430 | } |
| 431 | } |
| 432 | } |
| 433 | } else { |
| 434 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "WARNING:: oops missing link atoms " <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 435 | if (! link_atom_1) |
| 436 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). link.link_bond_restraintcxx . . $ coot/dictionary_residue_link_restraints_t#link_bond_restraint.[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).ib].atom_id_1_4ccxx . . $ coot/basic_dict_restraint_t#atom_id_1_4c(219584694fe2b248).().c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).() |
| 437 | <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " is missing from residue " <<cxx . . $ coot/`operator<<`(864abc555d23019c). residue_spec_tcxx . . $ coot/residue_spec_t#(bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].res_1cxx . . $ coot/bonded_pair_t#res_1.) <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 438 | if (! link_atom_2) |
| 439 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). link.link_bond_restraintcxx . . $ coot/dictionary_residue_link_restraints_t#link_bond_restraint.[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).ib].atom_id_2_4ccxx . . $ coot/basic_dict_restraint_t#atom_id_2_4c(219584694fe2b248).().c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).() |
| 440 | <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " is missing from residue " <<cxx . . $ coot/`operator<<`(864abc555d23019c). residue_spec_tcxx . . $ coot/residue_spec_t#(bpc[cxx . . $ coot/bonded_pair_container_t#`operator[]`(f91b47c330f13505).i].res_2cxx . . $ coot/bonded_pair_t#res_2.) <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 441 | } |
| 442 | } |
| 443 | } |
| 444 | } |
| 445 | } |
| 446 | return quadscxx . . $ std/vector#vector(6f559d22b039ccdb).; |
| 447 | } |
| 448 | |
| 449 | |
| 450 | // this can throw an exception. |
| 451 | // |
| 452 | // This presumes that mol is actually a mol-fragment, created something like: |
| 453 | // mmdb::Manager *moving_mol = |
| 454 | // coot::util::create_mmdbmanager_from_residue_specs(residue_specs, atom_sel.mol); |
| 455 | // |
| 456 | void |
| 457 | cootcxx . . $ coot/::multi_residue_torsion_fit_mapcxx . . $ coot/multi_residue_torsion_fit_map(d8bc77a84835792b).(int imol, |
| 458 | mmdbcxx . . $ mmdb/::Managercxx . . $ mmdb/Manager# *mol, |
| 459 | const clippercxx . . $ clipper/::Xmapcxx . . $ clipper/Xmap#<float> &xmap, |
| 460 | const stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<bool, clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth#> > &avoid_these_atoms, // 20170613 flag is is-water |
| 461 | int n_trials, |
| 462 | protein_geometrycxx . . $ coot/protein_geometry# *geom_p) { |
| 463 | |
| 464 | // First fill the atoms vector: all the atoms in the input mol |
| 465 | // Get the torsionable quads atom names |
| 466 | // Get the contact info and use that to make torsions |
| 467 | // For n_trials, |
| 468 | // make a model using set_dihedral_multi |
| 469 | // get self_clash_score |
| 470 | // if self_clash_score < 6 |
| 471 | // get density fit score |
| 472 | // if its better than the best score so far |
| 473 | // update best_quads and best_tree_dihedral_quads |
| 474 | // update model so that it uses best_tree_dihedral_quads |
| 475 | |
| 476 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::stringcxx . . $ std/string#, int> > atom_numbers = utilcxx . . $ coot/util/::atomic_number_atom_listcxx . . $ coot/util/atomic_number_atom_list(d4f4af6c3e407740).(); |
| 477 | |
| 478 | try { |
| 479 | mmdbcxx . . $ mmdb/::PPAtomcxx . . $ mmdb/PPAtom# atom_selection = 0; |
| 480 | int n_selected_atoms; |
| 481 | int selhnd = mol->NewSelectioncxx . . $ mmdb/SelManager#NewSelection(b126dc7c1de90089).(); // d |
| 482 | mol->SelectAtomscxx . . $ mmdb/SelManager#SelectAtoms(395440d8c4963665).(selhnd, 0, "*", |
| 483 | mmdbcxx . . $ mmdb/::ANY_REScxx . . $ mmdb/ANY_RES., "*", |
| 484 | mmdbcxx . . $ mmdb/::ANY_REScxx . . $ mmdb/ANY_RES., "*", |
| 485 | "*", "*", "*", "*"); |
| 486 | mol->GetSelIndexcxx . . $ mmdb/SelManager#GetSelIndex(72b04e22d1bb79c2).(selhnd, atom_selection, n_selected_atoms); |
| 487 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *, float> > atomscxx . . $ std/vector#vector(83fdeebbe0501a83).(n_selected_atoms); // for density fitting |
| 488 | for (int iat=0; iat<n_selected_atoms; iat++) { |
| 489 | int atomic_number = utilcxx . . $ coot/util/::atomic_numbercxx . . $ coot/util/atomic_number(d2bc5463616b2d9).(atom_selectioncxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).[iat]->elementcxx . . $ mmdb/Atom#element., atom_numbers); |
| 490 | float z = atomic_number; |
| 491 | if (atomic_number == -1) |
| 492 | z = 6.0f; |
| 493 | atoms[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iat] =cxx . . $ std/pair#`operator=`(ab9ebd0b824095ec). stdcxx . . $ std/pair#pair(62e1774a2dc03c82).::paircxx . . $ std/pair#<mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *, float> (atom_selection[iat], z); |
| 494 | } |
| 495 | |
| 496 | if (n_selected_atoms > 0) { |
| 497 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<torsion_atom_quadcxx . . $ coot/torsion_atom_quad#> quads = |
| 498 | torsionable_quadscxx . . $ coot/torsionable_quads(53c95b5d9624d931).(imol, mol, atom_selection, n_selected_atoms, geom_p); |
| 499 | |
| 500 | // FIXME for future, calculate link_angle_atom_triples, using something analoguous to |
| 501 | // torsionable_link_quads() |
| 502 | |
| 503 | if (false) // debug |
| 504 | for (unsigned int iquad=0; iquad<quads.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); iquad++) |
| 505 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "DEBUG multi-residue-torsion-fit-map: tosion quads: " |
| 506 | <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). iquad <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " |
| 507 | <<cxx . . $ coot/`operator<<`(f8fcd6198bb35afb). atom_spec_tcxx . . $ coot/atom_spec_t#(quads[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iquad].atom_1cxx . . $ coot/atom_quad#atom_1.) <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " |
| 508 | <<cxx . . $ coot/`operator<<`(f8fcd6198bb35afb). atom_spec_tcxx . . $ coot/atom_spec_t#(quads[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iquad].atom_2cxx . . $ coot/atom_quad#atom_2.) <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " |
| 509 | <<cxx . . $ coot/`operator<<`(f8fcd6198bb35afb). atom_spec_tcxx . . $ coot/atom_spec_t#(quads[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iquad].atom_3cxx . . $ coot/atom_quad#atom_3.) <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " |
| 510 | <<cxx . . $ coot/`operator<<`(f8fcd6198bb35afb). atom_spec_tcxx . . $ coot/atom_spec_t#(quads[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iquad].atom_4cxx . . $ coot/atom_quad#atom_4.) <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " \"" |
| 511 | <<cxx . . $ std/`operator<<`(88df5bef833f7f83). quads[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iquad].namecxx . . $ coot/atom_quad#name. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\" torsion: " |
| 512 | <<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). quads[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iquad].torsioncxx . . $ coot/atom_quad#torsion(21b6c25e127938e2).() |
| 513 | <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 514 | |
| 515 | contact_infocxx . . $ coot/contact_info# contactscxx . . $ coot/contact_info#contact_info(c5301e0fc33f325).(mol, imol, selhnd, quads, geom_p); |
| 516 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<int> > contact_indices = |
| 517 | contacts.get_contact_indices_with_reverse_contactscxx . . $ coot/contact_info#get_contact_indices_with_reverse_contacts(4375e865bd9bb3fb).(); |
| 518 | atom_tree_tcxx . . $ coot/atom_tree_t# treecxx . . $ coot/atom_tree_t#atom_tree_t(cd1aca06c01d850e).(contact_indices, 0, mol, selhnd); |
| 519 | |
| 520 | bool reverse_flag = 1; |
| 521 | double pre_score = utilcxx . . $ coot/util/::z_weighted_density_score_newcxx . . $ coot/util/z_weighted_density_score_new(98f9a9d8d08a9003).(atoms, xmap); |
| 522 | |
| 523 | double best_score = pre_score; |
| 524 | int n_quads = quads.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); |
| 525 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<double> best_quadscxx . . $ std/vector#vector(229e4d6bd205de31).(n_quads, -1); |
| 526 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<atom_tree_tcxx . . $ coot/atom_tree_t#::tree_dihedral_quad_info_tcxx . . $ coot/atom_tree_t#tree_dihedral_quad_info_t#> best_tree_dihedral_quadscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 527 | map_index_tcxx . . $ coot/map_index_t# fixed_indexcxx . . $ coot/map_index_t#map_index_t(d4f767463ce0a6b3).(0); |
| 528 | |
| 529 | // save the current |
| 530 | for (int iquad=0; iquad<n_quads; iquad++) |
| 531 | best_quads[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iquad] = quads[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iquad].torsioncxx . . $ coot/atom_quad#torsion(21b6c25e127938e2).(); |
| 532 | |
| 533 | // Make the first few shifts small, because we could be close |
| 534 | // to the correct solution by initial placement. At a guess, |
| 535 | // the first 15% should be small. |
| 536 | // |
| 537 | int itrial_n_small_lim(0.15*n_trials); |
| 538 | // |
| 539 | for (int itrial=0; itrial<n_trials; itrial++) { |
| 540 | |
| 541 | bool allow_conformer_switch = true; |
| 542 | bool small_torsion_changes = false; |
| 543 | if (itrial < itrial_n_small_lim) { |
| 544 | allow_conformer_switch = false; |
| 545 | small_torsion_changes = true; |
| 546 | } |
| 547 | |
| 548 | if (false) |
| 549 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Round " <<cxx . . $ std/basic_ostream#`operator<<`(23b6575433a77e57). itrial <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " of " <<cxx . . $ std/basic_ostream#`operator<<`(23b6575433a77e57). n_trials <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " for " <<cxx . . $ std/basic_ostream#`operator<<`(23b6575433a77e57). n_quads <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " quads " |
| 550 | <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 551 | |
| 552 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<atom_tree_tcxx . . $ coot/atom_tree_t#::tree_dihedral_quad_info_tcxx . . $ coot/atom_tree_t#tree_dihedral_quad_info_t#> torsion_quadscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 553 | |
| 554 | // debug, store angles in rand_angles: name current trial-value |
| 555 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<stdcxx . . $ std/::stringcxx . . $ std/string#, double, double> > rand_anglescxx . . $ std/vector#vector(83fdeebbe0501a83).(n_quads); |
| 556 | |
| 557 | for (int iquad=0; iquad<n_quads; iquad++) { |
| 558 | // quads[iquad] is passed for debugging |
| 559 | double rand_angle = get_rand_anglecxx . . $ coot/get_rand_angle(78c22a727fba319c).(best_quads[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iquad], quads[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iquad], itrial, |
| 560 | n_trials, allow_conformer_switch, small_torsion_changes); |
| 561 | |
| 562 | stdcxx . . $ std/::tuplecxx . . $ std/tuple#<stdcxx . . $ std/::stringcxx . . $ std/string#, double, double> tupcxx . . $ std/tuple#tuple(7b0701f99332c8a8).(quads[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iquad].namecxx . . $ coot/atom_quad#name., best_quads[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iquad], rand_angle); |
| 563 | rand_angles[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iquad] =cxx . . $ std/tuple#`operator=`(3df531cffa8a7485). tup; |
| 564 | |
| 565 | atom_tree_tcxx . . $ coot/atom_tree_t#::tree_dihedral_quad_info_tcxx . . $ coot/atom_tree_t#tree_dihedral_quad_info_t# torcxx . . $ coot/atom_tree_t#tree_dihedral_quad_info_t#tree_dihedral_quad_info_t(8902197f0d82582d).(quads[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iquad], rand_angle, fixed_index); |
| 566 | torsion_quads.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(tor); |
| 567 | } |
| 568 | |
| 569 | |
| 570 | if (false) { //debug |
| 571 | for (int iquad=0; iquad<n_quads; iquad++) { |
| 572 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "debug: itrial " <<cxx . . $ std/basic_ostream#`operator<<`(23b6575433a77e57). itrial <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " |
| 573 | <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "iquad " <<cxx . . $ std/basic_ostream#`operator<<`(23b6575433a77e57). iquad <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " |
| 574 | <<cxx . . $ std/`operator<<`(88df5bef833f7f83). stdcxx . . $ std/::getcxx . . $ std/get(51b66c851421c132).<0>(rand_angles[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iquad]) <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " |
| 575 | <<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). stdcxx . . $ std/::getcxx . . $ std/get(51b66c851421c132).<1>(rand_angles[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iquad]) <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " |
| 576 | <<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). stdcxx . . $ std/::getcxx . . $ std/get(51b66c851421c132).<2>(rand_angles[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iquad]) <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " "; |
| 577 | } |
| 578 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 579 | } |
| 580 | |
| 581 | if (false) { |
| 582 | stdcxx . . $ std/::stringcxx . . $ std/string# file_name = "A-trial-" +cxx . . $ std/operator+(39ed2c165380f78e). stdcxx . . $ std/::to_stringcxx . . $ std/__cxx11/to_string(3d81e17e7a87eecc).(itrial) +cxx . . $ std/operator+(900ec9581c410ad9). ".pdb"; |
| 583 | mol->WritePDBASCIIcxx . . $ mmdb/Root#WritePDBASCII(9eb88f3d8809bd24).(file_name.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 584 | } |
| 585 | |
| 586 | tree.set_dihedral_multicxx . . $ coot/atom_tree_t#set_dihedral_multi(db173d5632df38c6).(torsion_quads); |
| 587 | |
| 588 | if (false) { |
| 589 | stdcxx . . $ std/::stringcxx . . $ std/string# file_name = "B-trial-" +cxx . . $ std/operator+(39ed2c165380f78e). stdcxx . . $ std/::to_stringcxx . . $ std/__cxx11/to_string(3d81e17e7a87eecc).(itrial) +cxx . . $ std/operator+(900ec9581c410ad9). ".pdb"; |
| 590 | mol->WritePDBASCIIcxx . . $ mmdb/Root#WritePDBASCII(9eb88f3d8809bd24).(file_name.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 591 | } |
| 592 | |
| 593 | // FIXME for futures, also include link_angle_atom_triples (for excluding of bumps) |
| 594 | double self_clash_score = get_self_clash_scorecxx . . $ coot/get_self_clash_score(2dd8cb3eb5ac13d0).(mol, atom_selection, n_selected_atoms, quads); |
| 595 | |
| 596 | double env_clash_score = get_environment_clash_scorecxx . . $ coot/get_environment_clash_score(eab3807a5700080c).(mol, atom_selection, n_selected_atoms, |
| 597 | avoid_these_atoms); |
| 598 | |
| 599 | if (false) { |
| 600 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "DEBUG:: self_clash_score: " <<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). self_clash_score <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 601 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "DEBUG:: env_clash_score: " <<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). env_clash_score <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 602 | } |
| 603 | |
| 604 | // self-clash scores have mean 7.5, median 3.3 and sd 14, IRQ 0.66 |
| 605 | // Is this a good clash score lim? Not clear, but 10.0 is better than 1.0 |
| 606 | // |
| 607 | if ((self_clash_score > 6) || (env_clash_score > 30.0)) { |
| 608 | |
| 609 | // crash and bangs into itself (between residues) |
| 610 | // or into its neighbours (the 1.0 might need tuning) |
| 611 | |
| 612 | } else { |
| 613 | |
| 614 | // happy path |
| 615 | |
| 616 | double this_score = utilcxx . . $ coot/util/::z_weighted_density_score_newcxx . . $ coot/util/z_weighted_density_score_new(98f9a9d8d08a9003).(atoms, xmap); |
| 617 | |
| 618 | // debugging of scores |
| 619 | if (false) { |
| 620 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "debug trial " <<cxx . . $ std/basic_ostream#`operator<<`(23b6575433a77e57). itrial <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " fit-score: " <<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). this_score |
| 621 | <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " self-clash-score " <<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). self_clash_score |
| 622 | <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " for quads "; |
| 623 | for (unsigned int iquad=0; iquad<quads.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); iquad++) |
| 624 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " <<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). quads[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iquad].torsioncxx . . $ coot/atom_quad#torsion(21b6c25e127938e2).(); |
| 625 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 626 | } |
| 627 | |
| 628 | if (this_score > best_score) { |
| 629 | // std::cout << "Round " << itrial << " improved! was " << best_score |
| 630 | // << " now " << this_score << std::endl; |
| 631 | loggercxx . . $ logger..logcxx . . $ logging#log(86c7a9436785fa93).(log_tcxx . . $ log_t#::DEBUGcxx . . $ log_t#DEBUG., {cxx . . $ std/vector#vector(9619226211e5a241).stdcxx . . $ std/::stringcxx . . $ std/string#("Round"), itrial, |
| 632 | stdcxx . . $ std/::stringcxx . . $ std/string#("improvement - was"), best_score, |
| 633 | stdcxx . . $ std/::stringcxx . . $ std/string#("now"), this_score}); |
| 634 | // util::debug_z_weighted_density_score_new(atoms,xmap); |
| 635 | // save best torsion angles |
| 636 | best_score = this_score; |
| 637 | for (int iquad=0; iquad<n_quads; iquad++) |
| 638 | best_quads[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iquad] = quads[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iquad].torsioncxx . . $ coot/atom_quad#torsion(21b6c25e127938e2).(); |
| 639 | best_tree_dihedral_quads =cxx . . $ std/vector#`operator=`(e6b68e61becad66f). torsion_quads; |
| 640 | } |
| 641 | |
| 642 | if (false) { // debugging. |
| 643 | |
| 644 | // set the b-factor of the atoms to the score |
| 645 | int imod = 1; |
| 646 | mmdbcxx . . $ mmdb/::Modelcxx . . $ mmdb/Model# *model_p = mol->GetModelcxx . . $ mmdb/CoorManager#GetModel(58d7941c43ec3f04).(imod); |
| 647 | int n_chains = model_p->GetNumberOfChainscxx . . $ mmdb/Model#GetNumberOfChains(b126dc7c1de90089).(); |
| 648 | for (int ichain=0; ichain<n_chains; ichain++) { |
| 649 | mmdbcxx . . $ mmdb/::Chaincxx . . $ mmdb/Chain# *chain_p = model_p->GetChaincxx . . $ mmdb/Model#GetChain(ca72f112ae7cdd23).(ichain); |
| 650 | int nres = chain_p->GetNumberOfResiduescxx . . $ mmdb/Chain#GetNumberOfResidues(b126dc7c1de90089).(); |
| 651 | for (int ires=0; ires<nres; ires++) { |
| 652 | mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *residue_p = chain_p->GetResiduecxx . . $ mmdb/Chain#GetResidue(f580f598ef39565a).(ires); |
| 653 | int n_atoms = residue_p->GetNumberOfAtomscxx . . $ mmdb/Residue#GetNumberOfAtoms(b126dc7c1de90089).(); |
| 654 | for (int iat=0; iat<n_atoms; iat++) { |
| 655 | mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *at = residue_p->GetAtomcxx . . $ mmdb/Residue#GetAtom(3ff148469c8d2525).(iat); |
| 656 | at->tempFactorcxx . . $ mmdb/Atom#tempFactor. = this_score * 0.4; |
| 657 | at->tempFactorcxx . . $ mmdb/Atom#tempFactor. = self_clash_score; |
| 658 | } |
| 659 | } |
| 660 | } |
| 661 | stdcxx . . $ std/::stringcxx . . $ std/string# file_name = "trial-" +cxx . . $ std/operator+(39ed2c165380f78e). utilcxx . . $ coot/util/::int_to_stringcxx . . $ coot/util/int_to_string(7eb93f795f0defb3).(itrial) +cxx . . $ std/operator+(900ec9581c410ad9). ".pdb"; |
| 662 | mol->WritePDBASCIIcxx . . $ mmdb/Root#WritePDBASCII(9eb88f3d8809bd24).(file_name.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 663 | } |
| 664 | } |
| 665 | } |
| 666 | if (!best_tree_dihedral_quads.emptycxx . . $ std/vector#empty(3482b152b9333168).()) { |
| 667 | // std::string fn = "pre-set-dihedrals-for-best.pdb"; |
| 668 | // mol->WritePDBASCII(fn.c_str()); |
| 669 | tree.set_dihedral_multicxx . . $ coot/atom_tree_t#set_dihedral_multi(db173d5632df38c6).(best_tree_dihedral_quads); |
| 670 | // fn = "post-set-dihedrals-for-best.pdb"; |
| 671 | //mol->WritePDBASCII(fn.c_str()); |
| 672 | } |
| 673 | mol->DeleteSelectioncxx . . $ mmdb/SelManager#DeleteSelection(d4f767463ce0a6b3).(selhnd); |
| 674 | } |
| 675 | } |
| 676 | catch (const stdcxx . . $ std/::runtime_errorcxx . . $ std/runtime_error# &rte) { |
| 677 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "WARNING:: " <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). rte.whatcxx . . $ std/runtime_error#what(ba32b354807b2b81).() <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 678 | } |
| 679 | } |
| 680 | |
| 681 | |
| 682 | double |
| 683 | cootcxx . . $ coot/::get_rand_anglecxx . . $ coot/get_rand_angle(78c22a727fba319c).(double current_angle, |
| 684 | const torsion_atom_quadcxx . . $ coot/torsion_atom_quad# &quad, |
| 685 | int itrial, int n_trials, |
| 686 | bool allow_conformer_switch, |
| 687 | bool small_torsion_changes) { |
| 688 | |
| 689 | double r = current_angle; |
| 690 | double minus_one_to_one = -1 + 2 * double(utilcxx . . $ coot/util/::randomcxx . . $ coot/util/random(da6335ded91d79c2).())/double(RAND_MAXcxx . . $ `<external>/10696550936717951914/stdlib.h:87:9`!); |
| 691 | // trial_factor goes from 0 (start) to 1 (end) |
| 692 | double trial_factor = double(itrial)/double(n_trials); |
| 693 | // double angle_scale_factor = 0.2 + 0.8*(1-trial_factor); |
| 694 | double angle_scale_factor = 0.2 + 0.8 - trial_factor; |
| 695 | |
| 696 | if (small_torsion_changes) { |
| 697 | r += 5.0 * minus_one_to_one; |
| 698 | } else { |
| 699 | r += 30 * minus_one_to_one * angle_scale_factor; |
| 700 | } |
| 701 | |
| 702 | // allow gauche+/gauche-/trans |
| 703 | if (allow_conformer_switch) { |
| 704 | double rn = float(utilcxx . . $ coot/util/::randomcxx . . $ coot/util/random(da6335ded91d79c2).())/float(RAND_MAXcxx . . $ `<external>/10696550936717951914/stdlib.h:87:9`!); |
| 705 | double tf = 1 - trial_factor; // tf goes from 1 (start) to 0 (end) |
| 706 | if (rn < (0.02 + 0.25 * tf)) { |
| 707 | double rn_2 = float(utilcxx . . $ coot/util/::randomcxx . . $ coot/util/random(da6335ded91d79c2).())/float(RAND_MAXcxx . . $ `<external>/10696550936717951914/stdlib.h:87:9`!); |
| 708 | double step = floor(6 * rn_2) * 60.0; |
| 709 | // std::cout << " step " << step << std::endl; |
| 710 | r += step; |
| 711 | } |
| 712 | } |
| 713 | |
| 714 | if (r > 360) |
| 715 | r -= 360; |
| 716 | |
| 717 | return r; |
| 718 | } |
| 719 | |
| 720 | |
| 721 | double |
| 722 | cootcxx . . $ coot/::get_self_clash_scorecxx . . $ coot/get_self_clash_score(2dd8cb3eb5ac13d0).(mmdbcxx . . $ mmdb/::Managercxx . . $ mmdb/Manager# *mol, |
| 723 | mmdbcxx . . $ mmdb/::PPAtomcxx . . $ mmdb/PPAtom# atom_selection, |
| 724 | int n_selected_atoms, |
| 725 | const stdcxx . . $ std/::vectorcxx . . $ std/vector#<torsion_atom_quadcxx . . $ coot/torsion_atom_quad#> &quads) { |
| 726 | |
| 727 | // Score is |
| 728 | // sum of (d-bump_max)^2 for atom pairs i,j where j<i where d < bump_max |
| 729 | |
| 730 | mmdbcxx . . $ mmdb/::realtypecxx . . $ mmdb/realtype# bump_max = 3.6; // find distances between atoms that are less than this. |
| 731 | bump_max = 2.8; // 20170615 try this (for less self bumping) |
| 732 | double clash_score = 0; |
| 733 | |
| 734 | // setup for SeekContacts(): |
| 735 | // |
| 736 | mmdbcxx . . $ mmdb/::Contactcxx . . $ mmdb/Contact# *pscontact = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 737 | int n_contacts; |
| 738 | long i_contact_group = 1; |
| 739 | mmdbcxx . . $ mmdb/::mat44cxx . . $ mmdb/mat44# my_matt; |
| 740 | for (int i=0; i<4; i++) |
| 741 | for (int j=0; j<4; j++) |
| 742 | my_matt[i][j] = 0.0; |
| 743 | for (int i=0; i<4; i++) my_matt[i][i] = 1.0; |
| 744 | |
| 745 | mol->SeekContactscxx . . $ mmdb/CoorManager#SeekContacts(e8f2dd3d46e5da7a).(atom_selection, n_selected_atoms, |
| 746 | atom_selection, n_selected_atoms, |
| 747 | 0.001, bump_max, |
| 748 | 0, // seqDist: 1 means in different residues, |
| 749 | // but if I set that, then no contacts are found |
| 750 | // even for atoms that are in different residues: |
| 751 | // mmdb bug. |
| 752 | pscontact, n_contacts, |
| 753 | 0, &my_matt, i_contact_group); |
| 754 | |
| 755 | if (n_contacts > 0) { |
| 756 | if (pscontact) { |
| 757 | for (int i=0; i<n_contacts; i++) { |
| 758 | if (pscontact[i].id1cxx . . $ mmdb/Contact#id1. < pscontact[i].id2cxx . . $ mmdb/Contact#id2.) { |
| 759 | mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *at_1 = atom_selection[pscontact[i].id1cxx . . $ mmdb/Contact#id1.]; |
| 760 | mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *at_2 = atom_selection[pscontact[i].id2cxx . . $ mmdb/Contact#id2.]; |
| 761 | if (at_1->residuecxx . . $ mmdb/Atom#residue. != at_2->residuecxx . . $ mmdb/Atom#residue.) { |
| 762 | stdcxx . . $ std/::stringcxx . . $ std/string# e1 = at_1cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).->elementcxx . . $ mmdb/Atom#element.; |
| 763 | stdcxx . . $ std/::stringcxx . . $ std/string# e2 = at_2cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).->elementcxx . . $ mmdb/Atom#element.; |
| 764 | |
| 765 | if ((e1 != " H") && (e2 != " H")) { // PDB vs 3 FIXME |
| 766 | // ignore bumps to O5 (e.g. O4(prev)-O5(new)) on newly added residue |
| 767 | |
| 768 | stdcxx . . $ std/::stringcxx . . $ std/string# atom_name_2 = at_2cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).->namecxx . . $ mmdb/Atom#name.; |
| 769 | if (atom_name_2 != " O5 ") { |
| 770 | double d_sqd = |
| 771 | (at_1->xcxx . . $ mmdb/Atom#x.-at_2->xcxx . . $ mmdb/Atom#x.) * (at_1->xcxx . . $ mmdb/Atom#x.-at_2->xcxx . . $ mmdb/Atom#x.) + |
| 772 | (at_1->ycxx . . $ mmdb/Atom#y.-at_2->ycxx . . $ mmdb/Atom#y.) * (at_1->ycxx . . $ mmdb/Atom#y.-at_2->ycxx . . $ mmdb/Atom#y.) + |
| 773 | (at_1->zcxx . . $ mmdb/Atom#z.-at_2->zcxx . . $ mmdb/Atom#z.) * (at_1->zcxx . . $ mmdb/Atom#z.-at_2->zcxx . . $ mmdb/Atom#z.); |
| 774 | |
| 775 | // are they either in a bond, angle or torsion of any of quads? |
| 776 | // |
| 777 | bool in_a_tors = both_in_a_torsion_pcxx . . $ coot/both_in_a_torsion_p(3a1addb2c233894a).(at_1, at_2, quads); |
| 778 | if (! in_a_tors) { |
| 779 | double delta = bump_max - sqrt(d_sqd); |
| 780 | clash_score += delta * delta; |
| 781 | if (false) |
| 782 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "adding to clash_score " <<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). delta * delta <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " for dist " <<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). sqrt(d_sqd) |
| 783 | <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " between " <<cxx . . $ coot/`operator<<`(f8fcd6198bb35afb). atom_spec_tcxx . . $ coot/atom_spec_t#(at_1) <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " and " <<cxx . . $ coot/`operator<<`(f8fcd6198bb35afb). atom_spec_tcxx . . $ coot/atom_spec_t#(at_2) <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 784 | } |
| 785 | } |
| 786 | } |
| 787 | } |
| 788 | } |
| 789 | } |
| 790 | } |
| 791 | } |
| 792 | return clash_score; |
| 793 | } |
| 794 | |
| 795 | |
| 796 | bool |
| 797 | cootcxx . . $ coot/::both_in_a_torsion_pcxx . . $ coot/both_in_a_torsion_p(3a1addb2c233894a).(mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *at_1, |
| 798 | mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *at_2, |
| 799 | const stdcxx . . $ std/::vectorcxx . . $ std/vector#<torsion_atom_quadcxx . . $ coot/torsion_atom_quad#> &quads) { |
| 800 | |
| 801 | // this doesn't check angles and (non-dictionary) torsion that are |
| 802 | // made as a results of the link but not in a torsion. |
| 803 | |
| 804 | bool in_a_tors = false; |
| 805 | for (unsigned int i=0; i<quads.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); i++) { |
| 806 | bool found_at_1 = false; |
| 807 | bool found_at_2 = false; |
| 808 | const torsion_atom_quadcxx . . $ coot/torsion_atom_quad# &q = quads[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).i]; |
| 809 | if (q.atom_1cxx . . $ coot/atom_quad#atom_1. == at_1) found_at_1 = true; |
| 810 | if (q.atom_2cxx . . $ coot/atom_quad#atom_2. == at_1) found_at_1 = true; |
| 811 | if (q.atom_3cxx . . $ coot/atom_quad#atom_3. == at_1) found_at_1 = true; |
| 812 | if (q.atom_4cxx . . $ coot/atom_quad#atom_4. == at_1) found_at_1 = true; |
| 813 | if (q.atom_1cxx . . $ coot/atom_quad#atom_1. == at_2) found_at_2 = true; |
| 814 | if (q.atom_2cxx . . $ coot/atom_quad#atom_2. == at_2) found_at_2 = true; |
| 815 | if (q.atom_3cxx . . $ coot/atom_quad#atom_3. == at_2) found_at_2 = true; |
| 816 | if (q.atom_4cxx . . $ coot/atom_quad#atom_4. == at_2) found_at_2 = true; |
| 817 | if (found_at_1 && found_at_2) { |
| 818 | in_a_tors = true; |
| 819 | break; |
| 820 | } |
| 821 | } |
| 822 | return in_a_tors; |
| 823 | } |
| 824 | |
| 825 | // return a positive number for a clash - the bigger the number the worse the clash. |
| 826 | // |
| 827 | double |
| 828 | cootcxx . . $ coot/::get_environment_clash_scorecxx . . $ coot/get_environment_clash_score(eab3807a5700080c).(mmdbcxx . . $ mmdb/::Managercxx . . $ mmdb/Manager# *mol, |
| 829 | mmdbcxx . . $ mmdb/::PPAtomcxx . . $ mmdb/PPAtom# atom_selection, |
| 830 | int n_selected_atoms, |
| 831 | const stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<bool, clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth#> > &avoid_these_atoms) { |
| 832 | double cs = 0; |
| 833 | double sf = 1.0; |
| 834 | for (int iat=0; iat<n_selected_atoms; iat++) { |
| 835 | // we expect that the ASN will be close to its polypeptide neighbours. We don't want to |
| 836 | // include such clashes |
| 837 | stdcxx . . $ std/::stringcxx . . $ std/string# res_name = atom_selectioncxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).[iat]->GetResNamecxx . . $ mmdb/Atom#GetResName(41208ce6ca65dd58).(); |
| 838 | // std::cout << "res_name is " << res_name << std::endl; |
| 839 | if (res_name != "ASN") { |
| 840 | clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# at_pt = cocxx . . $ coot/co(83465a92f19cbf90).(atom_selection[iat]); |
| 841 | for (unsigned int jat=0; jat<avoid_these_atoms.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); jat++) { |
| 842 | double close_lim = 3.3; |
| 843 | if (avoid_these_atoms[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).jat].firstcxx . . $ std/pair#first.) close_lim = 2.5; // we can get close to waters without worry |
| 844 | double close_lim_sqrd = close_lim * close_lim; |
| 845 | double d_sqd = (at_pt -cxx . . $ clipper/operator-(44ad1d8741e04b17). avoid_these_atoms[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).jat].secondcxx . . $ std/pair#second.).lengthsqcxx . . $ clipper/Coord_orth#lengthsq(21b6c25e127938e2).(); |
| 846 | if (d_sqd < close_lim_sqrd) { |
| 847 | double diff = close_lim - sqrt(d_sqd); |
| 848 | cs += diff*diff*sf; |
| 849 | if (false) |
| 850 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "DEBUG:: env clash: atom " <<cxx . . $ coot/`operator<<`(f8fcd6198bb35afb). atom_spec_tcxx . . $ coot/atom_spec_t#(atom_selection[iat]) <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " is close to " |
| 851 | <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). jat <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " <<cxx . . $ std/`operator<<`(88df5bef833f7f83). avoid_these_atoms[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).jat].secondcxx . . $ std/pair#second..formatcxx . . $ clipper/Coord_orth#format(9c83e4702554ac51).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " <<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). sqrt(d_sqd) <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 852 | } |
| 853 | } |
| 854 | } |
| 855 | } |
| 856 | return cs; |
| 857 | } |