Debian Codegraph @

ligand/ideal-rna.cc

raw symbols SCIP
1 /* ligand/ideal-rna.cc
2 *
3 * Copyright 2006 The University of York
4 * Copyright 2009 by the University of Oxford
5 * Author: Paul Emsley
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or (at
10 * your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22 #include <iostream>
23
24 #include "coot-utils/coot-coord-utils.hh"cxx . . $ `<file>/coot-utils/coot-coord-utils.hh`/
25 #include "ideal-rna.hh"cxx . . $ `<file>/ligand/ideal-rna.hh`/
26
27 // The sequence passed must be in lower case.
28 //
29 cootcxx . . $ coot/::ideal_rnacxx . . $ coot/ideal_rna#::ideal_rnacxx . . $ coot/ideal_rna#ideal_rna(bf1016e7c214d94b).(const std::stringcxx . . $ std/string# &RNA_or_DNA, const std::stringcxx . . $ std/string# &form,
30 short int single_stranged_flag_in,
31 const std::stringcxx . . $ std/string# &sequence, mmdbcxx . . $ mmdb/::Managercxx . . $ mmdb/Manager# *standard_residues_in) {
32
33 RNA_or_DNA_cxx . . $ coot/ideal_rna#RNA_or_DNA_. =cxx . . $ std/__cxx11/basic_string#`operator=`(c0b47be1fddc0e75). RNA_or_DNA;
34 form_cxx . . $ coot/ideal_rna#form_. =cxx . . $ std/__cxx11/basic_string#`operator=`(c0b47be1fddc0e75). form;
35 seqcxx . . $ coot/ideal_rna#seq. =cxx . . $ std/__cxx11/basic_string#`operator=`(c0b47be1fddc0e75). sequence;
36 standard_residuescxx . . $ coot/ideal_rna#standard_residues. = standard_residues_in;
37 single_stranged_flagcxx . . $ coot/ideal_rna#single_stranged_flag. = single_stranged_flag_in;
38 use_standard_refmac_namescxx . . $ coot/ideal_rna#use_standard_refmac_names. = 1; // Ad, Gr etc
39
40 }
41
42 // return a null pointer on something bad happened.
43 mmdbcxx . . $ mmdb/::Managercxx . . $ mmdb/Manager# *
44 cootcxx . . $ coot/::ideal_rnacxx . . $ coot/ideal_rna#::make_moleculecxx . . $ coot/ideal_rna#make_molecule(3c4f8f620966b631).() {
45
46 mmdbcxx . . $ mmdb/::Managercxx . . $ mmdb/Manager# *mol = 0;
47 mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *ur;
48 bool is_dna_flag;
49 cootcxx . . $ coot/::ideal_rnacxx . . $ coot/ideal_rna#::form_tcxx . . $ coot/ideal_rna#form_t# form_flag = A_FORMcxx . . $ coot/ideal_rna#A_FORM.;
50
51 if (seqcxx . . $ coot/ideal_rna#seq..lengthcxx . . $ std/__cxx11/basic_string#length(7e80fff40d76986b).() == 0)
52 return mol; // NULL
53
54 if (RNA_or_DNA_cxx . . $ coot/ideal_rna#RNA_or_DNA_. ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). "RNA") {
55 // in a special place
56 is_dna_flag = 0;
57 } else {
58 is_dna_flag = 1;
59 }
60
61 if (form_cxx . . $ coot/ideal_rna#form_. ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). "B") {
62 ur = get_standard_residue_instancecxx . . $ coot/ideal_rna#get_standard_residue_instance(9ef240f1e73983d2).("DG"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., standard_residuescxx . . $ coot/ideal_rna#standard_residues.);
63
64
65 if (! is_dna_flag) {
66 // Add a O2' to RNA
67 //
68 std::stringcxx . . $ std/string# new_atom_name = " O2'"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).;
69 std::vectorcxx . . $ std/vector#<std::stringcxx . . $ std/string#> atcxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; // reference atom names
70 add_o2_primecxx . . $ coot/ideal_rna#add_o2_prime(c08ad52b78e0cfb3).(ur);
71 }
72 form_flag = B_FORMcxx . . $ coot/ideal_rna#B_FORM.;
73 } else {
74 form_flag = A_FORMcxx . . $ coot/ideal_rna#A_FORM.;
75 ur = get_standard_residue_instancecxx . . $ coot/ideal_rna#get_standard_residue_instance(9ef240f1e73983d2).("G"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., standard_residuescxx . . $ coot/ideal_rna#standard_residues.);
76 if (is_dna_flag) {
77 delete_o2_primecxx . . $ coot/ideal_rna#delete_o2_prime(c08ad52b78e0cfb3).(ur);
78 }
79 }
80
81 if (ur) {
82
83 mol = new mmdbcxx . . $ mmdb/::Managercxx . . $ mmdb/Manager#;
84 mmdbcxx . . $ mmdb/::Modelcxx . . $ mmdb/Model# *model_p = new mmdbcxx . . $ mmdb/::Modelcxx . . $ mmdb/Model#;
85 mmdbcxx . . $ mmdb/::Chaincxx . . $ mmdb/Chain# *sense_chain_p = new mmdbcxx . . $ mmdb/::Chaincxx . . $ mmdb/Chain#;
86 sense_chain_p->SetChainIDcxx . . $ mmdb/Chain#SetChainID(85c52e162fed56f9).("A");
87 model_p->AddChaincxx . . $ mmdb/Model#AddChain(3cc591ef6d77339b).(sense_chain_p);
88
89 clippercxx . . $ clipper/::Mat33cxx . . $ clipper/Mat33#<double> antisense_base_matcxx . . $ clipper/Mat33#Mat33(ca294aebd03ed32e).(1, 0, 0, 0, -1, 0, 0, 0, -1);
90 clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth# antisense_base_rtopcxx . . $ clipper/RTop_orth#RTop_orth(cd0dec0763f9cd6f).(antisense_base_mat, clippercxx . . $ clipper/Coord_orth#Coord_orth(3374d1a184fcc02e).::Coord_orthcxx . . $ clipper/Coord_orth#(0,0,0));
91 mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *antisense_ref = cootcxx . . $ coot/::utilcxx . . $ coot/util/::deep_copy_this_residuecxx . . $ coot/util/deep_copy_this_residue(ac10a5cf8fc97ff6).(ur);
92 // now transform antisense base to the right place:
93 cootcxx . . $ coot/::utilcxx . . $ coot/util/::transform_atomscxx . . $ coot/util/transform_atoms(a9b25d0ab3d02a33).(antisense_ref, antisense_base_rtop);
94 for(unsigned int iseq=0; iseq<seqcxx . . $ coot/ideal_rna#seq..lengthcxx . . $ std/__cxx11/basic_string#length(7e80fff40d76986b).(); iseq++) {
95 if (is_valid_basecxx . . $ coot/ideal_rna#is_valid_base(aec1b1cad4a17585).(seqcxx . . $ coot/ideal_rna#seq.[cxx . . $ std/__cxx11/basic_string#`operator[]`(69897ebe6c310f7e).iseq])) {
96 // sense residue
97 mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *res = cootcxx . . $ coot/::utilcxx . . $ coot/util/::deep_copy_this_residuecxx . . $ coot/util/deep_copy_this_residue(ac10a5cf8fc97ff6).(ur);
98 res->seqNumcxx . . $ mmdb/Residue#seqNum. = 1 + iseq ;
99 clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth# o = n_turnscxx . . $ coot/ideal_rna#n_turns(7250e8064767ccc4).(iseq, seqcxx . . $ coot/ideal_rna#seq..lengthcxx . . $ std/__cxx11/basic_string#length(7e80fff40d76986b).(), form_flag);
100 cootcxx . . $ coot/::utilcxx . . $ coot/util/::transform_atomscxx . . $ coot/util/transform_atoms(a9b25d0ab3d02a33).(res, o);
101 int success = mutate_rescxx . . $ coot/ideal_rna#mutate_res(820d3bbc18d46352).(res, seqcxx . . $ coot/ideal_rna#seq.[cxx . . $ std/__cxx11/basic_string#`operator[]`(69897ebe6c310f7e).iseq], is_dna_flag);
102 if (success) {
103 sense_chain_p->AddResiduecxx . . $ mmdb/Chain#AddResidue(e8508a3d85ca45d2).(res);
104 if (! use_standard_refmac_namescxx . . $ coot/ideal_rna#use_standard_refmac_names.) { // "standard" means v2
105 fix_up_residue_and_atom_namescxx . . $ coot/ideal_rna#fix_up_residue_and_atom_names(1630ce558d3a8b7d).(res, is_dna_flag);
106 }
107 }
108 } else {
109 std::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "ERROR:: oops not a valid base sequence-position: " <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). iseq
110 <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " type: " <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). seqcxx . . $ coot/ideal_rna#seq.[cxx . . $ std/__cxx11/basic_string#`operator[]`(69897ebe6c310f7e).iseq] <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). std::endlcxx . . $ std/endl(345bf97a19cc83a9).;
111 }
112 }
113
114 if (! single_stranged_flagcxx . . $ coot/ideal_rna#single_stranged_flag.) {
115 mmdbcxx . . $ mmdb/::Chaincxx . . $ mmdb/Chain# *antisense_chain_p = new mmdbcxx . . $ mmdb/::Chaincxx . . $ mmdb/Chain#;
116 // People complain that the resdiues of the antisense chain
117 // appear in the pdb file in the wrong order (high residue
118 // numbers first). So lets just make a vector of them, push
119 // them back and add them backwards at the end.
120 //
121 std::vectorcxx . . $ std/vector#<mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *> residues_vcxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
122 antisense_chain_p->SetChainIDcxx . . $ mmdb/Chain#SetChainID(85c52e162fed56f9).("B");
123
124 model_p->AddChaincxx . . $ mmdb/Model#AddChain(3cc591ef6d77339b).(antisense_chain_p);
125 for(unsigned int iseq=0; iseq<seqcxx . . $ coot/ideal_rna#seq..lengthcxx . . $ std/__cxx11/basic_string#length(7e80fff40d76986b).(); iseq++) {
126 if (is_valid_basecxx . . $ coot/ideal_rna#is_valid_base(aec1b1cad4a17585).(seqcxx . . $ coot/ideal_rna#seq.[cxx . . $ std/__cxx11/basic_string#`operator[]`(69897ebe6c310f7e).iseq])) {
127
128 // antisense residue
129 mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *res = cootcxx . . $ coot/::utilcxx . . $ coot/util/::deep_copy_this_residuecxx . . $ coot/util/deep_copy_this_residue(ac10a5cf8fc97ff6).(antisense_ref);
130 res->seqNumcxx . . $ mmdb/Residue#seqNum. = seqcxx . . $ coot/ideal_rna#seq..lengthcxx . . $ std/__cxx11/basic_string#length(7e80fff40d76986b).() - iseq;
131 // antisense_chain_p->AddResidue(res); "backwards in pdb"
132 clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth# o = n_turnscxx . . $ coot/ideal_rna#n_turns(7250e8064767ccc4).(iseq, seqcxx . . $ coot/ideal_rna#seq..lengthcxx . . $ std/__cxx11/basic_string#length(7e80fff40d76986b).(), form_flag);
133 cootcxx . . $ coot/::utilcxx . . $ coot/util/::transform_atomscxx . . $ coot/util/transform_atoms(a9b25d0ab3d02a33).(res, o);
134 char complimentary_base = antisense_basecxx . . $ coot/ideal_rna#antisense_base(5e5e94f291c2025e).(seqcxx . . $ coot/ideal_rna#seq.[cxx . . $ std/__cxx11/basic_string#`operator[]`(69897ebe6c310f7e).iseq], is_dna_flag);
135 if (complimentary_base) {
136 int success = mutate_rescxx . . $ coot/ideal_rna#mutate_res(820d3bbc18d46352).(res, complimentary_base, is_dna_flag);
137 if (success) {
138 residues_v.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(res); // modern
139 }
140 }
141 }
142 }
143 if (residues_v.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).() > 0) {
144 // test must fail, unsigned is bad then
145 for (int i=int(residues_v.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).()-1); i>=0; i--) {
146 antisense_chain_p->AddResiduecxx . . $ mmdb/Chain#AddResidue(e8508a3d85ca45d2).(residues_v[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i]);
147 if (! use_standard_refmac_namescxx . . $ coot/ideal_rna#use_standard_refmac_names.) {
148 fix_up_residue_and_atom_namescxx . . $ coot/ideal_rna#fix_up_residue_and_atom_names(1630ce558d3a8b7d).(residues_v[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i], is_dna_flag);
149 }
150 }
151 } else {
152 std::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "WARNING:: OOpps no backwards residues " <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). std::endlcxx . . $ std/endl(345bf97a19cc83a9).;
153 }
154 }
155 mol->AddModelcxx . . $ mmdb/CoorManager#AddModel(12b9c1a11a7b4bdb).(model_p);
156 mol->FinishStructEditcxx . . $ mmdb/Root#FinishStructEdit(b126dc7c1de90089).();
157 mol->PDBCleanupcxx . . $ mmdb/Root#PDBCleanup(2141b656ce2cc063).(mmdbcxx . . $ mmdb/::PDBCLEAN_SERIALcxx . . $ mmdb/PDBCLEAN_SERIAL.|mmdbcxx . . $ mmdb/::PDBCLEAN_INDEXcxx . . $ mmdb/PDBCLEAN_INDEX.);
158
159 } else {
160 std::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "WARNING:: Bad standard residue Ur/Td" <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). std::endlcxx . . $ std/endl(345bf97a19cc83a9).;
161 }
162
163 return mol;
164 }
165
166 // Fix up to v3 names, that is.
167 void
168 cootcxx . . $ coot/::ideal_rnacxx . . $ coot/ideal_rna#::fix_up_residue_and_atom_namescxx . . $ coot/ideal_rna#fix_up_residue_and_atom_names(1630ce558d3a8b7d).(mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *residue_p, bool is_dna_flag) {
169
170 std::stringcxx . . $ std/string# res_name = residue_pcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).->GetResNamecxx . . $ mmdb/Residue#GetResName(41208ce6ca65dd58).();
171 std::stringcxx . . $ std/string# new_name = res_namecxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5).; // residue_name_old_to_new(res_name, is_dna_flag); no longer needed
172
173 residue_p->SetResNamecxx . . $ mmdb/Residue#SetResName(85c52e162fed56f9).(new_name.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).());
174
175 mmdbcxx . . $ mmdb/::PPAtomcxx . . $ mmdb/PPAtom# residue_atoms = 0;
176 int n_residue_atoms;
177 residue_p->GetAtomTablecxx . . $ mmdb/Residue#GetAtomTable(9d9941bd98e0b231).(residue_atoms, n_residue_atoms);
178 for (int iat=0; iat<n_residue_atoms; iat++) {
179 mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *at = residue_atoms[iat];
180 std::stringcxx . . $ std/string# atom_name = atcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).->namecxx . . $ mmdb/Atom#name.;
181 if (atom_name.lengthcxx . . $ std/__cxx11/basic_string#length(7e80fff40d76986b).() > 3) {
182 if (atom_name[cxx . . $ std/__cxx11/basic_string#`operator[]`(69897ebe6c310f7e).3] == '*') {
183 atom_name[cxx . . $ std/__cxx11/basic_string#`operator[]`(69897ebe6c310f7e).3] = '\'';
184 at->SetAtomNamecxx . . $ mmdb/Atom#SetAtomName(85c52e162fed56f9).(atom_name.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).());
185 }
186
187 if (atom_name ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). " O1P") at->SetAtomNamecxx . . $ mmdb/Atom#SetAtomName(85c52e162fed56f9).(" OP1");
188 if (atom_name ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). " O2P") at->SetAtomNamecxx . . $ mmdb/Atom#SetAtomName(85c52e162fed56f9).(" OP2");
189 }
190 }
191
192 // fix the atom name C5M->C7 on a T in DNA [Grr, !@#$!@#$% PDB...]
193 if (new_name ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). "DT") {
194 for (int iat=0; iat<n_residue_atoms; iat++) {
195 mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *at = residue_atoms[iat];
196 std::stringcxx . . $ std/string# atom_name = atcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).->namecxx . . $ mmdb/Atom#name.;
197 if (atom_name ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). " C5M") {
198 at->SetAtomNamecxx . . $ mmdb/Atom#SetAtomName(85c52e162fed56f9).(" C7 ");
199 }
200 }
201 }
202
203 }
204
205
206
207 clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth#
208 cootcxx . . $ coot/::ideal_rnacxx . . $ coot/ideal_rna#::n_turnscxx . . $ coot/ideal_rna#n_turns(7250e8064767ccc4).(int nbase, int n_in_chain, cootcxx . . $ coot/::ideal_rnacxx . . $ coot/ideal_rna#::form_tcxx . . $ coot/ideal_rna#form_t# form_flag) const {
209
210 clippercxx . . $ clipper/::Mat33cxx . . $ clipper/Mat33#<double> m_identitycxx . . $ clipper/Mat33#Mat33(ca294aebd03ed32e).(1, 0, 0, 0, 1, 0, 0, 0, 1);
211 clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# t_identitycxx . . $ clipper/Coord_orth#Coord_orth(3374d1a184fcc02e).(0, 0, 0);
212 clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth# ocxx . . $ clipper/RTop_orth#RTop_orth(cd0dec0763f9cd6f).(m_identity, t_identity);
213
214 // A form
215 clippercxx . . $ clipper/::Mat33cxx . . $ clipper/Mat33#<double> base_matcxx . . $ clipper/Mat33#Mat33(ca294aebd03ed32e).(0.8415, -0.5402, 0,
216 0.5402, 0.8415, 0,
217 0, 0, 1);
218 clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# base_transcxx . . $ clipper/Coord_orth#Coord_orth(3374d1a184fcc02e).(0, 0, 2.81);
219 clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth# one_basecxx . . $ clipper/RTop_orth#RTop_orth(cd0dec0763f9cd6f).(base_mat, base_trans);
220
221 if (form_flag == cootcxx . . $ coot/::ideal_rnacxx . . $ coot/ideal_rna#::B_FORMcxx . . $ coot/ideal_rna#B_FORM.) {
222 // change one_base
223 clippercxx . . $ clipper/::Mat33cxx . . $ clipper/Mat33#<double> b_base_matcxx . . $ clipper/Mat33#Mat33(ca294aebd03ed32e).(0.809, -0.5878, 0,
224 0.5878, 0.809, 0,
225 0, 0, 1);
226 clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# b_base_transcxx . . $ clipper/Coord_orth#Coord_orth(3374d1a184fcc02e).(0, 0, 3.38);
227 one_base =cxx . . $ clipper/RTop_orth#`operator=`(a645a65ab075cbc5). clippercxx . . $ clipper/RTop_orth#RTop_orth(cd0dec0763f9cd6f).::RTop_orthcxx . . $ clipper/RTop_orth#(b_base_mat, b_base_trans);
228 }
229
230 for(int ibase=0; ibase<nbase; ibase++) {
231 clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth# o1cxx . . $ clipper/RTop_orth#RTop_orth(a99d62d6ddf8f0a5).(one_base *cxx . . $ clipper/`operator*`(8362d4076c27ca0e). o);
232 o =cxx . . $ clipper/RTop_orth#`operator=`(48c648009b6314b). o1;
233 }
234
235 return o;
236
237 }
238
239 bool
240 cootcxx . . $ coot/::ideal_rnacxx . . $ coot/ideal_rna#::is_valid_basecxx . . $ coot/ideal_rna#is_valid_base(aec1b1cad4a17585).(char base) const {
241
242 if (base == 'g') {
243 return 1;
244 } else {
245 if (base == 'c') {
246 return 1;
247 } else {
248 if (base == 'a') {
249 return 1;
250 } else {
251 if (base == 't') {
252 return 1;
253 } else {
254 if (base == 'u') {
255 return 1;
256 }
257 }
258 }
259 }
260 }
261 return 0;
262 }
263
264 char
265 cootcxx . . $ coot/::ideal_rnacxx . . $ coot/ideal_rna#::antisense_basecxx . . $ coot/ideal_rna#antisense_base(5e5e94f291c2025e).(char base, bool is_dna_flag) const {
266
267 if (base == 'g') {
268 return 'c';
269 } else {
270 if (base == 'c') {
271 return 'g';
272 } else {
273 if (base == 'a') {
274 if (is_dna_flag)
275 return 't';
276 else
277 return 'u';
278 } else {
279 if (base == 't') {
280 return 'a';
281 } else {
282 if (base == 'u') {
283 return 'a';
284 }
285 }
286 }
287 }
288 }
289 return 0;
290 }
291
292
293 //
294 // Get a deep copy:
295 // return NULL on failure
296 //
297 mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *
298 cootcxx . . $ coot/::ideal_rnacxx . . $ coot/ideal_rna#::get_standard_residue_instancecxx . . $ coot/ideal_rna#get_standard_residue_instance(9ef240f1e73983d2).(const std::stringcxx . . $ std/string# &residue_type_in,
299 mmdbcxx . . $ mmdb/::Managercxx . . $ mmdb/Manager# *standard_residues) const {
300
301 // convert new names: "A", "DA" to old ones (the ones in the
302 // standard residues file), "Ar", "Ad"
303 //
304 std::stringcxx . . $ std/string# residue_name = residue_name_from_typecxx . . $ coot/ideal_rna#residue_name_from_type(ed3976f106e8bf8e).(residue_type_in);
305 std::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "get_standard_residue_instance(): in :" <<cxx . . $ std/`operator<<`(88df5bef833f7f83). residue_type_in <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). ": out :" <<cxx . . $ std/`operator<<`(88df5bef833f7f83). residue_name <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). ":" <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). std::endlcxx . . $ std/endl(345bf97a19cc83a9).;
306
307 mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *std_residue = 0;
308 int selHnd = standard_residues->NewSelectioncxx . . $ mmdb/SelManager#NewSelection(b126dc7c1de90089).();
309 standard_residues->Selectcxx . . $ mmdb/SelManager#Select(807137904f387a6d). (selHnd, mmdbcxx . . $ mmdb/::STYPE_RESIDUEcxx . . $ mmdb/STYPE_RESIDUE., 1, // .. TYPE, iModel
310 "*",
311 mmdbcxx . . $ mmdb/::ANY_REScxx . . $ mmdb/ANY_RES., "*", // starting res
312 mmdbcxx . . $ mmdb/::ANY_REScxx . . $ mmdb/ANY_RES., "*", // ending res
313 residue_name.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(), // residue name
314 "*", // Residue must contain this atom name?
315 "*", // Residue must contain this Element?
316 "*", // altLocs
317 mmdbcxx . . $ mmdb/::SKEY_NEWcxx . . $ mmdb/SKEY_NEW. // selection key
318 );
319 mmdbcxx . . $ mmdb/::PPResiduecxx . . $ mmdb/PPResidue# SelResidue;
320 int nSelResidues;
321 standard_residues->GetSelIndexcxx . . $ mmdb/SelManager#GetSelIndex(d5950ce9c9f54468).(selHnd, SelResidue, nSelResidues);
322
323 if (nSelResidues != 1) {
324 std::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "This should never happen - ";
325 std::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "badness in ideal_rna::get_standard_residue_instance(), we selected "
326 <<cxx . . $ std/basic_ostream#`operator<<`(23b6575433a77e57). nSelResidues <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " residues looking for residues of type :"
327 <<cxx . . $ std/`operator<<`(88df5bef833f7f83). residue_name <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). ": from :" <<cxx . . $ std/`operator<<`(88df5bef833f7f83). residue_type_in <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). ":\n";
328 } else {
329 std_residue = cootcxx . . $ coot/::utilcxx . . $ coot/util/::deep_copy_this_residuecxx . . $ coot/util/deep_copy_this_residue(ac10a5cf8fc97ff6).(SelResidue[0]);
330 }
331 standard_residues->DeleteSelectioncxx . . $ mmdb/SelManager#DeleteSelection(d4f767463ce0a6b3).(selHnd);
332 return std_residue;
333 }
334
335 // convert new names: "A", "DA" to old ones (the ones in the
336 // standard residues file), "Ar", "Ad"
337 //
338 std::stringcxx . . $ std/string#
339 cootcxx . . $ coot/::ideal_rnacxx . . $ coot/ideal_rna#::residue_name_from_typecxx . . $ coot/ideal_rna#residue_name_from_type(ed3976f106e8bf8e).(const std::stringcxx . . $ std/string# &residue_type_in) const {
340
341 // 20240420-PE this need a rethink.
342
343 std::stringcxx . . $ std/string# r = "A"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).;
344
345 if (use_standard_refmac_namescxx . . $ coot/ideal_rna#use_standard_refmac_names.) {
346 return residue_type_incxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5).;
347 } else {
348 if (residue_type_in.lengthcxx . . $ std/__cxx11/basic_string#length(7e80fff40d76986b).() == 2)
349 if (residue_type_in[cxx . . $ std/__cxx11/basic_string#`operator[]`(7daf10330c1c7fee).1] == 'r'|| residue_type_in[cxx . . $ std/__cxx11/basic_string#`operator[]`(7daf10330c1c7fee).1] == 'd')
350 return residue_type_incxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5).;
351 if (residue_type_in ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). "A")
352 return "A"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).;
353 if (residue_type_in ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). "G")
354 return "G"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).;
355 if (residue_type_in ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). "C")
356 return "C"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).;
357 if (residue_type_in ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). "U")
358 return "U"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).;
359 if (residue_type_in ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). "DA")
360 return "DA"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).;
361 if (residue_type_in ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). "DG")
362 return "DG"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).;
363 if (residue_type_in ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). "DC")
364 return "DC"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).;
365 if (residue_type_in ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). "DT")
366 return "DT"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).;
367 }
368 return rcxx . . $ std/__cxx11/basic_string#basic_string(8f3aaafa33d05d0b).;
369 }
370
371 std::stringcxx . . $ std/string#
372 cootcxx . . $ coot/::ideal_rnacxx . . $ coot/ideal_rna#::residue_name_old_to_newcxx . . $ coot/ideal_rna#residue_name_old_to_new(f746d7e0655d843).(const std::stringcxx . . $ std/string# &residue_type_in, bool is_dna_flag) const {
373
374 std::stringcxx . . $ std/string# r = ""cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).;
375 if (is_dna_flag) {
376 if (residue_type_in ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). "Ad")
377 return "DA"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).;
378 if (residue_type_in ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). "Gd")
379 return "DG"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).;
380 if (residue_type_in ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). "Cd")
381 return "DC"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).;
382 if (residue_type_in ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). "Td")
383 return "DT"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).;
384 if (residue_type_in ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). "Ud")
385 return "DU"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).;
386 } else {
387 if (residue_type_in ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). "Ar")
388 return "A"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).;
389 if (residue_type_in ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). "Gr")
390 return "G"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).;
391 if (residue_type_in ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). "Cr")
392 return "C"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).;
393 if (residue_type_in ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). "Tr")
394 return "T"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).;
395 if (residue_type_in ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). "Ur")
396 return "U"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).;
397 }
398 return rcxx . . $ std/__cxx11/basic_string#basic_string(8f3aaafa33d05d0b).; // fail
399 }
400
401
402 // return a status: 0 for bad, 1 for good.
403 int
404 cootcxx . . $ coot/::ideal_rnacxx . . $ coot/ideal_rna#::mutate_rescxx . . $ coot/ideal_rna#mutate_res(820d3bbc18d46352).(mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *res, char base, bool is_dna_flag) const {
405
406 // we need to get instances of bases from the standard residues
407 int status = 0;
408
409 std::stringcxx . . $ std/string# residue_type = "None"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).;
410
411 if (is_dna_flag) {
412 if (base == 'a')
413 residue_type =cxx . . $ std/__cxx11/basic_string#`operator=`(978ca1133b5f6e74). "DA";
414 if (base == 'g')
415 residue_type =cxx . . $ std/__cxx11/basic_string#`operator=`(978ca1133b5f6e74). "DG";
416 if (base == 't')
417 residue_type =cxx . . $ std/__cxx11/basic_string#`operator=`(978ca1133b5f6e74). "DT";
418 if (base == 'c')
419 residue_type =cxx . . $ std/__cxx11/basic_string#`operator=`(978ca1133b5f6e74). "DC";
420 } else {
421 if (base == 'a')
422 residue_type =cxx . . $ std/__cxx11/basic_string#`operator=`(978ca1133b5f6e74). "A";
423 if (base == 'g')
424 residue_type =cxx . . $ std/__cxx11/basic_string#`operator=`(978ca1133b5f6e74). "G";
425 if (base == 'u')
426 residue_type =cxx . . $ std/__cxx11/basic_string#`operator=`(978ca1133b5f6e74). "U";
427 if (base == 'c')
428 residue_type =cxx . . $ std/__cxx11/basic_string#`operator=`(978ca1133b5f6e74). "C";
429 }
430
431 if (residue_type != "None") {
432 mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *std_res = get_standard_residue_instancecxx . . $ coot/ideal_rna#get_standard_residue_instance(9ef240f1e73983d2).(residue_type, standard_residuescxx . . $ coot/ideal_rna#standard_residues.);
433 if (std_res) {
434 cootcxx . . $ coot/::utilcxx . . $ coot/util/::mutate_basecxx . . $ coot/util/mutate_base(241c88a8d9d7818f).(res, std_res, 1);
435 status = 1;
436 }
437 }
438 return status;
439 }
440
441 void
442 cootcxx . . $ coot/::ideal_rnacxx . . $ coot/ideal_rna#::delete_o2_primecxx . . $ coot/ideal_rna#delete_o2_prime(c08ad52b78e0cfb3).(mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *res) const {
443
444 int natoms;
445 mmdbcxx . . $ mmdb/::PPAtomcxx . . $ mmdb/PPAtom# residue_atoms;
446 short int deleted = 0;
447
448 if (res) {
449 res->GetAtomTablecxx . . $ mmdb/Residue#GetAtomTable(9d9941bd98e0b231).(residue_atoms, natoms);
450 for (int i=0; i<natoms; i++) {
451 std::stringcxx . . $ std/string# atnamecxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).(residue_atoms[i]->namecxx . . $ mmdb/Atom#name.);
452 if (atname ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). " O2*") {
453 res->DeleteAtomcxx . . $ mmdb/Residue#DeleteAtom(7864480464b09eea).(i);
454 deleted=1;
455 }
456 if (atname ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). " O2'") {
457 res->DeleteAtomcxx . . $ mmdb/Residue#DeleteAtom(7864480464b09eea).(i);
458 deleted=1;
459 }
460 }
461 if (deleted)
462 res->TrimAtomTablecxx . . $ mmdb/Residue#TrimAtomTable(49f6e7a06ebc5aa8).();
463 }
464 }
465
466 // Tinker with res
467 void
468 cootcxx . . $ coot/::ideal_rnacxx . . $ coot/ideal_rna#::add_o2_primecxx . . $ coot/ideal_rna#add_o2_prime(c08ad52b78e0cfb3).(mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *res) const {
469
470 if (res) {
471 std::vectorcxx . . $ std/vector#<clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth#> mov_ptscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; // in order
472
473 mov_pts.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(clippercxx . . $ clipper/Coord_orth#Coord_orth(3374d1a184fcc02e).::Coord_orthcxx . . $ clipper/Coord_orth#(6.853, -5.219, 1.725)); // C1'
474 mov_pts.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(clippercxx . . $ clipper/Coord_orth#Coord_orth(3374d1a184fcc02e).::Coord_orthcxx . . $ clipper/Coord_orth#(7.473, -4.888, 3.087)); // C2'
475 mov_pts.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(clippercxx . . $ clipper/Coord_orth#Coord_orth(3374d1a184fcc02e).::Coord_orthcxx . . $ clipper/Coord_orth#(6.678, -5.807, 4.033)); // C3'
476
477 // The coordinate that gets moved by the rtop returned from LSQing.
478 // Later, it gets turned into an atom and added to res
479 //
480 clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# o2pcxx . . $ clipper/Coord_orth#Coord_orth(3374d1a184fcc02e).(8.870, -5.158, 3.018);
481
482 int natoms;
483 mmdbcxx . . $ mmdb/::PPAtomcxx . . $ mmdb/PPAtom# residue_atoms;
484 mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *c1p = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
485 mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *c2p = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
486 mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *c3p = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
487 res->GetAtomTablecxx . . $ mmdb/Residue#GetAtomTable(9d9941bd98e0b231).(residue_atoms, natoms);
488 for (int i=0; i<natoms; i++) {
489 std::stringcxx . . $ std/string# atnamecxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).(residue_atoms[i]->namecxx . . $ mmdb/Atom#name.);
490 if (atname ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). " C1'" || atname ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). " C1*")
491 c1p = residue_atoms[i];
492 if (atname ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). " C2'" || atname ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). " C2*")
493 c2p = residue_atoms[i];
494 if (atname ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). " C3'" || atname ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). " C3*")
495 c3p = residue_atoms[i];
496 }
497
498 if (c1p && c2p && c3p) { // add o
499 std::vectorcxx . . $ std/vector#<clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth#> ref_ptscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
500 ref_pts.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(clippercxx . . $ clipper/Coord_orth#Coord_orth(3374d1a184fcc02e).::Coord_orthcxx . . $ clipper/Coord_orth#(c1p->xcxx . . $ mmdb/Atom#x., c1p->ycxx . . $ mmdb/Atom#y., c1p->zcxx . . $ mmdb/Atom#z.));
501 ref_pts.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(clippercxx . . $ clipper/Coord_orth#Coord_orth(3374d1a184fcc02e).::Coord_orthcxx . . $ clipper/Coord_orth#(c2p->xcxx . . $ mmdb/Atom#x., c2p->ycxx . . $ mmdb/Atom#y., c2p->zcxx . . $ mmdb/Atom#z.));
502 ref_pts.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(clippercxx . . $ clipper/Coord_orth#Coord_orth(3374d1a184fcc02e).::Coord_orthcxx . . $ clipper/Coord_orth#(c3p->xcxx . . $ mmdb/Atom#x., c3p->ycxx . . $ mmdb/Atom#y., c3p->zcxx . . $ mmdb/Atom#z.));
503
504 clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth# rtopcxx . . $ clipper/RTop_orth#RTop_orth(2316f45164e461d4).(mov_pts, ref_pts);
505 clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# pos = o2p.transformcxx . . $ clipper/Coord_orth#transform(82925a12407e9823).(rtop);
506
507 float new_atom_occ = 1.0;
508 float new_atom_b_factor = 30.0;
509 std::stringcxx . . $ std/string# new_atom_name = " O2*"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).;
510 std::stringcxx . . $ std/string# new_atom_ele = " O"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).;
511
512 mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom# *new_at = new mmdbcxx . . $ mmdb/::Atomcxx . . $ mmdb/Atom#;
513 new_at->SetCoordinatescxx . . $ mmdb/Atom#SetCoordinates(a8d73491ea06a585).(pos.xcxx . . $ clipper/Coord_orth#x(cb83ef2068996cec).(), pos.ycxx . . $ clipper/Coord_orth#y(cb83ef2068996cec).(), pos.zcxx . . $ clipper/Coord_orth#z(cb83ef2068996cec).(), new_atom_occ, new_atom_b_factor);
514 new_at->SetAtomNamecxx . . $ mmdb/Atom#SetAtomName(85c52e162fed56f9).(new_atom_name.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).());
515 new_at->SetElementNamecxx . . $ mmdb/Atom#SetElementName(85c52e162fed56f9).(new_atom_ele.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).());
516 res->AddAtomcxx . . $ mmdb/Residue#AddAtom(74a928defe1fb19f).(new_at);
517 }
518 }
519 }