| 1 | /* |
| 2 | * geometry/residue-and-atom-specs.cc |
| 3 | * |
| 4 | * Copyright 2016 by Medical Research Council |
| 5 | * Author: Paul Emsley |
| 6 | * |
| 7 | * This file is part of Coot |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU Lesser General Public License as published |
| 11 | * by the Free Software Foundation; either version 3 of the License, or (at |
| 12 | * your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, but |
| 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 | * Lesser General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copies of the GNU General Public License and |
| 20 | * the GNU Lesser General Public License along with this program; if not, |
| 21 | * write to the Free Software Foundation, Inc., 51 Franklin Street, |
| 22 | * Fifth Floor, Boston, MA, 02110-1301, USA. |
| 23 | * See http://www.gnu.org/licenses/ |
| 24 | * |
| 25 | */ |
| 26 | |
| 27 | #include <iostream> |
| 28 | #include "utils/coot-utils.hh"cxx . . $ `<file>/utils/coot-utils.hh`/ |
| 29 | #include "residue-and-atom-specs.hh"cxx . . $ `<file>/geometry/residue-and-atom-specs.hh`/ |
| 30 | |
| 31 | std::ostreamcxx . . $ std/ostream#& cootcxx . . $ coot/::operatorcxx . . $ coot/`operator<<`(f8fcd6198bb35afb).<< (std::ostreamcxx . . $ std/ostream#& s, const cootcxx . . $ coot/::atom_spec_tcxx . . $ coot/atom_spec_t# &spec) { |
| 32 | |
| 33 | std::stringcxx . . $ std/string# rn = std::to_stringcxx . . $ std/__cxx11/to_string(3d81e17e7a87eecc).(spec.res_nocxx . . $ coot/atom_spec_t#res_no.); |
| 34 | if (spec.res_nocxx . . $ coot/atom_spec_t#res_no. >= 0) { |
| 35 | if (rn.sizecxx . . $ std/__cxx11/basic_string#size(7e80fff40d76986b).() == 1) rn =cxx . . $ std/__cxx11/basic_string#`operator=`(36befb0d0c9f966). " " +cxx . . $ std/operator+(42c652dfebe55ad7). rn; |
| 36 | if (rn.sizecxx . . $ std/__cxx11/basic_string#size(7e80fff40d76986b).() == 2) rn =cxx . . $ std/__cxx11/basic_string#`operator=`(36befb0d0c9f966). " " +cxx . . $ std/operator+(42c652dfebe55ad7). rn; |
| 37 | if (rn.sizecxx . . $ std/__cxx11/basic_string#size(7e80fff40d76986b).() == 3) rn =cxx . . $ std/__cxx11/basic_string#`operator=`(36befb0d0c9f966). " " +cxx . . $ std/operator+(42c652dfebe55ad7). rn; |
| 38 | } |
| 39 | |
| 40 | s <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "[spec: "; |
| 41 | s <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "model "; |
| 42 | s <<cxx . . $ std/basic_ostream#`operator<<`(23b6575433a77e57). spec.model_numbercxx . . $ coot/atom_spec_t#model_number.; |
| 43 | s <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " "; |
| 44 | s <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\""; |
| 45 | s <<cxx . . $ std/`operator<<`(88df5bef833f7f83). spec.chain_idcxx . . $ coot/atom_spec_t#chain_id.; |
| 46 | s <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\" "; |
| 47 | s <<cxx . . $ std/`operator<<`(88df5bef833f7f83). rn; |
| 48 | s <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " "; |
| 49 | s <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\""; |
| 50 | s <<cxx . . $ std/`operator<<`(88df5bef833f7f83). spec.ins_codecxx . . $ coot/atom_spec_t#ins_code.; |
| 51 | s <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\""; |
| 52 | s <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " "; |
| 53 | s <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\""; |
| 54 | s <<cxx . . $ std/`operator<<`(88df5bef833f7f83). spec.atom_namecxx . . $ coot/atom_spec_t#atom_name.; |
| 55 | s <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\""; |
| 56 | s <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " "; |
| 57 | s <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\""; |
| 58 | s <<cxx . . $ std/`operator<<`(88df5bef833f7f83). spec.alt_confcxx . . $ coot/atom_spec_t#alt_conf.; |
| 59 | s <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\"]"; |
| 60 | |
| 61 | return s; |
| 62 | |
| 63 | } |
| 64 | |
| 65 | std::ostreamcxx . . $ std/ostream#& cootcxx . . $ coot/::operatorcxx . . $ coot/`operator<<`(864abc555d23019c).<< (std::ostreamcxx . . $ std/ostream#& s, const cootcxx . . $ coot/::residue_spec_tcxx . . $ coot/residue_spec_t# &spec) { |
| 66 | |
| 67 | if (!spec.unset_pcxx . . $ coot/residue_spec_t#unset_p(50ce9a9e25b4a850).()) { |
| 68 | |
| 69 | s <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "[spec: "; |
| 70 | // s << "{{debug:: mmdb::MinInt4 is " << MinInt4 << "}} "; |
| 71 | if (spec.model_numbercxx . . $ coot/residue_spec_t#model_number. == mmdbcxx . . $ mmdb/::MinInt4cxx . . $ mmdb/MinInt4.) |
| 72 | s <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "mmdb::MinInt4"; |
| 73 | else |
| 74 | s <<cxx . . $ std/basic_ostream#`operator<<`(23b6575433a77e57). spec.model_numbercxx . . $ coot/residue_spec_t#model_number.; |
| 75 | |
| 76 | s <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " \""; |
| 77 | s <<cxx . . $ std/`operator<<`(88df5bef833f7f83). spec.chain_idcxx . . $ coot/residue_spec_t#chain_id.; |
| 78 | s <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\" "; |
| 79 | s <<cxx . . $ std/basic_ostream#`operator<<`(23b6575433a77e57). spec.res_nocxx . . $ coot/residue_spec_t#res_no.; |
| 80 | s <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " "; |
| 81 | s <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\""; |
| 82 | s <<cxx . . $ std/`operator<<`(88df5bef833f7f83). spec.ins_codecxx . . $ coot/residue_spec_t#ins_code.; |
| 83 | s <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\"]"; |
| 84 | } else { |
| 85 | s <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "{residue-spec-not-set}"; |
| 86 | } |
| 87 | return s; |
| 88 | |
| 89 | } |
| 90 | |
| 91 | // 20221028-PE move format into the .cc file so that we don't have << SWIG problems. |
| 92 | std::stringcxx . . $ std/string# |
| 93 | cootcxx . . $ coot/::atom_spec_tcxx . . $ coot/atom_spec_t#::formatcxx . . $ coot/atom_spec_t#format(219584694fe2b248).() const { |
| 94 | std::ostringstreamcxx . . $ std/ostringstream# scxx . . $ std/__cxx11/basic_ostringstream#basic_ostringstream(49f6e7a06ebc5aa8).; |
| 95 | if (!cxx . . $ std/basic_ios#`operator!`(50ce9a9e25b4a850).(s <<cxx . . $ coot/`operator<<`(f8fcd6198bb35afb). *this)) |
| 96 | return ""cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).; |
| 97 | return s.strcxx . . $ std/__cxx11/basic_ostringstream#str(b020c59b86b1b104).(); |
| 98 | } |
| 99 | |
| 100 | std::stringcxx . . $ std/string# |
| 101 | cootcxx . . $ coot/::residue_spec_tcxx . . $ coot/residue_spec_t#::formatcxx . . $ coot/residue_spec_t#format(219584694fe2b248).() const { |
| 102 | std::ostringstreamcxx . . $ std/ostringstream# scxx . . $ std/__cxx11/basic_ostringstream#basic_ostringstream(49f6e7a06ebc5aa8).; |
| 103 | if (!cxx . . $ std/basic_ios#`operator!`(50ce9a9e25b4a850).(s <<cxx . . $ coot/`operator<<`(864abc555d23019c). *this)) |
| 104 | return ""cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).; |
| 105 | return s.strcxx . . $ std/__cxx11/basic_ostringstream#str(b020c59b86b1b104).(); |
| 106 | } |
| 107 | |
| 108 | |
| 109 | // formatted as if you'd clicked on it in the graphics window |
| 110 | // But the residue type is missing - see below |
| 111 | std::stringcxx . . $ std/string# |
| 112 | cootcxx . . $ coot/::atom_spec_tcxx . . $ coot/atom_spec_t#::labelcxx . . $ coot/atom_spec_t#label(219584694fe2b248).() const { |
| 113 | std::stringcxx . . $ std/string# scxx . . $ std/__cxx11/basic_string#basic_string(925dcc5e17f50391).; |
| 114 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). utilcxx . . $ coot/util/::remove_whitespacecxx . . $ coot/util/remove_whitespace(fd626fc03107dd24).(atom_namecxx . . $ coot/atom_spec_t#atom_name.); |
| 115 | if (! alt_confcxx . . $ coot/atom_spec_t#alt_conf..emptycxx . . $ std/__cxx11/basic_string#empty(3482b152b9333168).()) { |
| 116 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). ","; |
| 117 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). alt_confcxx . . $ coot/atom_spec_t#alt_conf.; |
| 118 | } |
| 119 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). "/"; |
| 120 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). utilcxx . . $ coot/util/::int_to_stringcxx . . $ coot/util/int_to_string(7eb93f795f0defb3).(res_nocxx . . $ coot/atom_spec_t#res_no.); |
| 121 | if (! ins_codecxx . . $ coot/atom_spec_t#ins_code..emptycxx . . $ std/__cxx11/basic_string#empty(3482b152b9333168).()) { |
| 122 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). ","; |
| 123 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). ins_codecxx . . $ coot/atom_spec_t#ins_code.; |
| 124 | } |
| 125 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). "/"; |
| 126 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). chain_idcxx . . $ coot/atom_spec_t#chain_id.; |
| 127 | return scxx . . $ std/__cxx11/basic_string#basic_string(8f3aaafa33d05d0b).; |
| 128 | } |
| 129 | |
| 130 | std::stringcxx . . $ std/string# |
| 131 | cootcxx . . $ coot/::atom_spec_tcxx . . $ coot/atom_spec_t#::simple_labelcxx . . $ coot/atom_spec_t#simple_label(ed3976f106e8bf8e).(const std::stringcxx . . $ std/string# &residue_name) const { |
| 132 | std::stringcxx . . $ std/string# scxx . . $ std/__cxx11/basic_string#basic_string(925dcc5e17f50391).; |
| 133 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). chain_idcxx . . $ coot/atom_spec_t#chain_id.; |
| 134 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). " "; |
| 135 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). utilcxx . . $ coot/util/::int_to_stringcxx . . $ coot/util/int_to_string(7eb93f795f0defb3).(res_nocxx . . $ coot/atom_spec_t#res_no.); |
| 136 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). " "; |
| 137 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). utilcxx . . $ coot/util/::remove_whitespacecxx . . $ coot/util/remove_whitespace(fd626fc03107dd24).(atom_namecxx . . $ coot/atom_spec_t#atom_name.); |
| 138 | if (! residue_name.emptycxx . . $ std/__cxx11/basic_string#empty(3482b152b9333168).()) { |
| 139 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). " "; |
| 140 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). residue_name; |
| 141 | } |
| 142 | return scxx . . $ std/__cxx11/basic_string#basic_string(8f3aaafa33d05d0b).; |
| 143 | } |
| 144 | |
| 145 | |
| 146 | |
| 147 | // formatted as if you'd clicked on it in the graphics window |
| 148 | // Use the passed residue type. |
| 149 | std::stringcxx . . $ std/string# |
| 150 | cootcxx . . $ coot/::atom_spec_tcxx . . $ coot/atom_spec_t#::labelcxx . . $ coot/atom_spec_t#label(ed3976f106e8bf8e).(const std::stringcxx . . $ std/string# &residue_name) const { |
| 151 | std::stringcxx . . $ std/string# scxx . . $ std/__cxx11/basic_string#basic_string(925dcc5e17f50391).; |
| 152 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). atom_namecxx . . $ coot/atom_spec_t#atom_name.; |
| 153 | if (! alt_confcxx . . $ coot/atom_spec_t#alt_conf..emptycxx . . $ std/__cxx11/basic_string#empty(3482b152b9333168).()) { |
| 154 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). ","; |
| 155 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). alt_confcxx . . $ coot/atom_spec_t#alt_conf.; |
| 156 | } |
| 157 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). "/"; |
| 158 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). utilcxx . . $ coot/util/::int_to_stringcxx . . $ coot/util/int_to_string(7eb93f795f0defb3).(res_nocxx . . $ coot/atom_spec_t#res_no.); |
| 159 | if (! ins_codecxx . . $ coot/atom_spec_t#ins_code..emptycxx . . $ std/__cxx11/basic_string#empty(3482b152b9333168).()) { |
| 160 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). ","; |
| 161 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). ins_codecxx . . $ coot/atom_spec_t#ins_code.; |
| 162 | } |
| 163 | if (! residue_name.emptycxx . . $ std/__cxx11/basic_string#empty(3482b152b9333168).()) { |
| 164 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). " "; |
| 165 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). residue_name; |
| 166 | } |
| 167 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). "/"; |
| 168 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). chain_idcxx . . $ coot/atom_spec_t#chain_id.; |
| 169 | return scxx . . $ std/__cxx11/basic_string#basic_string(8f3aaafa33d05d0b).; |
| 170 | } |
| 171 | |
| 172 | // formatted as if you'd clicked on it in the graphics window |
| 173 | // But the residue type is missing - see below |
| 174 | std::stringcxx . . $ std/string# |
| 175 | cootcxx . . $ coot/::residue_spec_tcxx . . $ coot/residue_spec_t#::labelcxx . . $ coot/residue_spec_t#label(219584694fe2b248).() const { |
| 176 | std::stringcxx . . $ std/string# scxx . . $ std/__cxx11/basic_string#basic_string(925dcc5e17f50391).; |
| 177 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). utilcxx . . $ coot/util/::int_to_stringcxx . . $ coot/util/int_to_string(7eb93f795f0defb3).(res_nocxx . . $ coot/residue_spec_t#res_no.); |
| 178 | if (! ins_codecxx . . $ coot/residue_spec_t#ins_code..emptycxx . . $ std/__cxx11/basic_string#empty(3482b152b9333168).()) { |
| 179 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). ","; |
| 180 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). ins_codecxx . . $ coot/residue_spec_t#ins_code.; |
| 181 | } |
| 182 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). "/"; |
| 183 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). chain_idcxx . . $ coot/residue_spec_t#chain_id.; |
| 184 | return scxx . . $ std/__cxx11/basic_string#basic_string(8f3aaafa33d05d0b).; |
| 185 | } |
| 186 | |
| 187 | |
| 188 | // formatted as if you'd clicked on it in the graphics window |
| 189 | // Use the passed residue type. |
| 190 | std::stringcxx . . $ std/string# |
| 191 | cootcxx . . $ coot/::residue_spec_tcxx . . $ coot/residue_spec_t#::labelcxx . . $ coot/residue_spec_t#label(ed3976f106e8bf8e).(const std::stringcxx . . $ std/string# &residue_name) const { |
| 192 | std::stringcxx . . $ std/string# scxx . . $ std/__cxx11/basic_string#basic_string(925dcc5e17f50391).; |
| 193 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). utilcxx . . $ coot/util/::int_to_stringcxx . . $ coot/util/int_to_string(7eb93f795f0defb3).(res_nocxx . . $ coot/residue_spec_t#res_no.); |
| 194 | if (! ins_codecxx . . $ coot/residue_spec_t#ins_code..emptycxx . . $ std/__cxx11/basic_string#empty(3482b152b9333168).()) { |
| 195 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). ","; |
| 196 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). ins_codecxx . . $ coot/residue_spec_t#ins_code.; |
| 197 | } |
| 198 | if (! residue_name.emptycxx . . $ std/__cxx11/basic_string#empty(3482b152b9333168).()) { |
| 199 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). " "; |
| 200 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). residue_name; |
| 201 | } |
| 202 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). "/"; |
| 203 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). chain_idcxx . . $ coot/residue_spec_t#chain_id.; |
| 204 | return scxx . . $ std/__cxx11/basic_string#basic_string(8f3aaafa33d05d0b).; |
| 205 | } |
| 206 | |
| 207 | // return null on failure to find residue in mol |
| 208 | mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# * |
| 209 | cootcxx . . $ coot/::residue_spec_tcxx . . $ coot/residue_spec_t#::get_residuecxx . . $ coot/residue_spec_t#get_residue(ebb2d1b242974239).(mmdbcxx . . $ mmdb/::Managercxx . . $ mmdb/Manager# *mol) const { |
| 210 | |
| 211 | mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *r = 0; |
| 212 | int imod = 1; |
| 213 | mmdbcxx . . $ mmdb/::Modelcxx . . $ mmdb/Model# *model_p = mol->GetModelcxx . . $ mmdb/CoorManager#GetModel(58d7941c43ec3f04).(imod); |
| 214 | if (model_p) { |
| 215 | int n_chains = model_p->GetNumberOfChainscxx . . $ mmdb/Model#GetNumberOfChains(b126dc7c1de90089).(); |
| 216 | for (int ichain=0; ichain<n_chains; ichain++) { |
| 217 | mmdbcxx . . $ mmdb/::Chaincxx . . $ mmdb/Chain# *chain_p = model_p->GetChaincxx . . $ mmdb/Model#GetChain(ca72f112ae7cdd23).(ichain); |
| 218 | std::stringcxx . . $ std/string# this_chain_idcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).(chain_p->GetChainIDcxx . . $ mmdb/Chain#GetChainID(33a1f659e94feb42).()); |
| 219 | if (this_chain_id ==cxx . . $ std/`operator==`(5ea818b58063a774). chain_idcxx . . $ coot/residue_spec_t#chain_id.) { |
| 220 | int nres = chain_p->GetNumberOfResiduescxx . . $ mmdb/Chain#GetNumberOfResidues(b126dc7c1de90089).(); |
| 221 | for (int ires=0; ires<nres; ires++) { |
| 222 | mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *residue_p = chain_p->GetResiduecxx . . $ mmdb/Chain#GetResidue(f580f598ef39565a).(ires); |
| 223 | int this_res_no = residue_p->GetSeqNumcxx . . $ mmdb/Residue#GetSeqNum(b126dc7c1de90089).(); |
| 224 | if (this_res_no == this->res_nocxx . . $ coot/residue_spec_t#res_no.) { |
| 225 | int n_atoms = residue_p->GetNumberOfAtomscxx . . $ mmdb/Residue#GetNumberOfAtoms(b126dc7c1de90089).(); |
| 226 | if (n_atoms > 0) { |
| 227 | r = residue_p; |
| 228 | } |
| 229 | } |
| 230 | if (r) break; |
| 231 | } |
| 232 | } |
| 233 | if (r) break; |
| 234 | } |
| 235 | } |
| 236 | return r; |
| 237 | } |
| 238 | |
| 239 | |
| 240 | // return null on failure to find atom in mol |
| 241 | // (this is the inside out version of the function in molecule_class_info_t) |
| 242 | mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# * |
| 243 | cootcxx . . $ coot/::atom_spec_tcxx . . $ coot/atom_spec_t#::get_atomcxx . . $ coot/atom_spec_t#get_atom(57efba27b46d7a2e).(mmdbcxx . . $ mmdb/::Managercxx . . $ mmdb/Manager# *mol) const { |
| 244 | |
| 245 | mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *at = 0; |
| 246 | int imod = 1; |
| 247 | mmdbcxx . . $ mmdb/::Modelcxx . . $ mmdb/Model# *model_p = mol->GetModelcxx . . $ mmdb/CoorManager#GetModel(58d7941c43ec3f04).(imod); |
| 248 | if (model_p) { |
| 249 | int n_chains = model_p->GetNumberOfChainscxx . . $ mmdb/Model#GetNumberOfChains(b126dc7c1de90089).(); |
| 250 | for (int ichain=0; ichain<n_chains; ichain++) { |
| 251 | mmdbcxx . . $ mmdb/::Chaincxx . . $ mmdb/Chain# *chain_p = model_p->GetChaincxx . . $ mmdb/Model#GetChain(ca72f112ae7cdd23).(ichain); |
| 252 | std::stringcxx . . $ std/string# this_chain_idcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).(chain_p->GetChainIDcxx . . $ mmdb/Chain#GetChainID(33a1f659e94feb42).()); |
| 253 | if (this_chain_id ==cxx . . $ std/`operator==`(5ea818b58063a774). chain_idcxx . . $ coot/atom_spec_t#chain_id.) { |
| 254 | int nres = chain_p->GetNumberOfResiduescxx . . $ mmdb/Chain#GetNumberOfResidues(b126dc7c1de90089).(); |
| 255 | for (int ires=0; ires<nres; ires++) { |
| 256 | mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *residue_p = chain_p->GetResiduecxx . . $ mmdb/Chain#GetResidue(f580f598ef39565a).(ires); |
| 257 | int this_res_no = residue_p->GetSeqNumcxx . . $ mmdb/Residue#GetSeqNum(b126dc7c1de90089).(); |
| 258 | if (this_res_no == this->res_nocxx . . $ coot/atom_spec_t#res_no.) { |
| 259 | int n_atoms = residue_p->GetNumberOfAtomscxx . . $ mmdb/Residue#GetNumberOfAtoms(b126dc7c1de90089).(); |
| 260 | for (int iat=0; iat<n_atoms; iat++) { |
| 261 | mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *this_at = residue_p->GetAtomcxx . . $ mmdb/Residue#GetAtom(3ff148469c8d2525).(iat); |
| 262 | if (! this_at->isTercxx . . $ mmdb/Atom#isTer(c9857a73d68e59ba).()) { |
| 263 | std::stringcxx . . $ std/string# this_atom_namecxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).(this_at->GetAtomNamecxx . . $ mmdb/Atom#GetAtomName(41208ce6ca65dd58).()); |
| 264 | std::stringcxx . . $ std/string# this_alt_loc = (cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).this_at->altLoccxx . . $ mmdb/Atom#altLoc.); |
| 265 | if (this_atom_name ==cxx . . $ std/`operator==`(5ea818b58063a774). this->atom_namecxx . . $ coot/atom_spec_t#atom_name.) { |
| 266 | if (this_alt_loc ==cxx . . $ std/`operator==`(5ea818b58063a774). this->alt_confcxx . . $ coot/atom_spec_t#alt_conf.) { |
| 267 | at = this_at; |
| 268 | } |
| 269 | } |
| 270 | } |
| 271 | if (at) break; |
| 272 | } |
| 273 | if (at) break; |
| 274 | } |
| 275 | if (at) break; |
| 276 | } |
| 277 | if (at) break; |
| 278 | } |
| 279 | if (at) break; |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | return at; |
| 284 | } |
| 285 | |
| 286 | |
| 287 | |
| 288 | bool |
| 289 | cootcxx . . $ coot/::atom_spec_tcxx . . $ coot/atom_spec_t#::matches_speccxx . . $ coot/atom_spec_t#matches_spec(1e73f121d2740c1c).(mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *atom) const { |
| 290 | |
| 291 | if (atom_namecxx . . $ coot/atom_spec_t#atom_name. ==cxx . . $ std/`operator==`(5ea818b58063a774). stdcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).::stringcxx . . $ std/string#(atom->namecxx . . $ mmdb/Atom#name.)) { |
| 292 | |
| 293 | if (alt_confcxx . . $ coot/atom_spec_t#alt_conf. ==cxx . . $ std/`operator==`(5ea818b58063a774). stdcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).::stringcxx . . $ std/string#(atom->altLoccxx . . $ mmdb/Atom#altLoc.)) { |
| 294 | |
| 295 | mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *residue_p = atom->residuecxx . . $ mmdb/Atom#residue.; |
| 296 | |
| 297 | if (residue_p) { |
| 298 | |
| 299 | if (res_nocxx . . $ coot/atom_spec_t#res_no. == atom->GetSeqNumcxx . . $ mmdb/Atom#GetSeqNum(b126dc7c1de90089).()) { |
| 300 | |
| 301 | if (ins_codecxx . . $ coot/atom_spec_t#ins_code. ==cxx . . $ std/`operator==`(5ea818b58063a774). stdcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).::stringcxx . . $ std/string#(atom->GetInsCodecxx . . $ mmdb/Atom#GetInsCode(41208ce6ca65dd58).())) { |
| 302 | |
| 303 | mmdbcxx . . $ mmdb/::Chaincxx . . $ mmdb/Chain# *chain_p= atom->GetChaincxx . . $ mmdb/Atom#GetChain(e137625bce114105).(); |
| 304 | if (chain_p) { |
| 305 | if (chain_idcxx . . $ coot/atom_spec_t#chain_id. ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). chain_p->GetChainIDcxx . . $ mmdb/Chain#GetChainID(33a1f659e94feb42).()) { |
| 306 | // std::cout << atom_name << "a complete match " << std::endl; |
| 307 | return 1; |
| 308 | } else { |
| 309 | // std::cout << atom_name << "a chain mismatch " << std::endl; |
| 310 | return 0; |
| 311 | } |
| 312 | } else { |
| 313 | // std::cout << atom_name << "a no chain match " << std::endl; |
| 314 | // no chain |
| 315 | return 1; |
| 316 | } |
| 317 | } else { |
| 318 | // std::cout << atom_name << "an inscode mismatch " << std::endl; |
| 319 | return 0; |
| 320 | } |
| 321 | } else { |
| 322 | // std::cout << atom_name << "a resno mismatch " << std::endl; |
| 323 | return 0; |
| 324 | } |
| 325 | |
| 326 | } else { |
| 327 | // no residue |
| 328 | // std::cout << atom_name << "a no chain match " << std::endl; |
| 329 | return 1; |
| 330 | } |
| 331 | } else { |
| 332 | // std::cout << atom_name << "an altloc mismatch " << std::endl; |
| 333 | return 0; |
| 334 | } |
| 335 | } else { |
| 336 | // std::cout << atom_name << "an atom name mismatch :" << atom->name << ":" << std::endl; |
| 337 | return 0; |
| 338 | } |
| 339 | std::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(88df5bef833f7f83). atom_namecxx . . $ coot/atom_spec_t#atom_name. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " should not happen (matches_spec()) " <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). atom->namecxx . . $ mmdb/Atom#name. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). ":" <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). std::endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 340 | return 0; |
| 341 | } |
| 342 | |
| 343 | // return an atom selection handle for the selection in the mol |
| 344 | // that matches the spec. |
| 345 | // |
| 346 | int |
| 347 | cootcxx . . $ coot/::residue_spec_tcxx . . $ coot/residue_spec_t#::select_atomscxx . . $ coot/residue_spec_t#select_atoms(d9804adb083cb67f).(mmdbcxx . . $ mmdb/::Managercxx . . $ mmdb/Manager# *mol, int selhnd, |
| 348 | mmdbcxx . . $ mmdb/::SELECTION_KEYcxx . . $ mmdb/SELECTION_KEY# selection_key) { |
| 349 | |
| 350 | if (mol) { |
| 351 | mol->SelectAtomscxx . . $ mmdb/SelManager#SelectAtoms(395440d8c4963665).(selhnd, 0, chain_idcxx . . $ coot/residue_spec_t#chain_id..c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(), |
| 352 | res_nocxx . . $ coot/residue_spec_t#res_no., ins_codecxx . . $ coot/residue_spec_t#ins_code..c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(), |
| 353 | res_nocxx . . $ coot/residue_spec_t#res_no., ins_codecxx . . $ coot/residue_spec_t#ins_code..c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(), |
| 354 | "*", "*", "*", "*", selection_key); |
| 355 | } |
| 356 | return selhnd; |
| 357 | } |
| 358 | |
| 359 | |
| 360 | |
| 361 | // the header for this is (in) residue-and-atom-specs.hh. Hmm... should be fixed. |
| 362 | // |
| 363 | // model_p is a default argument, default 0/NULL (model_number is not set in the atom specs) |
| 364 | // |
| 365 | std::paircxx . . $ std/pair#<cootcxx . . $ coot/::atom_spec_tcxx . . $ coot/atom_spec_t#, cootcxx . . $ coot/::atom_spec_tcxx . . $ coot/atom_spec_t#> |
| 366 | cootcxx . . $ coot/::link_atomscxx . . $ coot/link_atoms(aedd0b426b7cf897).(mmdbcxx . . $ mmdb/::Linkcxx . . $ mmdb/Link# *link, mmdbcxx . . $ mmdb/::Modelcxx . . $ mmdb/Model# *model_p) { |
| 367 | |
| 368 | atom_spec_tcxx . . $ coot/atom_spec_t# a1cxx . . $ coot/atom_spec_t#atom_spec_t(ea0b0c109063a411).(linkcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).->chainID1cxx . . $ mmdb/Link#chainID1., link->seqNum1cxx . . $ mmdb/Link#seqNum1., linkcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).->insCode1cxx . . $ mmdb/Link#insCode1., linkcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).->atName1cxx . . $ mmdb/Link#atName1., linkcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).->aloc1cxx . . $ mmdb/Link#aloc1.); |
| 369 | atom_spec_tcxx . . $ coot/atom_spec_t# a2cxx . . $ coot/atom_spec_t#atom_spec_t(ea0b0c109063a411).(linkcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).->chainID2cxx . . $ mmdb/Link#chainID2., link->seqNum2cxx . . $ mmdb/Link#seqNum2., linkcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).->insCode2cxx . . $ mmdb/Link#insCode2., linkcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).->atName2cxx . . $ mmdb/Link#atName2., linkcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).->aloc2cxx . . $ mmdb/Link#aloc2.); |
| 370 | |
| 371 | if (model_p) { |
| 372 | int mn = model_p->GetSerNumcxx . . $ mmdb/Model#GetSerNum(b126dc7c1de90089).(); |
| 373 | a1.model_numbercxx . . $ coot/atom_spec_t#model_number. = mn; |
| 374 | a2.model_numbercxx . . $ coot/atom_spec_t#model_number. = mn; |
| 375 | } |
| 376 | |
| 377 | return stdcxx . . $ std/pair#pair(62e1774a2dc03c82).::paircxx . . $ std/pair#<cootcxx . . $ coot/::atom_spec_tcxx . . $ coot/atom_spec_t#, cootcxx . . $ coot/::atom_spec_tcxx . . $ coot/atom_spec_t#> (a1, a2); |
| 378 | } |
| 379 | // the header for this is (in) residue-and-atom-specs.hh. Hmm... should be fixed. |
| 380 | // |
| 381 | // model_p is a default argument, default 0/NULL (model_number is not set in the atom specs) |
| 382 | // |
| 383 | std::paircxx . . $ std/pair#<cootcxx . . $ coot/::atom_spec_tcxx . . $ coot/atom_spec_t#, cootcxx . . $ coot/::atom_spec_tcxx . . $ coot/atom_spec_t#> |
| 384 | cootcxx . . $ coot/::link_atomscxx . . $ coot/link_atoms(3e201362a98c7f32).(mmdbcxx . . $ mmdb/::LinkRcxx . . $ mmdb/LinkR# *link, mmdbcxx . . $ mmdb/::Modelcxx . . $ mmdb/Model# *model_p) { |
| 385 | |
| 386 | atom_spec_tcxx . . $ coot/atom_spec_t# a1cxx . . $ coot/atom_spec_t#atom_spec_t(ea0b0c109063a411).(linkcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).->chainID1cxx . . $ mmdb/LinkR#chainID1., link->seqNum1cxx . . $ mmdb/LinkR#seqNum1., linkcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).->insCode1cxx . . $ mmdb/LinkR#insCode1., linkcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).->atName1cxx . . $ mmdb/LinkR#atName1., linkcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).->aloc1cxx . . $ mmdb/LinkR#aloc1.); |
| 387 | atom_spec_tcxx . . $ coot/atom_spec_t# a2cxx . . $ coot/atom_spec_t#atom_spec_t(ea0b0c109063a411).(linkcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).->chainID2cxx . . $ mmdb/LinkR#chainID2., link->seqNum2cxx . . $ mmdb/LinkR#seqNum2., linkcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).->insCode2cxx . . $ mmdb/LinkR#insCode2., linkcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).->atName2cxx . . $ mmdb/LinkR#atName2., linkcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).->aloc2cxx . . $ mmdb/LinkR#aloc2.); |
| 388 | |
| 389 | if (model_p) { |
| 390 | int mn = model_p->GetSerNumcxx . . $ mmdb/Model#GetSerNum(b126dc7c1de90089).(); |
| 391 | a1.model_numbercxx . . $ coot/atom_spec_t#model_number. = mn; |
| 392 | a2.model_numbercxx . . $ coot/atom_spec_t#model_number. = mn; |
| 393 | } |
| 394 | |
| 395 | return stdcxx . . $ std/pair#pair(62e1774a2dc03c82).::paircxx . . $ std/pair#<cootcxx . . $ coot/::atom_spec_tcxx . . $ coot/atom_spec_t#, cootcxx . . $ coot/::atom_spec_tcxx . . $ coot/atom_spec_t#> (a1, a2); |
| 396 | } |
| 397 |