Debian Codegraph @

ligand/helix-placement.cc

raw symbols SCIP
1 /* ligand/helix-placement.cc
2 *
3 * Copyright 2005 The University of York
4 * Author: Paul Emsley, Kevin Cowtan
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * 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 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21 // Portability gubbins
22 #ifndef _MSC_VER
23 #include <unistd.h> // for getopt(3)
24 #else
25 #define stat _stat
26 #endif
27 #ifndef _GNU_SOURCEcxx . . $ `<built-in>:479:9`!
28 #define _GNU_SOURCE
29 #endif
30
31 #ifdef __GNU_LIBRARY__cxx . . $ `<external>/18206667465210621810/features.h:510:9`!
32 #include "compat/coot-getopt.h"cxx . . $ `<file>/compat/coot-getopt.h`/
33 #else
34 #define __GNU_LIBRARY__
35 #include "compat/coot-getopt.h"
36 #undef __GNU_LIBRARY__
37 #endif
38
39 #include <algorithm>
40
41 #include <clipper/clipper.h>
42 #include "clipper/ccp4/ccp4_map_io.h"
43 #include "residue_by_phi_psi.hh"cxx . . $ `<file>/ligand/residue_by_phi_psi.hh`/
44 #include "helix-placement.hh"cxx . . $ `<file>/ligand/helix-placement.hh`/
45 #include "utils/coot-utils.hh"cxx . . $ `<file>/utils/coot-utils.hh`/
46 #include "rigid-body.hh"cxx . . $ `<file>/ligand/rigid-body.hh`/
47 #include "mini-mol/mini-mol-utils.hh"cxx . . $ `<file>/mini-mol/mini-mol-utils.hh`/
48 #include "db-main/db-strands.hh"cxx . . $ `<file>/db-main/db-strands.hh`/
49
50 #include <sys/types.h> // for stating
51 #include <sys/stat.h>
52
53 cootcxx . . $ coot/::helix_placement_info_tcxx . . $ coot/helix_placement_info_t#
54 cootcxx . . $ coot/::helix_placementcxx . . $ coot/helix_placement#::place_alpha_helix_nearcxx . . $ coot/helix_placement#place_alpha_helix_near(71d970a9573fc0a).(const clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# &pt,
55 int n_residues,
56 float density_level_for_trim,
57 float b_factor,
58 float map_rmsd) const {
59
60 clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# ptc = pt;
61 for (int i=0; i<10; i++) {
62 clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# new_pt = move_helix_centre_point_guesscxx . . $ coot/helix_placement#move_helix_centre_point_guess(14c1b8bf9c0dd15a).(ptc, density_level_for_trim);
63 // std::cout << "starting point: " << ptc.format() << std::endl;
64 // std::cout << " ending point: " << new_pt.format() << std::endl;
65 // double d = clipper::Coord_orth::length(ptc, new_pt);
66 // std::cout << "moved dist " << d << std::endl;
67 ptc =cxx . . $ clipper/Coord_orth#`operator=`(78e738cfe0eb964f). new_pt;
68 if ( (new_pt -cxx . . $ clipper/operator-(44ad1d8741e04b17). pt).lengthsqcxx . . $ clipper/Coord_orth#lengthsq(21b6c25e127938e2).() > 9.0) {
69 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "INFO:: helix placement centre point movement limit reached\n";
70 break;
71 }
72 }
73
74 // std::cout << "centred position " << ptc.format() << std::endl;
75
76 // So ptc is at the centre of the helix. What are the eigen
77 // vectors of the electron density about this point.
78
79 float acell[6];
80 acell[0] = xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).().descrcxx . . $ clipper/Cell#descr(60e29b0f4054320c).().acxx . . $ clipper/Cell_descr#a(cb83ef2068996cec).();
81 acell[1] = xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).().descrcxx . . $ clipper/Cell#descr(60e29b0f4054320c).().bcxx . . $ clipper/Cell_descr#b(cb83ef2068996cec).();
82 acell[2] = xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).().descrcxx . . $ clipper/Cell#descr(60e29b0f4054320c).().ccxx . . $ clipper/Cell_descr#c(cb83ef2068996cec).();
83 acell[3] = clippercxx . . $ clipper/::Utilcxx . . $ clipper/Util#::rad2dcxx . . $ clipper/Util#rad2d(569b37c916856981).(xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).().descrcxx . . $ clipper/Cell#descr(60e29b0f4054320c).().alphacxx . . $ clipper/Cell_descr#alpha(cb83ef2068996cec).());
84 acell[4] = clippercxx . . $ clipper/::Utilcxx . . $ clipper/Util#::rad2dcxx . . $ clipper/Util#rad2d(569b37c916856981).(xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).().descrcxx . . $ clipper/Cell#descr(60e29b0f4054320c).().betacxx . . $ clipper/Cell_descr#beta(cb83ef2068996cec).());
85 acell[5] = clippercxx . . $ clipper/::Utilcxx . . $ clipper/Util#::rad2dcxx . . $ clipper/Util#rad2d(569b37c916856981).(xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).().descrcxx . . $ clipper/Cell#descr(60e29b0f4054320c).().gammacxx . . $ clipper/Cell_descr#gamma(cb83ef2068996cec).());
86 // mmmol.set_cell(a);
87 stdcxx . . $ std/::stringcxx . . $ std/string# spacegroup_str_hm = xmapcxx . . $ std/__cxx11/basic_string#basic_string(8f3aaafa33d05d0b)..spacegroupcxx . . $ clipper/Xmap_base#spacegroup(f2c81a655761ef05).().symbol_hmcxx . . $ clipper/Spgr_descr#symbol_hm(9c83e4702554ac51).();
88
89 // a 20 residue helix is 27A long
90 float search_radius = float(n_residues)/2.0;
91 cootcxx . . $ coot/::eigen_info_tcxx . . $ coot/eigen_info_t# rtop_eigen_info = helix_eigen_systemcxx . . $ coot/helix_placement#helix_eigen_system(bf62a47acffef0f4).(ptc, search_radius);
92 clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth# rtop_eigen = rtop_eigen_info.rtopcxx . . $ coot/eigen_info_t#rtop.;
93 // int best_eigenvalue_index = rtop_eigen_info.best_eigen_value_index;
94 // std::cout << "DEBUG:: matrix\n" << rtop_eigen.format()
95 // << "\n has determinant "
96 // << rtop_eigen.rot().det() << std::endl;
97
98 cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::moleculecxx . . $ coot/minimol/molecule# mrcxx . . $ coot/minimol/molecule#molecule(49f6e7a06ebc5aa8).; // part of returned value
99 cootcxx . . $ coot/::helix_placement_info_tcxx . . $ coot/helix_placement_info_t# m = get_20_residue_helix_standard_orientationcxx . . $ coot/helix_placement#get_20_residue_helix_standard_orientation(6c960eda6f397b1).(n_residues,
100 b_factor);
101 short int success = m.successcxx . . $ coot/helix_placement_info_t#success.;
102 stdcxx . . $ std/::stringcxx . . $ std/string# failure_message = mcxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5)..failure_messagecxx . . $ coot/helix_placement_info_t#failure_message.;
103
104 if (m.molcxx . . $ coot/helix_placement_info_t#mol.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0].fragmentscxx . . $ coot/minimol/molecule#fragments..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).() > 0 ) {
105
106 // now apply rtop_eigen to m!
107 //
108 // we don't know which way round the helix is at this stage, of course.
109 // So we will loop over 2 reorienation matrixes:
110
111 stdcxx . . $ std/::vectorcxx . . $ std/vector#<clippercxx . . $ clipper/::Mat33cxx . . $ clipper/Mat33#<double> > flip_rotated_matricescxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
112 flip_rotated_matrices.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(clippercxx . . $ clipper/Mat33#Mat33(ca294aebd03ed32e).::Mat33cxx . . $ clipper/Mat33#<double>(1,0,0,0,1,0,0,0,1));
113 flip_rotated_matrices.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(clippercxx . . $ clipper/Mat33#Mat33(ca294aebd03ed32e).::Mat33cxx . . $ clipper/Mat33#<double>(-1, 0, 0, 0, 1, 0, 0, 0, -1));
114
115 clippercxx . . $ clipper/::Mat33cxx . . $ clipper/Mat33#<double> no_rotationcxx . . $ clipper/Mat33#Mat33(ca294aebd03ed32e). (1, 0, 0, 0, 1, 0, 0, 0, 1);
116 clippercxx . . $ clipper/::Mat33cxx . . $ clipper/Mat33#<double> y_axis_rotationcxx . . $ clipper/Mat33#Mat33(ca294aebd03ed32e).(0, 0, -1, 0, 1, 0, 1, 0, 0);
117 clippercxx . . $ clipper/::Mat33cxx . . $ clipper/Mat33#<double> x_axis_rotationcxx . . $ clipper/Mat33#Mat33(ca294aebd03ed32e).(1, 0, 0, 0, 0, -1, 0, 1, 0);
118 clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth# no_rotation_opcxx . . $ clipper/RTop_orth#RTop_orth(cd0dec0763f9cd6f).(no_rotation, clippercxx . . $ clipper/Coord_orth#Coord_orth(3374d1a184fcc02e).::Coord_orthcxx . . $ clipper/Coord_orth#(0,0,0));
119 clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth# y_axis_opcxx . . $ clipper/RTop_orth#RTop_orth(cd0dec0763f9cd6f).(y_axis_rotation, clippercxx . . $ clipper/Coord_orth#Coord_orth(3374d1a184fcc02e).::Coord_orthcxx . . $ clipper/Coord_orth#(0,0,0));
120 clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth# x_axis_opcxx . . $ clipper/RTop_orth#RTop_orth(cd0dec0763f9cd6f).(x_axis_rotation, clippercxx . . $ clipper/Coord_orth#Coord_orth(3374d1a184fcc02e).::Coord_orthcxx . . $ clipper/Coord_orth#(0,0,0));
121
122 stdcxx . . $ std/::vectorcxx . . $ std/vector#<clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth#> eigen_orientationscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
123 eigen_orientations.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(no_rotation_op);
124 eigen_orientations.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(y_axis_op);
125 eigen_orientations.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(x_axis_op);
126
127 float score;
128 stdcxx . . $ std/::vectorcxx . . $ std/vector#<cootcxx . . $ coot/::scored_helix_info_tcxx . . $ coot/scored_helix_info_t#> eigens_scored_helicescxx . . $ std/vector#vector(83fdeebbe0501a83).(3);
129 stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<float, float> > cb_density_info_for_scored_helicescxx . . $ std/vector#vector(83fdeebbe0501a83).(3);
130
131 for (int ieigen=0; ieigen<3; ieigen++) {
132 stdcxx . . $ std/::vectorcxx . . $ std/vector#<cootcxx . . $ coot/::scored_helix_info_tcxx . . $ coot/scored_helix_info_t#> this_eigen_scored_helicescxx . . $ std/vector#vector(83fdeebbe0501a83).(2);
133 for (unsigned int irm=0; irm<flip_rotated_matrices.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); irm++) {
134 cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::moleculecxx . . $ coot/minimol/molecule# rotated_helix = m.molcxx . . $ coot/helix_placement_info_t#mol.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0];
135 // apply flip (180 degrees (upsidedown)) matrices to rotated_helix then:
136 clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth# flip_rtopcxx . . $ clipper/RTop_orth#RTop_orth(cd0dec0763f9cd6f).(flip_rotated_matrices[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).irm],
137 clippercxx . . $ clipper/Coord_orth#Coord_orth(3374d1a184fcc02e).::Coord_orthcxx . . $ clipper/Coord_orth#(0,0,0));
138 for(unsigned int ifrag=0; ifrag<rotated_helix.fragmentscxx . . $ coot/minimol/molecule#fragments..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); ifrag++)
139 rotated_helix[cxx . . $ coot/minimol/molecule#`operator[]`(1062c7b8e0909df1).ifrag].transformcxx . . $ coot/minimol/fragment#transform(e19fd923a135bced).(flip_rtop);
140
141 // now search for best rotation round the helix axis:
142 //
143 for (float theta=0; theta<2*M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`!; theta += 0.2) {
144
145 cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::moleculecxx . . $ coot/minimol/molecule# theta_mol = rotated_helix;
146
147 double sin_t = sincxx . . $ sin(fbcf3211dfe1bfd1).(theta);
148 double cos_t = coscxx . . $ cos(fbcf3211dfe1bfd1).(theta);
149 clippercxx . . $ clipper/::Mat33cxx . . $ clipper/Mat33#<double> theta_matcxx . . $ clipper/Mat33#Mat33(ca294aebd03ed32e).(cos_t,-sin_t,0, sin_t,cos_t,0, 0,0,1);
150 clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth# theta_rtopcxx . . $ clipper/RTop_orth#RTop_orth(cd0dec0763f9cd6f).(theta_mat, clippercxx . . $ clipper/Coord_orth#Coord_orth(3374d1a184fcc02e).::Coord_orthcxx . . $ clipper/Coord_orth#(0,0,0));
151 for(unsigned int ifrag=0; ifrag<rotated_helix.fragmentscxx . . $ coot/minimol/molecule#fragments..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); ifrag++)
152 theta_mol[cxx . . $ coot/minimol/molecule#`operator[]`(1062c7b8e0909df1).ifrag].transformcxx . . $ coot/minimol/fragment#transform(e19fd923a135bced).(theta_rtop);
153
154 for(unsigned int ifrag=0; ifrag<theta_mol.fragmentscxx . . $ coot/minimol/molecule#fragments..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); ifrag++)
155 theta_mol[cxx . . $ coot/minimol/molecule#`operator[]`(1062c7b8e0909df1).ifrag].transformcxx . . $ coot/minimol/fragment#transform(e19fd923a135bced).(eigen_orientations[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).ieigen]);
156
157 // finally apply eigen to shift to position in map.
158 for(unsigned int ifrag=0; ifrag<theta_mol.fragmentscxx . . $ coot/minimol/molecule#fragments..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); ifrag++)
159 theta_mol[cxx . . $ coot/minimol/molecule#`operator[]`(1062c7b8e0909df1).ifrag].transformcxx . . $ coot/minimol/fragment#transform(e19fd923a135bced).(rtop_eigen);
160
161 // std::string fitted_name = "fitted-helix-";
162 // fitted_name += coot::util::int_to_string(irm);
163 // fitted_name += "-";
164 // fitted_name += coot::util::float_to_string(theta*180/M_PI);
165 // fitted_name += ".pdb";
166 // theta_mol.write_file(fitted_name);
167
168 score = score_helix_positioncxx . . $ coot/helix_placement#score_helix_position(a0b84a170f8981cf).(theta_mol);
169 if (score > this_eigen_scored_helices[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).irm].scorecxx . . $ coot/scored_helix_info_t#score.) {
170 this_eigen_scored_helices[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).irm] =cxx . . $ coot/scored_helix_info_t#`operator=`(4bbf5a4a0028e2e9). cootcxx . . $ coot/scored_helix_info_t#scored_helix_info_t(5ef2f84fc85ee5de).::scored_helix_info_tcxx . . $ coot/scored_helix_info_t#(theta_mol, score);
171 }
172 // std::cout << "score " << irm << " " << theta*180/M_PI << " " << score
173 // << std::endl;
174 }
175 }
176
177 // scored_helices[0].mol.write_file("best-pre-fit-0.pdb");
178 // scored_helices[1].mol.write_file("best-pre-fit-1.pdb");
179
180 // score = score_helix_position(scored_helices[0].mol);
181 // std::cout << "Score 0 pre rigid body fitting: " << score << std::endl;
182 // score = score_helix_position(scored_helices[1].mol);
183 // std::cout << "Score 1 pre rigid body fitting: " << score << std::endl;
184
185 cootcxx . . $ coot/::rigid_body_fitcxx . . $ coot/rigid_body_fit(387b8788d6e9adea).(&this_eigen_scored_helices[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0].molcxx . . $ coot/scored_helix_info_t#mol., xmapcxx . . $ coot/helix_placement#xmap., map_rmsd);
186 cootcxx . . $ coot/::rigid_body_fitcxx . . $ coot/rigid_body_fit(387b8788d6e9adea).(&this_eigen_scored_helices[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1].molcxx . . $ coot/scored_helix_info_t#mol., xmapcxx . . $ coot/helix_placement#xmap., map_rmsd);
187
188 score = score_helix_positioncxx . . $ coot/helix_placement#score_helix_position(a0b84a170f8981cf).(this_eigen_scored_helices[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0].molcxx . . $ coot/scored_helix_info_t#mol.);
189 this_eigen_scored_helices[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0].scorecxx . . $ coot/scored_helix_info_t#score. = score;
190 // std::cout << "Score 0 post rigid body fitting: " << score << std::endl;
191 score = score_helix_positioncxx . . $ coot/helix_placement#score_helix_position(a0b84a170f8981cf).(this_eigen_scored_helices[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1].molcxx . . $ coot/scored_helix_info_t#mol.);
192 this_eigen_scored_helices[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1].scorecxx . . $ coot/scored_helix_info_t#score. = score;
193 // std::cout << "Score 1 post rigid body fitting: " << score << std::endl;
194
195 // scored_helices[0].mol.write_file("best-post-fit-0.pdb");
196 // scored_helices[1].mol.write_file("best-post-fit-1.pdb");
197
198 stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth#>, stdcxx . . $ std/::vectorcxx . . $ std/vector#<clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth#> > p0 =
199 decompose_helix_by_cbetacxx . . $ coot/helix_placement#decompose_helix_by_cbeta(efc016816866d094).(this_eigen_scored_helices[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0].molcxx . . $ coot/scored_helix_info_t#mol.);
200 cootcxx . . $ coot/::utilcxx . . $ coot/util/::density_stats_info_tcxx . . $ coot/util/density_stats_info_t# ds0 = score_atomscxx . . $ coot/helix_placement#score_atoms(9b6e4287d8edf03a).(p0.secondcxx . . $ std/pair#second.);
201 stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth#>, stdcxx . . $ std/::vectorcxx . . $ std/vector#<clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth#> > p1 =
202 decompose_helix_by_cbetacxx . . $ coot/helix_placement#decompose_helix_by_cbeta(efc016816866d094).(this_eigen_scored_helices[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1].molcxx . . $ coot/scored_helix_info_t#mol.);
203 cootcxx . . $ coot/::utilcxx . . $ coot/util/::density_stats_info_tcxx . . $ coot/util/density_stats_info_t# ds1 = score_atomscxx . . $ coot/helix_placement#score_atoms(9b6e4287d8edf03a).(p1.secondcxx . . $ std/pair#second.);
204
205 stdcxx . . $ std/::paircxx . . $ std/pair#<float, float> mv0 = ds0cxx . . $ std/pair#pair(dab76e35023fdb54)..mean_and_variancecxx . . $ coot/util/density_stats_info_t#mean_and_variance(1376e5766acc2ef2).();
206 stdcxx . . $ std/::paircxx . . $ std/pair#<float, float> mv1 = ds1cxx . . $ std/pair#pair(dab76e35023fdb54)..mean_and_variancecxx . . $ coot/util/density_stats_info_t#mean_and_variance(1376e5766acc2ef2).();
207 if (mv0.secondcxx . . $ std/pair#second. >= 0)
208 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "comparison of CB scores: " <<cxx . . $ std/basic_ostream#`operator<<`(2b73cd0f0517cf77). mv0.firstcxx . . $ std/pair#first. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " <<cxx . . $ std/basic_ostream#`operator<<`(2b73cd0f0517cf77). sqrtcxx . . $ sqrt(fbcf3211dfe1bfd1).(mv0.secondcxx . . $ std/pair#second.)
209 <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
210 if (mv1.secondcxx . . $ std/pair#second. >= 0)
211 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "comparison of CB scores: " <<cxx . . $ std/basic_ostream#`operator<<`(2b73cd0f0517cf77). mv1.firstcxx . . $ std/pair#first. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " <<cxx . . $ std/basic_ostream#`operator<<`(2b73cd0f0517cf77). sqrtcxx . . $ sqrt(fbcf3211dfe1bfd1).(mv1.secondcxx . . $ std/pair#second.)
212 <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
213
214 if (mv0.firstcxx . . $ std/pair#first. > mv1.firstcxx . . $ std/pair#first.) {
215 eigens_scored_helices[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).ieigen] =cxx . . $ coot/scored_helix_info_t#`operator=`(7eee9baafe7e09d6). this_eigen_scored_helices[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0];
216 cb_density_info_for_scored_helices[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).ieigen] =cxx . . $ std/pair#`operator=`(277da66fe4726b22). mv0;
217 } else {
218 eigens_scored_helices[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).ieigen] =cxx . . $ coot/scored_helix_info_t#`operator=`(7eee9baafe7e09d6). this_eigen_scored_helices[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1];
219 cb_density_info_for_scored_helices[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).ieigen] =cxx . . $ std/pair#`operator=`(277da66fe4726b22). mv1;
220 }
221 // debug: write out the helices: forwards and back for each
222 // eigen, check the flips.
223 // for (int i=0; i<2; i++) {
224 // std::string f = "post-fit";
225 // f += "-eigen:";
226 // f += coot::util::int_to_string(ieigen);
227 // f += "-ori:";
228 // f += coot::util::int_to_string(i);
229 // f += ".pdb";
230 // this_eigen_scored_helices[i].mol.write_file(f);
231 // }
232 }
233
234 int best_index = 0;
235 if (eigens_scored_helices[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1].scorecxx . . $ coot/scored_helix_info_t#score. > eigens_scored_helices[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0].scorecxx . . $ coot/scored_helix_info_t#score.)
236 best_index = 1;
237 if (eigens_scored_helices[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).2].scorecxx . . $ coot/scored_helix_info_t#score. > eigens_scored_helices[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).best_index].scorecxx . . $ coot/scored_helix_info_t#score.)
238 best_index = 2;
239 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "INFO:: CB density stats for best fit : "
240 <<cxx . . $ std/basic_ostream#`operator<<`(2b73cd0f0517cf77). cb_density_info_for_scored_helices[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).best_index].firstcxx . . $ std/pair#first. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " "
241 <<cxx . . $ std/basic_ostream#`operator<<`(2b73cd0f0517cf77). sqrtcxx . . $ sqrt(fbcf3211dfe1bfd1).(cb_density_info_for_scored_helices[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).best_index].secondcxx . . $ std/pair#second.) <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " "
242 <<cxx . . $ std/basic_ostream#`operator<<`(2b73cd0f0517cf77). cb_density_info_for_scored_helices[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).best_index].firstcxx . . $ std/pair#first./sqrtcxx . . $ sqrt(fbcf3211dfe1bfd1).(cb_density_info_for_scored_helices[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).best_index].secondcxx . . $ std/pair#second.) <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
243
244 float descrimination_ratio = 1.0; // seems a reasonable cut off, various testing.
245 descrimination_ratio = 0.5;
246
247 if ( (cb_density_info_for_scored_helices[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).best_index].firstcxx . . $ std/pair#first. > 0.0) &&
248 (cb_density_info_for_scored_helices[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).best_index].secondcxx . . $ std/pair#second. > 0.0) &&
249 (cb_density_info_for_scored_helices[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).best_index].firstcxx . . $ std/pair#first./sqrtcxx . . $ sqrt(fbcf3211dfe1bfd1).(cb_density_info_for_scored_helices[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).best_index].secondcxx . . $ std/pair#second.) > descrimination_ratio) ) {
250 mr =cxx . . $ coot/minimol/molecule#`operator=`(8e2fab78f4df6d66). eigens_scored_helices[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).best_index].molcxx . . $ coot/scored_helix_info_t#mol.;
251 mr.set_cellcxx . . $ coot/minimol/molecule#set_cell(e6881f009d13a851).(acell);
252 mr.set_spacegroupcxx . . $ coot/minimol/molecule#set_spacegroup(9c546c94e5fcce4e).(spacegroup_str_hm);
253 success = 1;
254 trim_and_growcxx . . $ coot/helix_placement#trim_and_grow(b7af30d83b4d586e).(&mr, density_level_for_trim, b_factor); // modify mr
255 float final_score = score_helix_positioncxx . . $ coot/helix_placement#score_helix_position(a0b84a170f8981cf).(mr);
256 if (final_score < 0) {
257 success = 0;
258 failure_message =cxx . . $ std/__cxx11/basic_string#`operator=`(978ca1133b5f6e74). "Sorry, low overall density. Nowhere sensible for a helix.";
259 }
260 } else {
261 success = 0;
262 failure_message =cxx . . $ std/__cxx11/basic_string#`operator=`(978ca1133b5f6e74). "Sorry, low density for CB positions - best fit ignored.";
263 }
264 } // m.mol.fragments.size() test.
265 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "INFO:: helix addition success status: " <<cxx . . $ std/basic_ostream#`operator<<`(27f8b99acd982269). success <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n";
266 return cootcxx . . $ coot/helix_placement_info_t#helix_placement_info_t(d7525711b08e4f59).::helix_placement_info_tcxx . . $ coot/helix_placement_info_t#(mr, success, failure_message);
267 }
268
269 // The Engine here is Kevin Cowtan's MR-style search.
270 //
271 // min_density_limit is typically 1 sigma
272 //
273 cootcxx . . $ coot/::helix_placement_info_tcxx . . $ coot/helix_placement_info_t#
274 cootcxx . . $ coot/::helix_placementcxx . . $ coot/helix_placement#::place_alpha_helix_near_kc_versioncxx . . $ coot/helix_placement#place_alpha_helix_near_kc_version(15796e59cf8c115c).(const clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# &pt,
275 int n_residues,
276 float min_density_limit,
277 float high_density_turning_point,
278 float b_factor,
279 float map_rmsd) const {
280
281 clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# ptc = pt;
282 for (int i=0; i<10; i++) {
283 float max_density_lim = high_density_turning_point; // min_density_limit is the
284 // wrong name, I think.
285 ptc =cxx . . $ clipper/Coord_orth#`operator=`(c3f604fd3327b93d). move_helix_centre_point_guesscxx . . $ coot/helix_placement#move_helix_centre_point_guess(14c1b8bf9c0dd15a).(ptc, max_density_lim);
286 }
287
288 // OK, let's limit the movement of the centre position to 1.5A.
289 //
290 double centre_moved_dist = sqrtcxx . . $ sqrt(fee4f1d22bc8e617).((pt-cxx . . $ clipper/operator-(44ad1d8741e04b17).ptc).lengthsqcxx . . $ clipper/Coord_orth#lengthsq(21b6c25e127938e2).());
291 double max_allowed_move = 1.0;
292 if (centre_moved_dist > max_allowed_move) {
293 clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# vcxx . . $ clipper/Coord_orth#Coord_orth(3374d1a184fcc02e).(max_allowed_move * (ptc.xcxx . . $ clipper/Coord_orth#x(cb83ef2068996cec).()-pt.xcxx . . $ clipper/Coord_orth#x(cb83ef2068996cec).())/centre_moved_dist,
294 max_allowed_move * (ptc.ycxx . . $ clipper/Coord_orth#y(cb83ef2068996cec).()-pt.ycxx . . $ clipper/Coord_orth#y(cb83ef2068996cec).())/centre_moved_dist,
295 max_allowed_move * (ptc.zcxx . . $ clipper/Coord_orth#z(cb83ef2068996cec).()-pt.zcxx . . $ clipper/Coord_orth#z(cb83ef2068996cec).())/centre_moved_dist);
296 ptc =cxx . . $ clipper/Coord_orth#`operator=`(c3f604fd3327b93d). pt +cxx . . $ clipper/operator+(44ad1d8741e04b17). v;
297 }
298
299 if (0) { // debugging initial moving
300 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "=================== called with pt " <<cxx . . $ std/`operator<<`(88df5bef833f7f83). pt.formatcxx . . $ clipper/Coord_orth#format(9c83e4702554ac51).() <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
301 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "=================== ptc now " <<cxx . . $ std/`operator<<`(88df5bef833f7f83). ptc.formatcxx . . $ clipper/Coord_orth#format(9c83e4702554ac51).() <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
302 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "=================== difference " <<cxx . . $ std/`operator<<`(88df5bef833f7f83). clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth#(ptc-cxx . . $ clipper/operator-(44ad1d8741e04b17).pt).formatcxx . . $ clipper/Coord_orth#format(9c83e4702554ac51).()
303 <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
304 }
305
306
307 float acell[6];
308 acell[0] = xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).().descrcxx . . $ clipper/Cell#descr(60e29b0f4054320c).().acxx . . $ clipper/Cell_descr#a(cb83ef2068996cec).();
309 acell[1] = xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).().descrcxx . . $ clipper/Cell#descr(60e29b0f4054320c).().bcxx . . $ clipper/Cell_descr#b(cb83ef2068996cec).();
310 acell[2] = xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).().descrcxx . . $ clipper/Cell#descr(60e29b0f4054320c).().ccxx . . $ clipper/Cell_descr#c(cb83ef2068996cec).();
311 acell[3] = clippercxx . . $ clipper/::Utilcxx . . $ clipper/Util#::rad2dcxx . . $ clipper/Util#rad2d(569b37c916856981).(xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).().descrcxx . . $ clipper/Cell#descr(60e29b0f4054320c).().alphacxx . . $ clipper/Cell_descr#alpha(cb83ef2068996cec).());
312 acell[4] = clippercxx . . $ clipper/::Utilcxx . . $ clipper/Util#::rad2dcxx . . $ clipper/Util#rad2d(569b37c916856981).(xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).().descrcxx . . $ clipper/Cell#descr(60e29b0f4054320c).().betacxx . . $ clipper/Cell_descr#beta(cb83ef2068996cec).());
313 acell[5] = clippercxx . . $ clipper/::Utilcxx . . $ clipper/Util#::rad2dcxx . . $ clipper/Util#rad2d(569b37c916856981).(xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).().descrcxx . . $ clipper/Cell#descr(60e29b0f4054320c).().gammacxx . . $ clipper/Cell_descr#gamma(cb83ef2068996cec).());
314 stdcxx . . $ std/::stringcxx . . $ std/string# spacegroup_str_hm = xmapcxx . . $ std/__cxx11/basic_string#basic_string(8f3aaafa33d05d0b)..spacegroupcxx . . $ clipper/Xmap_base#spacegroup(f2c81a655761ef05).().symbol_hmcxx . . $ clipper/Spgr_descr#symbol_hm(9c83e4702554ac51).();
315
316 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "DEBUG info:: xmap cell: "
317 <<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). clippercxx . . $ clipper/::Utilcxx . . $ clipper/Util#::rad2dcxx . . $ clipper/Util#rad2d(569b37c916856981).(xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).().descrcxx . . $ clipper/Cell#descr(60e29b0f4054320c).().alphacxx . . $ clipper/Cell_descr#alpha(cb83ef2068996cec).()) <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " "
318 <<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). clippercxx . . $ clipper/::Utilcxx . . $ clipper/Util#::rad2dcxx . . $ clipper/Util#rad2d(569b37c916856981).(xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).().descrcxx . . $ clipper/Cell#descr(60e29b0f4054320c).().betacxx . . $ clipper/Cell_descr#beta(cb83ef2068996cec).()) <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " "
319 <<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). clippercxx . . $ clipper/::Utilcxx . . $ clipper/Util#::rad2dcxx . . $ clipper/Util#rad2d(569b37c916856981).(xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).().descrcxx . . $ clipper/Cell#descr(60e29b0f4054320c).().gammacxx . . $ clipper/Cell_descr#gamma(cb83ef2068996cec).()) <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n";
320 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "DEBUG info:: xmap HM symbol: " <<cxx . . $ std/`operator<<`(88df5bef833f7f83). xmapcxx . . $ coot/helix_placement#xmap..spacegroupcxx . . $ clipper/Xmap_base#spacegroup(f2c81a655761ef05).().symbol_hmcxx . . $ clipper/Spgr_descr#symbol_hm(9c83e4702554ac51).() <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
321
322 stdcxx . . $ std/::vectorcxx . . $ std/vector#<cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::moleculecxx . . $ coot/minimol/molecule#> mrcxx . . $ std/vector#vector(83fdeebbe0501a83).(2); // part of returned value
323 cootcxx . . $ coot/::helix_placement_info_tcxx . . $ coot/helix_placement_info_t# m =
324 get_20_residue_helix_standard_orientationcxx . . $ coot/helix_placement#get_20_residue_helix_standard_orientation(6c960eda6f397b1).(n_residues, b_factor);
325 short int success = m.successcxx . . $ coot/helix_placement_info_t#success.;
326 stdcxx . . $ std/::stringcxx . . $ std/string# failure_message = mcxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5)..failure_messagecxx . . $ coot/helix_placement_info_t#failure_message.;
327 stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<float, float> > cbeta_score_holdercxx . . $ std/vector#vector(83fdeebbe0501a83).(2);
328 // initializse the score holder to bad (helix rejected)
329 cbeta_score_holder[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0] =cxx . . $ std/pair#`operator=`(ab9ebd0b824095ec). stdcxx . . $ std/pair#pair(62e1774a2dc03c82).::paircxx . . $ std/pair#<float, float> (-1.0, -1.0);
330 cbeta_score_holder[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1] =cxx . . $ std/pair#`operator=`(ab9ebd0b824095ec). stdcxx . . $ std/pair#pair(62e1774a2dc03c82).::paircxx . . $ std/pair#<float, float> (-1.0, -1.0);
331
332 if (m.molcxx . . $ coot/helix_placement_info_t#mol.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0].fragmentscxx . . $ coot/minimol/molecule#fragments..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).() > 0 ) {
333
334 // search model params
335 double cyl_len = 6.0; // half length
336 double cyl_rad = 2.8; // half diameter (radius)
337 cyl_len = double(n_residues)/2.0; // PE parameter (for helices)
338
339 // ------------- elided ----------------
340
341 float max_density_limit = high_density_turning_point;
342 clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth# ops_resultops =
343 find_best_tube_orientationcxx . . $ coot/helix_placement#find_best_tube_orientation(60e92e1d6131eae1).(ptc, cyl_len, cyl_rad, max_density_limit);
344
345 // ops[resultops] is the matrix which orients the to the helix
346 // axis around the origin.
347 stdcxx . . $ std/::vectorcxx . . $ std/vector#<clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth#> ofm =
348 optimize_rotation_fitcxx . . $ coot/helix_placement#optimize_rotation_fit(431d14f672c8af74).(m.molcxx . . $ coot/helix_placement_info_t#mol.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0], ops_resultops, ptc);
349
350 // There are 2 orientation in ofm correspoding to the up and
351 // down orientations of the initial helix. We have already had
352 // a guess at which would be the best, but we need to do a full
353 // optimization of both directions before we can decide the best.
354 //
355 // We will make the "Helix", i.e. the first solution the one
356 // with the best cb score.
357 //
358 // We will not add the second helix if it's cbeta score is not
359 // at least 0.5 * the standard deviation of the CB density. More
360 // below.
361
362 for (int iofm=0; iofm<2; iofm++) {
363 // now we need to apply ops[resultops] to the molecule.
364 //
365 if (1) {
366 mr[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iofm] =cxx . . $ coot/minimol/molecule#`operator=`(8e2fab78f4df6d66). m.molcxx . . $ coot/helix_placement_info_t#mol.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0];
367
368 clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth# to_pointcxx . . $ clipper/RTop_orth#RTop_orth(cd0dec0763f9cd6f).(clippercxx . . $ clipper/Mat33#Mat33(ca294aebd03ed32e).::Mat33cxx . . $ clipper/Mat33#<double>(1,0,0,0,1,0,0,0,1), ptc);
369 for(unsigned int ifrag=0; ifrag<mr[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iofm].fragmentscxx . . $ coot/minimol/molecule#fragments..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); ifrag++)
370 mr[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iofm][cxx . . $ coot/minimol/molecule#`operator[]`(1062c7b8e0909df1).ifrag].transformcxx . . $ coot/minimol/fragment#transform(e19fd923a135bced).(ofm[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iofm]);
371 for(unsigned int ifrag=0; ifrag<mr[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iofm].fragmentscxx . . $ coot/minimol/molecule#fragments..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); ifrag++)
372 mr[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iofm][cxx . . $ coot/minimol/molecule#`operator[]`(1062c7b8e0909df1).ifrag].transformcxx . . $ coot/minimol/fragment#transform(e19fd923a135bced).(ops_resultops);
373 for(unsigned int ifrag=0; ifrag<mr[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iofm].fragmentscxx . . $ coot/minimol/molecule#fragments..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); ifrag++)
374 mr[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iofm][cxx . . $ coot/minimol/molecule#`operator[]`(1062c7b8e0909df1).ifrag].transformcxx . . $ coot/minimol/fragment#transform(e19fd923a135bced).(to_point);
375
376 clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# dcxx . . $ clipper/Coord_orth#Coord_orth(3374d1a184fcc02e).( 0.0, 0.0, 2.0 );
377 clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# pt1(ptc +cxx . . $ clipper/operator+(44ad1d8741e04b17). ops_resultops*cxx . . $ clipper/`operator*`(6d57cab3db6fd847).d);
378 clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# pt2(ptc -cxx . . $ clipper/operator-(44ad1d8741e04b17). ops_resultops*cxx . . $ clipper/`operator*`(6d57cab3db6fd847).d);
379
380 // debugging orientation:
381 if (0) {
382 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " Helix axis: \n (set-rotation-centre " <<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). pt1.xcxx . . $ clipper/Coord_orth#x(cb83ef2068996cec).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " "
383 <<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). pt1.ycxx . . $ clipper/Coord_orth#y(cb83ef2068996cec).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " <<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). pt1.zcxx . . $ clipper/Coord_orth#z(cb83ef2068996cec).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). ")\n";
384 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " (place-atom-at-pointer)\n";
385 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " Helix axis: \n (set-rotation-centre " <<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). ptc.xcxx . . $ clipper/Coord_orth#x(cb83ef2068996cec).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " "
386 <<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). ptc.ycxx . . $ clipper/Coord_orth#y(cb83ef2068996cec).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " <<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). ptc.zcxx . . $ clipper/Coord_orth#z(cb83ef2068996cec).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). ")\n";
387 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " (place-atom-at-pointer)\n";
388 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " Helix axis: \n (set-rotation-centre " <<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). pt2.xcxx . . $ clipper/Coord_orth#x(cb83ef2068996cec).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " "
389 <<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). pt2.ycxx . . $ clipper/Coord_orth#y(cb83ef2068996cec).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " <<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). pt2.zcxx . . $ clipper/Coord_orth#z(cb83ef2068996cec).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). ")\n";
390 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " (place-atom-at-pointer)\n";
391 }
392
393 mr[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iofm].set_cellcxx . . $ coot/minimol/molecule#set_cell(e6881f009d13a851).(acell);
394 mr[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iofm].set_spacegroupcxx . . $ coot/minimol/molecule#set_spacegroup(9c546c94e5fcce4e).(spacegroup_str_hm);
395 // here set occupancies of CBetas to 0 so that they are not fitted.
396 mr[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iofm].set_atom_occcxx . . $ coot/minimol/molecule#set_atom_occ(8431f1d501be6743).(" CB "cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., 0.0);
397 cootcxx . . $ coot/::rigid_body_fitcxx . . $ coot/rigid_body_fit(387b8788d6e9adea).(&mr[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iofm], xmapcxx . . $ coot/helix_placement#xmap., map_rmsd);
398 // restore the occupancies of CBetas
399 mr[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iofm].set_atom_occcxx . . $ coot/minimol/molecule#set_atom_occ(8431f1d501be6743).(" CB "cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., 1.0);
400 success = 1;
401 trim_and_growcxx . . $ coot/helix_placement#trim_and_grow(b7af30d83b4d586e).(&mr[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iofm], min_density_limit, b_factor); // modify mr
402 float final_score = score_helix_positioncxx . . $ coot/helix_placement#score_helix_position(a0b84a170f8981cf).(mr[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iofm]);
403 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "INFO:: Helix position score: " <<cxx . . $ std/basic_ostream#`operator<<`(2b73cd0f0517cf77). final_score <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n";
404 if (final_score < 0) {
405 success = 0;
406 failure_message =cxx . . $ std/__cxx11/basic_string#`operator=`(978ca1133b5f6e74). "Low density for fitted helix. Rejected.";
407 } else {
408 // pair(other atoms, c-betas)
409 stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth#>,
410 stdcxx . . $ std/::vectorcxx . . $ std/vector#<clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth#> > p1 =
411 decompose_helix_by_cbetacxx . . $ coot/helix_placement#decompose_helix_by_cbeta(efc016816866d094).(mr[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iofm]);
412 cootcxx . . $ coot/::utilcxx . . $ coot/util/::density_stats_info_tcxx . . $ coot/util/density_stats_info_t# ds = score_atomscxx . . $ coot/helix_placement#score_atoms(9b6e4287d8edf03a).(p1.secondcxx . . $ std/pair#second.);
413 stdcxx . . $ std/::paircxx . . $ std/pair#<float, float> mv0 = dscxx . . $ std/pair#pair(dab76e35023fdb54)..mean_and_variancecxx . . $ coot/util/density_stats_info_t#mean_and_variance(1376e5766acc2ef2).();
414 if (mv0.secondcxx . . $ std/pair#second. >= 0) {
415 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "INFO:: CB density scores: mean: " <<cxx . . $ std/basic_ostream#`operator<<`(2b73cd0f0517cf77). mv0.firstcxx . . $ std/pair#first.
416 <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " stddev: " <<cxx . . $ std/basic_ostream#`operator<<`(2b73cd0f0517cf77). sqrtcxx . . $ sqrt(fbcf3211dfe1bfd1).(mv0.secondcxx . . $ std/pair#second.) <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
417
418 cbeta_score_holder[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iofm] =cxx . . $ std/pair#`operator=`(ab9ebd0b824095ec). stdcxx . . $ std/pair#pair(62e1774a2dc03c82).::paircxx . . $ std/pair#<float, float> (mv0.firstcxx . . $ std/pair#first., mv0.secondcxx . . $ std/pair#second.);
419
420 float descrimination_ratio = 1.0; // seems a reasonable cut off,
421 // various testing.
422 descrimination_ratio = 0.5; // liberal, let questionable
423 // helix through.
424 float mean_over_stddev = mv0.firstcxx . . $ std/pair#first./sqrtcxx . . $ sqrt(fbcf3211dfe1bfd1).(mv0.secondcxx . . $ std/pair#second.);
425 if (mean_over_stddev > descrimination_ratio) {
426 success = 1;
427 } else {
428 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Failed CB density test" <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
429 failure_message =cxx . . $ std/__cxx11/basic_string#`operator=`(978ca1133b5f6e74). "Failed CB density test - rejected";
430 success = 1; // debugging
431 }
432 } else {
433 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "WARNING:: Bad fit for CBs - helix rejected\n" ;
434 failure_message =cxx . . $ std/__cxx11/basic_string#`operator=`(978ca1133b5f6e74). "WARNING:: Bad fit for CBs - helix rejected";
435 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "INFO:: --------------- density_stats_info_t ds mean and var "
436 <<cxx . . $ std/basic_ostream#`operator<<`(2b73cd0f0517cf77). mv0.firstcxx . . $ std/pair#first. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " <<cxx . . $ std/basic_ostream#`operator<<`(2b73cd0f0517cf77). mv0.secondcxx . . $ std/pair#second. <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
437 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "INFO:: --------------- n " <<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). ds.ncxx . . $ coot/util/density_stats_info_t#n. <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
438 success = 0;
439 }
440 }
441 }
442 }
443 }
444 if (success) {
445 // If there was at least one helix that fitted tolerably well,
446 // turn the helices in the vector if the score for the second
447 // was beter. Also filter the molecule vector if the poorer
448 // molecule has bad stats (the mean cb density must be at least
449 // half the standard deviation of its cbeta). It also must have
450 // a score at least 0.4*the better helix score.
451 if (cbeta_score_holder[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1].firstcxx . . $ std/pair#first. > cbeta_score_holder[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0].firstcxx . . $ std/pair#first.) {
452 // second helix was better than first...
453 cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::moleculecxx . . $ coot/minimol/molecule# mtmp = mr[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0];
454 mr[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0] =cxx . . $ coot/minimol/molecule#`operator=`(8e2fab78f4df6d66). mr[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1];
455 mr[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1] =cxx . . $ coot/minimol/molecule#`operator=`(8e2fab78f4df6d66). mtmp;
456 // also swap the scores, we use them in the next test...
457 stdcxx . . $ std/::paircxx . . $ std/pair#<float, float> tmp = cbeta_score_holdercxx . . $ std/pair#pair(31533a781ed7dba3).[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0];
458 cbeta_score_holder[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0] =cxx . . $ std/pair#`operator=`(277da66fe4726b22). cbeta_score_holder[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1];
459 cbeta_score_holder[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1] =cxx . . $ std/pair#`operator=`(277da66fe4726b22). tmp;
460 }
461 // trim out "Reverse" helices with really bad scores...
462 if ((cbeta_score_holder[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1].firstcxx . . $ std/pair#first. < 0.0) ||
463 (cbeta_score_holder[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1].firstcxx . . $ std/pair#first.*2.0 < cbeta_score_holder[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1].secondcxx . . $ std/pair#second.) ||
464 (cbeta_score_holder[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1].firstcxx . . $ std/pair#first.*2.5 < cbeta_score_holder[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0].firstcxx . . $ std/pair#first.)) {
465 mr.resizecxx . . $ std/vector#resize(2c44cd906ae4e829).(1);
466 }
467 }
468 return cootcxx . . $ coot/helix_placement_info_t#helix_placement_info_t(3c8a5f91d8691310).::helix_placement_info_tcxx . . $ coot/helix_placement_info_t#(mr, success, failure_message);
469 }
470
471 // when density is above max_density_limit, start reducing the score
472 //
473 clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth#
474 cootcxx . . $ coot/::helix_placementcxx . . $ coot/helix_placement#::find_best_tube_orientationcxx . . $ coot/helix_placement#find_best_tube_orientation(60e92e1d6131eae1).(clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# ptc, double cyl_len,
475 double cyl_rad, float high_density_turning_point) const {
476
477 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "INFO:: high_density_turning_point: " <<cxx . . $ std/basic_ostream#`operator<<`(2b73cd0f0517cf77). high_density_turning_point <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
478
479 // density map score for density d:
480 // below mdl: d
481 //
482 // above mdl:
483 // 2*mdl - d
484
485 // make the search angles
486 stdcxx . . $ std/::vectorcxx . . $ std/vector#<clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth#> opscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
487 int resultops;
488
489 // make a list of rotation ops to try
490 float step =5.0; // test value
491 float beta1 =90.0; // beta search half range for mirror sym
492 float alpha1=360.0; // no gamma search for cyl sym
493 // do a uniformly sampled search of orientation space
494 for ( float bdeg=step/2; bdeg < beta1; bdeg += step ) {
495 float beta = clippercxx . . $ clipper/::Utilcxx . . $ clipper/Util#::d2radcxx . . $ clipper/Util#d2rad(569b37c916856981).(bdeg);
496 // float s = anglim/clipper::Util::intf(sin(beta)*anglim/step+1);
497 for ( float adeg=step/2; adeg < alpha1; adeg += step ) {
498 float alpha = clippercxx . . $ clipper/::Utilcxx . . $ clipper/Util#::d2radcxx . . $ clipper/Util#d2rad(569b37c916856981).(adeg);
499 clippercxx . . $ clipper/::Euler_ccp4cxx . . $ clipper/Euler_ccp4# eulercxx . . $ clipper/Euler_ccp4#Euler_ccp4(3374d1a184fcc02e).( alpha, beta, 0.0 );
500 ops.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).( clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth#(clippercxx . . $ clipper/::Rotationcxx . . $ clipper/Rotation#(euler).matrixcxx . . $ clipper/Rotation#matrix(fe3f2ee59ab37396).()) );
501 }
502 }
503 unsigned int ops_size = ops.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).();
504
505 // make inverse ops
506 stdcxx . . $ std/::vectorcxx . . $ std/vector#<clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth#> opsicxx . . $ std/vector#vector(83fdeebbe0501a83).( ops.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).() );
507 for (unsigned int j = 0; j < ops.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); j++ ) opsi[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).j] =cxx . . $ clipper/RTop_orth#`operator=`(a645a65ab075cbc5). ops[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).j].inversecxx . . $ clipper/RTop_orth#inverse(f503fb8b464cd976).();
508
509 typedef clippercxx . . $ clipper/::Xmapcxx . . $ clipper/Xmap#<float>::Map_reference_coordcxx . . $ clipper/Xmap_base#Map_reference_coord# MRCcxx . . $ coot/helix_placement#find_best_tube_orientation(60e92e1d6131eae1).MRC#;
510 MRCcxx . . $ coot/helix_placement#find_best_tube_orientation(60e92e1d6131eae1).MRC# i0cxx . . $ clipper/Xmap_base#Map_reference_coord#Map_reference_coord(49f6e7a06ebc5aa8)., iucxx . . $ clipper/Xmap_base#Map_reference_coord#Map_reference_coord(49f6e7a06ebc5aa8)., ivcxx . . $ clipper/Xmap_base#Map_reference_coord#Map_reference_coord(49f6e7a06ebc5aa8)., iwcxx . . $ clipper/Xmap_base#Map_reference_coord#Map_reference_coord(49f6e7a06ebc5aa8).;
511 stdcxx . . $ std/::vectorcxx . . $ std/vector#<double> scorescxx . . $ std/vector#vector(83fdeebbe0501a83).( ops.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).() );
512 stdcxx . . $ std/::vectorcxx . . $ std/vector#<unsigned int> n_cyl_pointscxx . . $ std/vector#vector(83fdeebbe0501a83).( ops.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).() );
513 clippercxx . . $ clipper/::Cellcxx . . $ clipper/Cell# cell = xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).();
514 clippercxx . . $ clipper/::Grid_samplingcxx . . $ clipper/Grid_sampling# grid = xmapcxx . . $ coot/helix_placement#xmap..grid_samplingcxx . . $ clipper/Xmap_base#grid_sampling(6a52163cca7b365a).();
515 clippercxx . . $ clipper/::Grid_rangecxx . . $ clipper/Grid_range# grcxx . . $ clipper/Grid_range#Grid_range(fb6037e39e93be38).( cell, grid, sqrtcxx . . $ sqrt(fee4f1d22bc8e617).(cyl_len*cyl_len+cyl_rad*cyl_rad) );
516 clippercxx . . $ clipper/::Coord_gridcxx . . $ clipper/Coord_grid# gcxx . . $ clipper/Coord_grid#Coord_grid(49f6e7a06ebc5aa8)., g0cxx . . $ clipper/Coord_grid#Coord_grid(49f6e7a06ebc5aa8)., g1cxx . . $ clipper/Coord_grid#Coord_grid(49f6e7a06ebc5aa8).;
517 clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# c0cxx . . $ clipper/Coord_orth#Coord_orth(49f6e7a06ebc5aa8)., c1cxx . . $ clipper/Coord_orth#Coord_orth(49f6e7a06ebc5aa8).;
518 float d;
519 for (unsigned int j = 0; j < ops.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); j++ ) {
520 scores[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).j] = 0.0;
521 n_cyl_points[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).j] = 0;
522 }
523
524 g =cxx . . $ clipper/Coord_grid#`operator=`(3d289c241a8b5724). ptc.coord_fraccxx . . $ clipper/Coord_orth#coord_frac(7a789c6ea68ab09d).(cell).coord_gridcxx . . $ clipper/Coord_frac#coord_grid(8af8dedfb348eb6b).(grid);
525 g0 =cxx . . $ clipper/Coord_grid#`operator=`(3d289c241a8b5724). g +cxx . . $ clipper/operator+(a245cd9d909517ae). gr.mincxx . . $ clipper/Grid_range#min(19e597278f29c546).();
526 g1 =cxx . . $ clipper/Coord_grid#`operator=`(3d289c241a8b5724). g +cxx . . $ clipper/operator+(a245cd9d909517ae). gr.maxcxx . . $ clipper/Grid_range#max(19e597278f29c546).();
527 i0 =cxx . . $ clipper/Xmap_base#Map_reference_coord#`operator=`(ca7c4d41914ee823). MRCcxx . . $ clipper/Xmap_base#Map_reference_coord#Map_reference_coord(fc604017b438f484).( xmapcxx . . $ coot/helix_placement#xmap., g0 );
528 for ( iu =cxx . . $ clipper/Xmap_base#Map_reference_coord#`operator=`(f1c726caa222c6d7). i0; iu.coordcxx . . $ clipper/Xmap_base#Map_reference_coord#coord(19e597278f29c546).().ucxx . . $ clipper/Coord_grid#u(ec45a031f4e09d1e).() <= g1.ucxx . . $ clipper/Coord_grid#u(ffa05e89dbf2c50f).(); iu.next_ucxx . . $ clipper/Xmap_base#Map_reference_coord#next_u(7e9928c547467625).() ) {
529 for ( iv =cxx . . $ clipper/Xmap_base#Map_reference_coord#`operator=`(f1c726caa222c6d7). iu; iv.coordcxx . . $ clipper/Xmap_base#Map_reference_coord#coord(19e597278f29c546).().vcxx . . $ clipper/Coord_grid#v(ec45a031f4e09d1e).() <= g1.vcxx . . $ clipper/Coord_grid#v(ffa05e89dbf2c50f).(); iv.next_vcxx . . $ clipper/Xmap_base#Map_reference_coord#next_v(7e9928c547467625).() )
530 for ( iw =cxx . . $ clipper/Xmap_base#Map_reference_coord#`operator=`(f1c726caa222c6d7). iv; iw.coordcxx . . $ clipper/Xmap_base#Map_reference_coord#coord(19e597278f29c546).().wcxx . . $ clipper/Coord_grid#w(ec45a031f4e09d1e).() <= g1.wcxx . . $ clipper/Coord_grid#w(ffa05e89dbf2c50f).(); iw.next_wcxx . . $ clipper/Xmap_base#Map_reference_coord#next_w(7e9928c547467625).() ) {
531 c0 =cxx . . $ clipper/Coord_orth#`operator=`(c3f604fd3327b93d). iw.coord_orthcxx . . $ clipper/Xmap_base#Map_reference_coord#coord_orth(da49533f68bc3540).() -cxx . . $ clipper/operator-(44ad1d8741e04b17). ptc;
532 for (unsigned int j = 0; j < ops_size; j++ ) {
533 c1 =cxx . . $ clipper/Coord_orth#`operator=`(c3f604fd3327b93d). opsi[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).j] *cxx . . $ clipper/`operator*`(6d57cab3db6fd847). c0;
534 if ( fabscxx . . $ fabs(fee4f1d22bc8e617).(c1.zcxx . . $ clipper/Coord_orth#z(cb83ef2068996cec).()) < cyl_len &&
535 c1.xcxx . . $ clipper/Coord_orth#x(cb83ef2068996cec).()*c1.xcxx . . $ clipper/Coord_orth#x(cb83ef2068996cec).()+c1.ycxx . . $ clipper/Coord_orth#y(cb83ef2068996cec).()*c1.ycxx . . $ clipper/Coord_orth#y(cb83ef2068996cec).() < cyl_rad*cyl_rad ) {
536 d = xmapcxx . . $ coot/helix_placement#xmap.[cxx . . $ clipper/Xmap#`operator[]`(43161cfe7b08af99).iw];
537 double this_score = (d > high_density_turning_point ? 2*high_density_turning_point-d : d);
538 // std::cout << "this_score: " << this_score << " using d " << d << std::endl;
539 scores[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).j] += this_score;
540 // scores[j] += d;
541 n_cyl_points[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).j]++;
542 }
543 }
544 }
545 }
546
547 if (0) // debug
548 for (unsigned int j = 0; j < ops.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); j++)
549 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "orientation " <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). j <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " score " <<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). scores[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).j] <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). n_cyl_points[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).j]
550 <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " points" <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
551
552 unsigned int jmax = 0;
553 for (unsigned int j = 0; j < ops.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); j++)
554 if (scores[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).j] > scores[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).jmax])
555 jmax = j;
556 resultops = jmax;
557 return ops[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).resultops];
558 }
559
560
561 // Return the orientation for the best fit and the orientation for the
562 // best fit with the helix oriented the other way up. The orientation
563 // matrices contain the flipping operator too.
564 //
565 stdcxx . . $ std/::vectorcxx . . $ std/vector#<clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth#>
566 cootcxx . . $ coot/::helix_placementcxx . . $ coot/helix_placement#::optimize_rotation_fitcxx . . $ coot/helix_placement#optimize_rotation_fit(431d14f672c8af74).(const cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::moleculecxx . . $ coot/minimol/molecule# &helix,
567 const clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth# &axis_ori,
568 const clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# &helix_point) const {
569
570 // helix.write_file("helix-pre-optim.pdb");
571 stdcxx . . $ std/::vectorcxx . . $ std/vector#<clippercxx . . $ clipper/::Mat33cxx . . $ clipper/Mat33#<double> > flip_rotated_matricescxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
572 flip_rotated_matrices.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(clippercxx . . $ clipper/Mat33#Mat33(ca294aebd03ed32e).::Mat33cxx . . $ clipper/Mat33#<double>(1,0,0,0,1,0,0,0,1));
573 flip_rotated_matrices.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(clippercxx . . $ clipper/Mat33#Mat33(ca294aebd03ed32e).::Mat33cxx . . $ clipper/Mat33#<double>(-1, 0, 0, 0, 1, 0, 0, 0, -1));
574 float score;
575 stdcxx . . $ std/::vectorcxx . . $ std/vector#<float> best_scorecxx . . $ std/vector#vector(229e4d6bd205de31).(2,-9999.9);
576 stdcxx . . $ std/::vectorcxx . . $ std/vector#<clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth#> best_rtopcxx . . $ std/vector#vector(83fdeebbe0501a83).(2);
577
578 for (unsigned int irm=0; irm<flip_rotated_matrices.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); irm++) {
579 cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::moleculecxx . . $ coot/minimol/molecule# rotated_helix = helix;
580 // apply flip (180 degrees (upsidedown)) matrices to rotated_helix then:
581 clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth# flip_rtopcxx . . $ clipper/RTop_orth#RTop_orth(cd0dec0763f9cd6f).(flip_rotated_matrices[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).irm],
582 clippercxx . . $ clipper/Coord_orth#Coord_orth(3374d1a184fcc02e).::Coord_orthcxx . . $ clipper/Coord_orth#(0,0,0));
583 for(unsigned int ifrag=0; ifrag<rotated_helix.fragmentscxx . . $ coot/minimol/molecule#fragments..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); ifrag++)
584 rotated_helix[cxx . . $ coot/minimol/molecule#`operator[]`(1062c7b8e0909df1).ifrag].transformcxx . . $ coot/minimol/fragment#transform(e19fd923a135bced).(flip_rtop);
585
586
587 // if (1) {
588 // std::string s("rotated-helix-");
589 // s += coot::util::int_to_string(irm);
590 // s += ".pdb";
591 // rotated_helix.write_file(s);
592 // }
593
594 // now search for best rotation round the helix axis:
595 //
596 int theta_count = 0; // for debugging
597 for (float theta=0; theta<2*M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`!; theta += 0.2) {
598
599 cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::moleculecxx . . $ coot/minimol/molecule# theta_mol = rotated_helix;
600
601 double sin_t = sincxx . . $ sin(fbcf3211dfe1bfd1).(theta);
602 double cos_t = coscxx . . $ cos(fbcf3211dfe1bfd1).(theta);
603 clippercxx . . $ clipper/::Mat33cxx . . $ clipper/Mat33#<double> theta_matcxx . . $ clipper/Mat33#Mat33(ca294aebd03ed32e).(cos_t,-sin_t,0, sin_t,cos_t,0, 0,0,1);
604 clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth# theta_rtopcxx . . $ clipper/RTop_orth#RTop_orth(cd0dec0763f9cd6f).(theta_mat, clippercxx . . $ clipper/Coord_orth#Coord_orth(3374d1a184fcc02e).::Coord_orthcxx . . $ clipper/Coord_orth#(0,0,0));
605 for(unsigned int ifrag=0; ifrag<rotated_helix.fragmentscxx . . $ coot/minimol/molecule#fragments..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); ifrag++)
606 theta_mol[cxx . . $ coot/minimol/molecule#`operator[]`(1062c7b8e0909df1).ifrag].transformcxx . . $ coot/minimol/fragment#transform(e19fd923a135bced).(theta_rtop);
607
608 // finally apply eigen to shift to position in map.
609 clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth# tcxx . . $ clipper/RTop_orth#RTop_orth(cd0dec0763f9cd6f).(axis_ori.rotcxx . . $ clipper/RTop#rot(ba7fec5062424102).(), helix_point +cxx . . $ clipper/operator+(46588243a4d00b95). axis_ori.trncxx . . $ clipper/RTop#trn(e52ad8594b15af75).());
610 for(unsigned int ifrag=0; ifrag<theta_mol.fragmentscxx . . $ coot/minimol/molecule#fragments..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); ifrag++)
611 theta_mol[cxx . . $ coot/minimol/molecule#`operator[]`(1062c7b8e0909df1).ifrag].transformcxx . . $ coot/minimol/fragment#transform(e19fd923a135bced).(t);
612 score = score_helix_positioncxx . . $ coot/helix_placement#score_helix_position(a0b84a170f8981cf).(theta_mol);
613 if (score > best_score[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).irm]) {
614 best_rtop[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).irm] =cxx . . $ clipper/RTop_orth#`operator=`(a645a65ab075cbc5). clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth#(theta_rtop *cxx . . $ clipper/`operator*`(8362d4076c27ca0e). flip_rtop);
615 best_score[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).irm] = score;
616 }
617
618 if (0) { // debug
619 stdcxx . . $ std/::stringcxx . . $ std/string# scxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).("theta-helix-flip-");
620 s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). cootcxx . . $ coot/::utilcxx . . $ coot/util/::int_to_stringcxx . . $ coot/util/int_to_string(7eb93f795f0defb3).(irm);
621 s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). "-theta-";
622 s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). cootcxx . . $ coot/::utilcxx . . $ coot/util/::int_to_stringcxx . . $ coot/util/int_to_string(7eb93f795f0defb3).(theta_count);
623 s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). ".pdb";
624 theta_mol.write_filecxx . . $ coot/minimol/molecule#write_file(d292696f89fe1693).(scxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5)., 20.0);
625 }
626 theta_count++;
627 }
628
629 if (0) { // debug
630 cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::moleculecxx . . $ coot/minimol/molecule# t = helix;
631 for(unsigned int ifrag=0; ifrag<t.fragmentscxx . . $ coot/minimol/molecule#fragments..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); ifrag++)
632 t[cxx . . $ coot/minimol/molecule#`operator[]`(1062c7b8e0909df1).ifrag].transformcxx . . $ coot/minimol/fragment#transform(e19fd923a135bced).(best_rtop[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).irm]);
633 stdcxx . . $ std/::stringcxx . . $ std/string# s = "flipped-"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).;
634 s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). cootcxx . . $ coot/::utilcxx . . $ coot/util/::int_to_stringcxx . . $ coot/util/int_to_string(7eb93f795f0defb3).(irm);
635 s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). ".pdb";
636 t.write_filecxx . . $ coot/minimol/molecule#write_file(d292696f89fe1693).(scxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5)., 20.0);
637 }
638 }
639 stdcxx . . $ std/::vectorcxx . . $ std/vector#<clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth#> flip_best_rtopcxx . . $ std/vector#vector(83fdeebbe0501a83).(2);
640
641 flip_best_rtop[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0] =cxx . . $ clipper/RTop_orth#`operator=`(48c648009b6314b). best_rtop[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0];
642 flip_best_rtop[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1] =cxx . . $ clipper/RTop_orth#`operator=`(48c648009b6314b). best_rtop[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1];
643 if (best_score[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1] > best_score[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0]) {
644 flip_best_rtop[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0] =cxx . . $ clipper/RTop_orth#`operator=`(48c648009b6314b). best_rtop[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1];
645 flip_best_rtop[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1] =cxx . . $ clipper/RTop_orth#`operator=`(48c648009b6314b). best_rtop[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0];
646 }
647 return flip_best_rtopcxx . . $ std/vector#vector(6f559d22b039ccdb).;
648 }
649
650
651 clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth#
652 cootcxx . . $ coot/::helix_placementcxx . . $ coot/helix_placement#::move_helix_centre_point_guesscxx . . $ coot/helix_placement#move_helix_centre_point_guess(14c1b8bf9c0dd15a).(const clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# &pt,
653 float density_max) const {
654
655 int i=0;
656
657 // First sample density in sphere around point and find the
658 // weighted averge.
659
660 float search_radius = 5.2; // A
661 float search_radius_sq = search_radius * search_radius;
662
663 clippercxx . . $ clipper/::Coord_fraccxx . . $ clipper/Coord_frac# cf = pt.coord_fraccxx . . $ clipper/Coord_orth#coord_frac(7a789c6ea68ab09d).(xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).());
664 clippercxx . . $ clipper/::Coord_fraccxx . . $ clipper/Coord_frac# box0cxx . . $ clipper/Coord_frac#Coord_frac(3374d1a184fcc02e).(cf.ucxx . . $ clipper/Coord_frac#u(cb83ef2068996cec).() - search_radius/xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).().descrcxx . . $ clipper/Cell#descr(60e29b0f4054320c).().acxx . . $ clipper/Cell_descr#a(cb83ef2068996cec).(),
665 cf.vcxx . . $ clipper/Coord_frac#v(cb83ef2068996cec).() - search_radius/xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).().descrcxx . . $ clipper/Cell#descr(60e29b0f4054320c).().bcxx . . $ clipper/Cell_descr#b(cb83ef2068996cec).(),
666 cf.wcxx . . $ clipper/Coord_frac#w(cb83ef2068996cec).() - search_radius/xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).().descrcxx . . $ clipper/Cell#descr(60e29b0f4054320c).().ccxx . . $ clipper/Cell_descr#c(cb83ef2068996cec).());
667
668 clippercxx . . $ clipper/::Coord_fraccxx . . $ clipper/Coord_frac# box1cxx . . $ clipper/Coord_frac#Coord_frac(3374d1a184fcc02e).(cf.ucxx . . $ clipper/Coord_frac#u(cb83ef2068996cec).() + search_radius/xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).().descrcxx . . $ clipper/Cell#descr(60e29b0f4054320c).().acxx . . $ clipper/Cell_descr#a(cb83ef2068996cec).(),
669 cf.vcxx . . $ clipper/Coord_frac#v(cb83ef2068996cec).() + search_radius/xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).().descrcxx . . $ clipper/Cell#descr(60e29b0f4054320c).().bcxx . . $ clipper/Cell_descr#b(cb83ef2068996cec).(),
670 cf.wcxx . . $ clipper/Coord_frac#w(cb83ef2068996cec).() + search_radius/xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).().descrcxx . . $ clipper/Cell#descr(60e29b0f4054320c).().ccxx . . $ clipper/Cell_descr#c(cb83ef2068996cec).());
671
672 clippercxx . . $ clipper/::Grid_mapcxx . . $ clipper/Grid_map# gridcxx . . $ clipper/Grid_range#Grid_range(c3fadf5ed512037f).(box0.coord_gridcxx . . $ clipper/Coord_frac#coord_grid(8af8dedfb348eb6b).(xmapcxx . . $ coot/helix_placement#xmap..grid_samplingcxx . . $ clipper/Xmap_base#grid_sampling(6a52163cca7b365a).()),
673 box1.coord_gridcxx . . $ clipper/Coord_frac#coord_grid(8af8dedfb348eb6b).(xmapcxx . . $ coot/helix_placement#xmap..grid_samplingcxx . . $ clipper/Xmap_base#grid_sampling(6a52163cca7b365a).()));
674
675 clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# sumcxx . . $ clipper/Coord_orth#Coord_orth(3374d1a184fcc02e).(0,0,0);
676 float weight_sum = 0;
677 float weight;
678 int n_samples = 0;
679 clippercxx . . $ clipper/::Xmap_basecxx . . $ clipper/Xmap_base#::Map_reference_coordcxx . . $ clipper/Xmap_base#Map_reference_coord# ixcxx . . $ clipper/Xmap_base#Map_reference_coord#Map_reference_coord(fc604017b438f484).(xmapcxx . . $ coot/helix_placement#xmap., grid.mincxx . . $ clipper/Grid_range#min(19e597278f29c546).()), iucxx . . $ clipper/Xmap_base#Map_reference_coord#Map_reference_coord(49f6e7a06ebc5aa8)., ivcxx . . $ clipper/Xmap_base#Map_reference_coord#Map_reference_coord(49f6e7a06ebc5aa8)., iwcxx . . $ clipper/Xmap_base#Map_reference_coord#Map_reference_coord(49f6e7a06ebc5aa8).;
680 for ( iu =cxx . . $ clipper/Xmap_base#Map_reference_coord#`operator=`(f1c726caa222c6d7). ix; iu.coordcxx . . $ clipper/Xmap_base#Map_reference_coord#coord(19e597278f29c546).().ucxx . . $ clipper/Coord_grid#u(ec45a031f4e09d1e).() <= grid.maxcxx . . $ clipper/Grid_range#max(19e597278f29c546).().ucxx . . $ clipper/Coord_grid#u(ec45a031f4e09d1e).(); iu.next_ucxx . . $ clipper/Xmap_base#Map_reference_coord#next_u(7e9928c547467625).() ) {
681 float ivcount = 0;
682 // std::cout << "iv limits: " << iv.coord().v() << " " << grid.max().v() << std::endl;
683 for ( iv =cxx . . $ clipper/Xmap_base#Map_reference_coord#`operator=`(f1c726caa222c6d7). iu; iv.coordcxx . . $ clipper/Xmap_base#Map_reference_coord#coord(19e597278f29c546).().vcxx . . $ clipper/Coord_grid#v(ec45a031f4e09d1e).() <= grid.maxcxx . . $ clipper/Grid_range#max(19e597278f29c546).().vcxx . . $ clipper/Coord_grid#v(ec45a031f4e09d1e).(); iv.next_vcxx . . $ clipper/Xmap_base#Map_reference_coord#next_v(7e9928c547467625).() ) {
684 // std::cout << " iv..." << ivcount << std::endl;
685 ivcount++;
686 for ( iw =cxx . . $ clipper/Xmap_base#Map_reference_coord#`operator=`(f1c726caa222c6d7). iv; iw.coordcxx . . $ clipper/Xmap_base#Map_reference_coord#coord(19e597278f29c546).().wcxx . . $ clipper/Coord_grid#w(ec45a031f4e09d1e).() <= grid.maxcxx . . $ clipper/Grid_range#max(19e597278f29c546).().wcxx . . $ clipper/Coord_grid#w(ec45a031f4e09d1e).(); iw.next_wcxx . . $ clipper/Xmap_base#Map_reference_coord#next_w(7e9928c547467625).() ) {
687 // sample a sphere
688 if ( (iw.coordcxx . . $ clipper/Xmap_base#Map_reference_coord#coord(19e597278f29c546).().coord_fraccxx . . $ clipper/Coord_grid#coord_frac(f26d1ccf9b8333c9).(xmapcxx . . $ coot/helix_placement#xmap..grid_samplingcxx . . $ clipper/Xmap_base#grid_sampling(6a52163cca7b365a).()).coord_orthcxx . . $ clipper/Coord_frac#coord_orth(3e49f05e7ab7344).(xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).()) -cxx . . $ clipper/operator-(44ad1d8741e04b17). pt).lengthsqcxx . . $ clipper/Coord_orth#lengthsq(21b6c25e127938e2).() < search_radius_sq) {
689 // Get the position of that grid coord and weight it by xmap[iw]
690
691 float d = xmapcxx . . $ coot/helix_placement#xmap.[cxx . . $ clipper/Xmap#`operator[]`(43161cfe7b08af99).iw];
692 if (d > density_max)
693 d = density_max;
694
695 weight = d * d;
696 sum +=cxx . . $ clipper/Vec3#`operator+=`(aebd1b88eec26ecc). clippercxx . . $ clipper/Coord_orth#Coord_orth(3374d1a184fcc02e).::Coord_orthcxx . . $ clipper/Coord_orth#(iw.coord_orthcxx . . $ clipper/Xmap_base#Map_reference_coord#coord_orth(da49533f68bc3540).().xcxx . . $ clipper/Coord_orth#x(cb83ef2068996cec).() * weight,
697 iw.coord_orthcxx . . $ clipper/Xmap_base#Map_reference_coord#coord_orth(da49533f68bc3540).().ycxx . . $ clipper/Coord_orth#y(cb83ef2068996cec).() * weight,
698 iw.coord_orthcxx . . $ clipper/Xmap_base#Map_reference_coord#coord_orth(da49533f68bc3540).().zcxx . . $ clipper/Coord_orth#z(cb83ef2068996cec).() * weight);
699 weight_sum += weight;
700 n_samples++;
701 }
702 }
703 }
704 }
705
706 clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# new_pt = pt;
707 if (n_samples > 0) {
708 double one_over = 1/(weight_sum);
709 // double one_over = 1/(double(n_samples));
710
711 new_pt =cxx . . $ clipper/Coord_orth#`operator=`(c3f604fd3327b93d). (one_over *cxx . . $ clipper/`operator*`(25eee10b02de6d36). sum);
712
713 if (0) {
714 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "DEBUG:: starting point: " <<cxx . . $ std/`operator<<`(88df5bef833f7f83). pt.formatcxx . . $ clipper/Coord_orth#format(9c83e4702554ac51).() <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
715 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "DEBUG:: mean point: " <<cxx . . $ std/`operator<<`(88df5bef833f7f83). new_pt.formatcxx . . $ clipper/Coord_orth#format(9c83e4702554ac51).() <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
716 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "DEBUG:: moved... " <<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). sqrtcxx . . $ sqrt(fee4f1d22bc8e617).((pt -cxx . . $ clipper/operator-(44ad1d8741e04b17). new_pt).lengthsqcxx . . $ clipper/Coord_orth#lengthsq(21b6c25e127938e2).()) <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
717 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "DEBUG:: nsamples: " <<cxx . . $ std/basic_ostream#`operator<<`(23b6575433a77e57). n_samples <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
718 }
719
720 i = 1; // a good thing
721 }
722
723 // std::cout << "DEBUG:: total moved " << sqrt((pt-new_pt).lengthsq()) << std::endl;
724 return new_pt;
725 }
726
727 // Return the index of the highest eigen value and the raw rotation matix
728 //
729 cootcxx . . $ coot/::eigen_info_tcxx . . $ coot/eigen_info_t#
730 cootcxx . . $ coot/::helix_placementcxx . . $ coot/helix_placement#::helix_eigen_systemcxx . . $ coot/helix_placement#helix_eigen_system(bf62a47acffef0f4).(const clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# mean_pos,
731 float search_radius) const {
732
733 // set up the covariance matrix
734
735 clippercxx . . $ clipper/::Matrixcxx . . $ clipper/Matrix#<double> matcxx . . $ clipper/Matrix#Matrix(f27ff5a0a080eb8a).(3,3);
736 for (int ii=0; ii<3; ii++)
737 for (int jj=0; jj<3; jj++)
738 mat(cxx . . $ clipper/Array2d#`operator()`(2ad352fa902d6713).ii,jj) = 0.0;
739
740 // float search_radius = 8.0; // A
741 float search_radius_sq = search_radius * search_radius;
742
743 clippercxx . . $ clipper/::Coord_fraccxx . . $ clipper/Coord_frac# cf = mean_pos.coord_fraccxx . . $ clipper/Coord_orth#coord_frac(7a789c6ea68ab09d).(xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).());
744 clippercxx . . $ clipper/::Coord_fraccxx . . $ clipper/Coord_frac# box0cxx . . $ clipper/Coord_frac#Coord_frac(3374d1a184fcc02e).(cf.ucxx . . $ clipper/Coord_frac#u(cb83ef2068996cec).() - search_radius/xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).().descrcxx . . $ clipper/Cell#descr(60e29b0f4054320c).().acxx . . $ clipper/Cell_descr#a(cb83ef2068996cec).(),
745 cf.vcxx . . $ clipper/Coord_frac#v(cb83ef2068996cec).() - search_radius/xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).().descrcxx . . $ clipper/Cell#descr(60e29b0f4054320c).().bcxx . . $ clipper/Cell_descr#b(cb83ef2068996cec).(),
746 cf.wcxx . . $ clipper/Coord_frac#w(cb83ef2068996cec).() - search_radius/xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).().descrcxx . . $ clipper/Cell#descr(60e29b0f4054320c).().ccxx . . $ clipper/Cell_descr#c(cb83ef2068996cec).());
747
748 clippercxx . . $ clipper/::Coord_fraccxx . . $ clipper/Coord_frac# box1cxx . . $ clipper/Coord_frac#Coord_frac(3374d1a184fcc02e).(cf.ucxx . . $ clipper/Coord_frac#u(cb83ef2068996cec).() + search_radius/xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).().descrcxx . . $ clipper/Cell#descr(60e29b0f4054320c).().acxx . . $ clipper/Cell_descr#a(cb83ef2068996cec).(),
749 cf.vcxx . . $ clipper/Coord_frac#v(cb83ef2068996cec).() + search_radius/xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).().descrcxx . . $ clipper/Cell#descr(60e29b0f4054320c).().bcxx . . $ clipper/Cell_descr#b(cb83ef2068996cec).(),
750 cf.wcxx . . $ clipper/Coord_frac#w(cb83ef2068996cec).() + search_radius/xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).().descrcxx . . $ clipper/Cell#descr(60e29b0f4054320c).().ccxx . . $ clipper/Cell_descr#c(cb83ef2068996cec).());
751
752 clippercxx . . $ clipper/::Grid_mapcxx . . $ clipper/Grid_map# gridcxx . . $ clipper/Grid_range#Grid_range(c3fadf5ed512037f).(box0.coord_gridcxx . . $ clipper/Coord_frac#coord_grid(8af8dedfb348eb6b).(xmapcxx . . $ coot/helix_placement#xmap..grid_samplingcxx . . $ clipper/Xmap_base#grid_sampling(6a52163cca7b365a).()),
753 box1.coord_gridcxx . . $ clipper/Coord_frac#coord_grid(8af8dedfb348eb6b).(xmapcxx . . $ coot/helix_placement#xmap..grid_samplingcxx . . $ clipper/Xmap_base#grid_sampling(6a52163cca7b365a).()));
754
755 float d;
756 int n_samples = 0;
757 float sum_weights = 0;
758 clippercxx . . $ clipper/::Xmap_basecxx . . $ clipper/Xmap_base#::Map_reference_coordcxx . . $ clipper/Xmap_base#Map_reference_coord# ixcxx . . $ clipper/Xmap_base#Map_reference_coord#Map_reference_coord(fc604017b438f484).(xmapcxx . . $ coot/helix_placement#xmap., grid.mincxx . . $ clipper/Grid_range#min(19e597278f29c546).()), iucxx . . $ clipper/Xmap_base#Map_reference_coord#Map_reference_coord(49f6e7a06ebc5aa8)., ivcxx . . $ clipper/Xmap_base#Map_reference_coord#Map_reference_coord(49f6e7a06ebc5aa8)., iwcxx . . $ clipper/Xmap_base#Map_reference_coord#Map_reference_coord(49f6e7a06ebc5aa8).;
759 for ( iu =cxx . . $ clipper/Xmap_base#Map_reference_coord#`operator=`(f1c726caa222c6d7). ix; iu.coordcxx . . $ clipper/Xmap_base#Map_reference_coord#coord(19e597278f29c546).().ucxx . . $ clipper/Coord_grid#u(ec45a031f4e09d1e).() <= grid.maxcxx . . $ clipper/Grid_range#max(19e597278f29c546).().ucxx . . $ clipper/Coord_grid#u(ec45a031f4e09d1e).(); iu.next_ucxx . . $ clipper/Xmap_base#Map_reference_coord#next_u(7e9928c547467625).() ) {
760 for ( iv =cxx . . $ clipper/Xmap_base#Map_reference_coord#`operator=`(f1c726caa222c6d7). iu; iv.coordcxx . . $ clipper/Xmap_base#Map_reference_coord#coord(19e597278f29c546).().vcxx . . $ clipper/Coord_grid#v(ec45a031f4e09d1e).() <= grid.maxcxx . . $ clipper/Grid_range#max(19e597278f29c546).().vcxx . . $ clipper/Coord_grid#v(ec45a031f4e09d1e).(); iv.next_vcxx . . $ clipper/Xmap_base#Map_reference_coord#next_v(7e9928c547467625).() ) {
761 for ( iw =cxx . . $ clipper/Xmap_base#Map_reference_coord#`operator=`(f1c726caa222c6d7). iv; iw.coordcxx . . $ clipper/Xmap_base#Map_reference_coord#coord(19e597278f29c546).().wcxx . . $ clipper/Coord_grid#w(ec45a031f4e09d1e).() <= grid.maxcxx . . $ clipper/Grid_range#max(19e597278f29c546).().wcxx . . $ clipper/Coord_grid#w(ec45a031f4e09d1e).(); iw.next_wcxx . . $ clipper/Xmap_base#Map_reference_coord#next_w(7e9928c547467625).() ) {
762 // sample a sphere
763 clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# co = iw.coord_orthcxx . . $ clipper/Xmap_base#Map_reference_coord#coord_orth(da49533f68bc3540).();
764 if ( (co -cxx . . $ clipper/operator-(44ad1d8741e04b17). mean_pos).lengthsqcxx . . $ clipper/Coord_orth#lengthsq(21b6c25e127938e2).() < search_radius_sq) {
765 // Get the position of that grid coord and weight it by xmap[iw]
766
767 d = xmapcxx . . $ coot/helix_placement#xmap.[cxx . . $ clipper/Xmap#`operator[]`(43161cfe7b08af99).iw];
768 if (d < 0)
769 d = 0;
770 d *= d;
771
772 mat(cxx . . $ clipper/Array2d#`operator()`(2ad352fa902d6713).0,0) += d * (co.xcxx . . $ clipper/Coord_orth#x(cb83ef2068996cec).() - mean_pos.xcxx . . $ clipper/Coord_orth#x(cb83ef2068996cec).()) * (co.xcxx . . $ clipper/Coord_orth#x(cb83ef2068996cec).() - mean_pos.xcxx . . $ clipper/Coord_orth#x(cb83ef2068996cec).());
773 mat(cxx . . $ clipper/Array2d#`operator()`(2ad352fa902d6713).0,1) += d * (co.xcxx . . $ clipper/Coord_orth#x(cb83ef2068996cec).() - mean_pos.xcxx . . $ clipper/Coord_orth#x(cb83ef2068996cec).()) * (co.ycxx . . $ clipper/Coord_orth#y(cb83ef2068996cec).() - mean_pos.ycxx . . $ clipper/Coord_orth#y(cb83ef2068996cec).());
774 mat(cxx . . $ clipper/Array2d#`operator()`(2ad352fa902d6713).0,2) += d * (co.xcxx . . $ clipper/Coord_orth#x(cb83ef2068996cec).() - mean_pos.xcxx . . $ clipper/Coord_orth#x(cb83ef2068996cec).()) * (co.zcxx . . $ clipper/Coord_orth#z(cb83ef2068996cec).() - mean_pos.zcxx . . $ clipper/Coord_orth#z(cb83ef2068996cec).());
775 mat(cxx . . $ clipper/Array2d#`operator()`(2ad352fa902d6713).1,0) += d * (co.ycxx . . $ clipper/Coord_orth#y(cb83ef2068996cec).() - mean_pos.ycxx . . $ clipper/Coord_orth#y(cb83ef2068996cec).()) * (co.xcxx . . $ clipper/Coord_orth#x(cb83ef2068996cec).() - mean_pos.xcxx . . $ clipper/Coord_orth#x(cb83ef2068996cec).());
776 mat(cxx . . $ clipper/Array2d#`operator()`(2ad352fa902d6713).1,1) += d * (co.ycxx . . $ clipper/Coord_orth#y(cb83ef2068996cec).() - mean_pos.ycxx . . $ clipper/Coord_orth#y(cb83ef2068996cec).()) * (co.ycxx . . $ clipper/Coord_orth#y(cb83ef2068996cec).() - mean_pos.ycxx . . $ clipper/Coord_orth#y(cb83ef2068996cec).());
777 mat(cxx . . $ clipper/Array2d#`operator()`(2ad352fa902d6713).1,2) += d * (co.ycxx . . $ clipper/Coord_orth#y(cb83ef2068996cec).() - mean_pos.ycxx . . $ clipper/Coord_orth#y(cb83ef2068996cec).()) * (co.zcxx . . $ clipper/Coord_orth#z(cb83ef2068996cec).() - mean_pos.zcxx . . $ clipper/Coord_orth#z(cb83ef2068996cec).());
778 mat(cxx . . $ clipper/Array2d#`operator()`(2ad352fa902d6713).2,0) += d * (co.zcxx . . $ clipper/Coord_orth#z(cb83ef2068996cec).() - mean_pos.zcxx . . $ clipper/Coord_orth#z(cb83ef2068996cec).()) * (co.xcxx . . $ clipper/Coord_orth#x(cb83ef2068996cec).() - mean_pos.xcxx . . $ clipper/Coord_orth#x(cb83ef2068996cec).());
779 mat(cxx . . $ clipper/Array2d#`operator()`(2ad352fa902d6713).2,1) += d * (co.zcxx . . $ clipper/Coord_orth#z(cb83ef2068996cec).() - mean_pos.zcxx . . $ clipper/Coord_orth#z(cb83ef2068996cec).()) * (co.ycxx . . $ clipper/Coord_orth#y(cb83ef2068996cec).() - mean_pos.ycxx . . $ clipper/Coord_orth#y(cb83ef2068996cec).());
780 mat(cxx . . $ clipper/Array2d#`operator()`(2ad352fa902d6713).2,2) += d * (co.zcxx . . $ clipper/Coord_orth#z(cb83ef2068996cec).() - mean_pos.zcxx . . $ clipper/Coord_orth#z(cb83ef2068996cec).()) * (co.zcxx . . $ clipper/Coord_orth#z(cb83ef2068996cec).() - mean_pos.zcxx . . $ clipper/Coord_orth#z(cb83ef2068996cec).());
781 sum_weights += d;
782 n_samples++;
783 }
784 }
785 }
786 }
787 // change mat
788 stdcxx . . $ std/::vectorcxx . . $ std/vector#<double> eigens = mat.eigencxx . . $ clipper/Matrix#eigen(cba6ef3ffaa54966).(false);
789
790 int best_eigen_index = 0;
791 if (eigens[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1] > eigens[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0])
792 best_eigen_index = 1;
793 if (eigens[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).2] > eigens[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).best_eigen_index])
794 best_eigen_index = 2;
795
796 // std::cout << " Biggest eigen is number " << best_eigen_index << std::endl;
797 // std::cout << "eigens 0 " <<eigens[0] << " " << sqrt(eigens[0]/float(sum_weights))
798 // << std::endl;
799 // std::cout << "eigens 1 " <<eigens[1] << " " << sqrt(eigens[1]/float(sum_weights))
800 // << std::endl;
801 // std::cout << "eigens 2 " <<eigens[2] << " " << sqrt(eigens[2]/float(sum_weights))
802 // << std::endl;
803 // double eigen_descrimination_factor = eigens[best_eigen_index] * eigens[best_eigen_index] * eigens[best_eigen_index]/(eigens[0] * eigens[1] * eigens[2]);
804 // std::cout << "Eigens descrimination factor: " << eigen_descrimination_factor
805 // << std::endl;
806
807 // std::cout << "n samples: " << n_samples << std::endl;
808 // std::cout << "sum weight " << sum_weights << std::endl;
809
810 clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# e0cxx . . $ clipper/Coord_orth#Coord_orth(3374d1a184fcc02e).(mat(cxx . . $ clipper/Array2d#`operator()`(2ad352fa902d6713).0,0), mat(cxx . . $ clipper/Array2d#`operator()`(2ad352fa902d6713).1,0), mat(cxx . . $ clipper/Array2d#`operator()`(2ad352fa902d6713).2,0));
811 clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# e1cxx . . $ clipper/Coord_orth#Coord_orth(3374d1a184fcc02e).(mat(cxx . . $ clipper/Array2d#`operator()`(2ad352fa902d6713).0,1), mat(cxx . . $ clipper/Array2d#`operator()`(2ad352fa902d6713).1,1), mat(cxx . . $ clipper/Array2d#`operator()`(2ad352fa902d6713).2,1));
812 clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# e2cxx . . $ clipper/Coord_orth#Coord_orth(3374d1a184fcc02e).(mat(cxx . . $ clipper/Array2d#`operator()`(2ad352fa902d6713).0,2), mat(cxx . . $ clipper/Array2d#`operator()`(2ad352fa902d6713).1,2), mat(cxx . . $ clipper/Array2d#`operator()`(2ad352fa902d6713).2,2));
813 // clipper::Coord_orth e0(mat(0,0), mat(0,1), mat(0,2));
814 // clipper::Coord_orth e1(mat(1,0), mat(1,1), mat(1,2));
815 // clipper::Coord_orth e2(mat(2,0), mat(2,1), mat(2,2));
816 e0 =cxx . . $ clipper/Coord_orth#`operator=`(c3f604fd3327b93d). sqrtcxx . . $ sqrt(fee4f1d22bc8e617).(eigens[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0]/float(sum_weights)) *cxx . . $ clipper/`operator*`(25eee10b02de6d36). e0;
817 e1 =cxx . . $ clipper/Coord_orth#`operator=`(c3f604fd3327b93d). sqrtcxx . . $ sqrt(fee4f1d22bc8e617).(eigens[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1]/float(sum_weights)) *cxx . . $ clipper/`operator*`(25eee10b02de6d36). e1;
818 e2 =cxx . . $ clipper/Coord_orth#`operator=`(c3f604fd3327b93d). sqrtcxx . . $ sqrt(fee4f1d22bc8e617).(eigens[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).2]/float(sum_weights)) *cxx . . $ clipper/`operator*`(25eee10b02de6d36). e2;
819
820 clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# tip_0_1(mean_pos +cxx . . $ clipper/operator+(44ad1d8741e04b17). e0);
821 clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# tip_0_2(mean_pos -cxx . . $ clipper/operator-(44ad1d8741e04b17). e0);
822 clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# tip_1_1(mean_pos +cxx . . $ clipper/operator+(44ad1d8741e04b17). e1);
823 clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# tip_1_2(mean_pos -cxx . . $ clipper/operator-(44ad1d8741e04b17). e1);
824 clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# tip_2_1(mean_pos +cxx . . $ clipper/operator+(44ad1d8741e04b17). e2);
825 clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# tip_2_2(mean_pos -cxx . . $ clipper/operator-(44ad1d8741e04b17). e2);
826
827
828 // std::cout << "(set-rotation-centre "
829 // << mean_pos.x() << " "
830 // << mean_pos.y() << " "
831 // << mean_pos.z() << ") ; mean-pos" << std::endl;
832 // std::cout << "(set-rotation-centre "
833 // << tip_0_1.x() << " "
834 // << tip_0_1.y() << " "
835 // << tip_0_1.z() << ") ; tip x1" << std::endl;
836 // std::cout << "(set-rotation-centre "
837 // << tip_0_2.x() << " "
838 // << tip_0_2.y() << " "
839 // << tip_0_2.z() << ") ; tip x2" << std::endl;
840 // std::cout << "(set-rotation-centre "
841 // << tip_1_1.x() << " "
842 // << tip_1_1.y() << " "
843 // << tip_1_1.z() << ") ; tip y1" << std::endl;
844 // std::cout << "(set-rotation-centre "
845 // << tip_1_2.x() << " "
846 // << tip_1_2.y() << " "
847 // << tip_1_2.z() << ") ; tip y2" << std::endl;
848 // std::cout << "(set-rotation-centre "
849 // << tip_2_1.x() << " "
850 // << tip_2_1.y() << " "
851 // << tip_2_1.z() << ") ; tip z1" << std::endl;
852 // std::cout << "(set-rotation-centre "
853 // << tip_2_2.x() << " "
854 // << tip_2_2.y() << " "
855 // << tip_2_2.z() << ") ; tip z2" << std::endl;
856
857 clippercxx . . $ clipper/::Mat33cxx . . $ clipper/Mat33#<double> mat33cxx . . $ clipper/Mat33#Mat33(49f6e7a06ebc5aa8).;
858 for (int j=0; j<3; j++)
859 for (int i=0; i<3; i++)
860 mat33(cxx . . $ clipper/Mat33#`operator()`(2ad352fa902d6713).i,j) = mat(cxx . . $ clipper/Array2d#`operator()`(2ad352fa902d6713).i,j);
861
862 clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth# rtopcxx . . $ clipper/RTop_orth#RTop_orth(cd0dec0763f9cd6f).(mat33, mean_pos);
863 return cootcxx . . $ coot/eigen_info_t#eigen_info_t(ec3ffd7e4c509f84).::eigen_info_tcxx . . $ coot/eigen_info_t#(rtop, best_eigen_index, eigens);
864 }
865
866
867 cootcxx . . $ coot/::helix_placement_info_tcxx . . $ coot/helix_placement_info_t#
868 cootcxx . . $ coot/::helix_placementcxx . . $ coot/helix_placement#::get_20_residue_helix_standard_orientationcxx . . $ coot/helix_placement#get_20_residue_helix_standard_orientation(6c960eda6f397b1).(int nresidues,
869 float b_factor) const {
870
871 cootcxx . . $ coot/::helix_placement_info_tcxx . . $ coot/helix_placement_info_t# m = get_20_residue_helixcxx . . $ coot/helix_placement#get_20_residue_helix(ec885671b9e62f07).(nresidues);
872 if (m.molcxx . . $ coot/helix_placement_info_t#mol.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0].fragmentscxx . . $ coot/minimol/molecule#fragments..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).() > 0) {
873 // std::cout << "DEBUG:: residue fragment residue range "
874 // << m.mol[0][0].min_res_no() << " to "
875 // << m.mol[0][0].max_residue_number()
876 // << " requested: " << nresidues << std::endl;
877
878 // We need to orient this arbitarily positioned fragment up the
879 // z axis: So let's create 20 master points either side of the
880 // origin along the z axis and use these as a reference frame to
881 // rotate the CAs of the m molecule.
882 //
883 // We will then apply the transformation to all atoms in the m
884 // (well, the 0th fragment of m).
885 //
886 stdcxx . . $ std/::vectorcxx . . $ std/vector#<clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth#> z_axis_markerscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
887 stdcxx . . $ std/::vectorcxx . . $ std/vector#<clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth#> frag_positionscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
888 int nres = nresidues;
889 for (int i=0; i<nres; i++) {
890 cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::atomcxx . . $ coot/minimol/atom# a = m.molcxx . . $ coot/helix_placement_info_t#mol.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0][cxx . . $ coot/minimol/molecule#`operator[]`(1062c7b8e0909df1).0][cxx . . $ coot/minimol/fragment#`operator[]`(52b91a6aa7c0bd12).i+1][cxx . . $ coot/minimol/residue#`operator[]`(46a5038e90255fa3)." CA "cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).];
891 if (a.namecxx . . $ coot/minimol/atom#name. != "FAIL") {
892 double z_pos = (double(i) - double((nres+1)/2.0))*1.5;
893 clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# pacxx . . $ clipper/Coord_orth#Coord_orth(3374d1a184fcc02e).(0, 0, z_pos);
894 z_axis_markers.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(pa);
895 frag_positions.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(a.poscxx . . $ coot/minimol/atom#pos.);
896 }
897 }
898 // Note that we get garbage nans for our rtop when we put the
899 // z_axis_markers down the x_axis (strangely enough). So we put
900 // the markers down the x axis and then multiply by:
901 // ( 0 0 1)
902 // ( 0 1 0)
903 // (-1 0 0)
904 // No, we don't
905 //
906 clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth# rtopcxx . . $ clipper/RTop_orth#RTop_orth(2316f45164e461d4).(frag_positions, z_axis_markers);
907 // clipper::Mat33<double> y_axis_rotation(0, 0, -1, 0, 1, 0, 1, 0, 0);
908 // clipper::RTop_orth y_axis_op(y_axis_rotation, clipper::Coord_orth(0,0,0));
909
910 // we don't need (use) the x_axis_rotation
911 // clipper::Mat33<double> x_axis_rotation(1, 0, 0, 0, 0, -1, 0, 1, 0);
912 // clipper::RTop_orth x_axis_op(x_axis_rotation, clipper::Coord_orth(0,0,0));
913
914 stdcxx . . $ std/::vectorcxx . . $ std/vector#<cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::atomcxx . . $ coot/minimol/atom# *> av = m.molcxx . . $ coot/helix_placement_info_t#mol.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0].select_atoms_serialcxx . . $ coot/minimol/molecule#select_atoms_serial(b76adc939ab46a91).();
915 for (unsigned int iat=0; iat<av.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); iat++) {
916 av[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iat]->poscxx . . $ coot/minimol/atom#pos. =cxx . . $ clipper/Coord_orth#`operator=`(c3f604fd3327b93d). av[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iat]->poscxx . . $ coot/minimol/atom#pos..transformcxx . . $ clipper/Coord_orth#transform(82925a12407e9823).(rtop);
917 av[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iat]->temperature_factorcxx . . $ coot/minimol/atom#temperature_factor. = b_factor;
918 }
919 }
920 return m;
921 }
922
923
924 // Return molecule with no fragments on error reading file. Try
925 // thowing an error, perhaps.
926 //
927 cootcxx . . $ coot/::helix_placement_info_tcxx . . $ coot/helix_placement_info_t#
928 cootcxx . . $ coot/::helix_placementcxx . . $ coot/helix_placement#::get_20_residue_helixcxx . . $ coot/helix_placement#get_20_residue_helix(ec885671b9e62f07).(int n_residues) const {
929
930 stdcxx . . $ std/::stringcxx . . $ std/string# helix_filename = "theor-helix-70.pdb"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).;
931 stdcxx . . $ std/::stringcxx . . $ std/string# pkgdatadir = cootcxx . . $ coot/::package_data_dircxx . . $ coot/package_data_dir(efd28698952f529a).();
932 stdcxx . . $ std/::stringcxx . . $ std/string# full_path_helix_filename = pkgdatadircxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5).;
933 full_path_helix_filename +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). "/";
934 full_path_helix_filename +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). helix_filename;
935
936 cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::moleculecxx . . $ coot/minimol/molecule# mcxx . . $ coot/minimol/molecule#molecule(49f6e7a06ebc5aa8).;
937 short int success = 0;
938 stdcxx . . $ std/::stringcxx . . $ std/string# failurecxx . . $ std/__cxx11/basic_string#basic_string(925dcc5e17f50391).;
939
940 struct stat buf;
941 int status = stat(full_path_helix_filename.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(), &buf);
942 if (status == 0) {
943 m.read_filecxx . . $ coot/minimol/molecule#read_file(89800cbf2a9b278f).(full_path_helix_filenamecxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5).);
944 if (m.fragmentscxx . . $ coot/minimol/molecule#fragments..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).() > 0) {
945 cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::fragmentcxx . . $ coot/minimol/fragment# fcxx . . $ coot/minimol/fragment#fragment(49f6e7a06ebc5aa8).;
946 // fill f with the first 20 residues of m;
947 if (m[cxx . . $ coot/minimol/molecule#`operator[]`(1062c7b8e0909df1).0].max_residue_numbercxx . . $ coot/minimol/fragment#max_residue_number(455f465bc33b4cdf).() > n_residues) {
948 for (int ires=1; ires<=n_residues; ires++) {
949 try {
950 f.addresiduecxx . . $ coot/minimol/fragment#addresidue(429d90603f4ee4f0).(m[cxx . . $ coot/minimol/molecule#`operator[]`(1062c7b8e0909df1).0][cxx . . $ coot/minimol/fragment#`operator[]`(52b91a6aa7c0bd12).ires], 0);
951 }
952 catch (const stdcxx . . $ std/::runtime_errorcxx . . $ std/runtime_error# &rte) {
953 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "ERROR:: get_20_residue_helix() " <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). rte.whatcxx . . $ std/runtime_error#what(ba32b354807b2b81).() <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
954 }
955 }
956 m[cxx . . $ coot/minimol/molecule#`operator[]`(1062c7b8e0909df1).0] =cxx . . $ coot/minimol/fragment#`operator=`(c5d5369fc5dfe44c). f;
957 success = 1;
958 }
959 }
960 } else {
961 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Error finding library theoretical helix pdb." <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
962 failure =cxx . . $ std/__cxx11/basic_string#`operator=`(978ca1133b5f6e74). "Error finding library theoretical helix pdb.";
963 success = 0;
964 }
965 return cootcxx . . $ coot/helix_placement_info_t#helix_placement_info_t(d7525711b08e4f59).::helix_placement_info_tcxx . . $ coot/helix_placement_info_t#(m, success, failure);
966 }
967
968 cootcxx . . $ coot/::utilcxx . . $ coot/util/::density_stats_info_tcxx . . $ coot/util/density_stats_info_t#
969 cootcxx . . $ coot/::helix_placementcxx . . $ coot/helix_placement#::score_atomscxx . . $ coot/helix_placement#score_atoms(9b6e4287d8edf03a).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth#> &atom_pos) const {
970
971 cootcxx . . $ coot/::utilcxx . . $ coot/util/::density_stats_info_tcxx . . $ coot/util/density_stats_info_t# dsicxx . . $ coot/util/density_stats_info_t#density_stats_info_t(49f6e7a06ebc5aa8).;
972 float score;
973 for (unsigned int i=0; i<atom_pos.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); i++) {
974 score = cootcxx . . $ coot/::utilcxx . . $ coot/util/::density_at_pointcxx . . $ coot/util/density_at_point(eaf42b0c64814e59).(xmapcxx . . $ coot/helix_placement#xmap., atom_pos[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).i]);
975 dsi.addcxx . . $ coot/util/density_stats_info_t#add(f371dfa6ad81844c).(score);
976 }
977 return dsi;
978 }
979
980 float
981 cootcxx . . $ coot/::helix_placementcxx . . $ coot/helix_placement#::score_helix_positioncxx . . $ coot/helix_placement#score_helix_position(a0b84a170f8981cf).(const cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::moleculecxx . . $ coot/minimol/molecule# &m) const {
982
983 float score = 0.0;
984 for (unsigned int ifrag=0; ifrag<m.fragmentscxx . . $ coot/minimol/molecule#fragments..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); ifrag++) {
985 for (int ires=m[cxx . . $ coot/minimol/molecule#`operator[]`(bb2a098e83fae33e).ifrag].min_res_nocxx . . $ coot/minimol/fragment#min_res_no(455f465bc33b4cdf).(); ires<m[cxx . . $ coot/minimol/molecule#`operator[]`(bb2a098e83fae33e).ifrag].max_residue_numbercxx . . $ coot/minimol/fragment#max_residue_number(455f465bc33b4cdf).();
986 ires++) {
987 for (unsigned int iat=0; iat<m[cxx . . $ coot/minimol/molecule#`operator[]`(bb2a098e83fae33e).ifrag][cxx . . $ coot/minimol/fragment#`operator[]`(5d923071f4ccdb85).ires].atomscxx . . $ coot/minimol/residue#atoms..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); iat++) {
988 score += cootcxx . . $ coot/::utilcxx . . $ coot/util/::density_at_pointcxx . . $ coot/util/density_at_point(eaf42b0c64814e59).(xmapcxx . . $ coot/helix_placement#xmap., m[cxx . . $ coot/minimol/molecule#`operator[]`(bb2a098e83fae33e).ifrag][cxx . . $ coot/minimol/fragment#`operator[]`(5d923071f4ccdb85).ires][cxx . . $ coot/minimol/residue#`operator[]`(ec2953c9e8887011).iat].poscxx . . $ coot/minimol/atom#pos.) *
989 m[cxx . . $ coot/minimol/molecule#`operator[]`(bb2a098e83fae33e).ifrag][cxx . . $ coot/minimol/fragment#`operator[]`(5d923071f4ccdb85).ires][cxx . . $ coot/minimol/residue#`operator[]`(ec2953c9e8887011).iat].occupancycxx . . $ coot/minimol/atom#occupancy.;
990 }
991 }
992 }
993 return score;
994 }
995
996 cootcxx . . $ coot/::utilcxx . . $ coot/util/::density_stats_info_tcxx . . $ coot/util/density_stats_info_t#
997 cootcxx . . $ coot/::helix_placementcxx . . $ coot/helix_placement#::score_residuecxx . . $ coot/helix_placement#score_residue(b5a505dc0dda3861).(const cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::residuecxx . . $ coot/minimol/residue# &residue) const {
998
999 cootcxx . . $ coot/::utilcxx . . $ coot/util/::density_stats_info_tcxx . . $ coot/util/density_stats_info_t# dsicxx . . $ coot/util/density_stats_info_t#density_stats_info_t(49f6e7a06ebc5aa8).;
1000 float score;
1001 for (unsigned int i=0; i<residue.atomscxx . . $ coot/minimol/residue#atoms..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); i++) {
1002 score = cootcxx . . $ coot/::utilcxx . . $ coot/util/::density_at_pointcxx . . $ coot/util/density_at_point(eaf42b0c64814e59).(xmapcxx . . $ coot/helix_placement#xmap., residue.atomscxx . . $ coot/minimol/residue#atoms.[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).i].poscxx . . $ coot/minimol/atom#pos.);
1003 dsi.addcxx . . $ coot/util/density_stats_info_t#add(f371dfa6ad81844c).(score);
1004 }
1005 return dsi;
1006 }
1007
1008 // pair(other atoms, c-betas)
1009 stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth#>, stdcxx . . $ std/::vectorcxx . . $ std/vector#<clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth#> >
1010 cootcxx . . $ coot/::helix_placementcxx . . $ coot/helix_placement#::decompose_helix_by_cbetacxx . . $ coot/helix_placement#decompose_helix_by_cbeta(efc016816866d094).(cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::moleculecxx . . $ coot/minimol/molecule# &m) const {
1011
1012 stdcxx . . $ std/::vectorcxx . . $ std/vector#<clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth#> other_atomscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
1013 stdcxx . . $ std/::vectorcxx . . $ std/vector#<clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth#> c_betascxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
1014 for (unsigned int ifrag=0; ifrag<m.fragmentscxx . . $ coot/minimol/molecule#fragments..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); ifrag++) {
1015 for (int ires=m[cxx . . $ coot/minimol/molecule#`operator[]`(1062c7b8e0909df1).ifrag].min_res_nocxx . . $ coot/minimol/fragment#min_res_no(455f465bc33b4cdf).(); ires<m[cxx . . $ coot/minimol/molecule#`operator[]`(1062c7b8e0909df1).ifrag].max_residue_numbercxx . . $ coot/minimol/fragment#max_residue_number(455f465bc33b4cdf).();
1016 ires++) {
1017 for (unsigned int iat=0; iat<m[cxx . . $ coot/minimol/molecule#`operator[]`(1062c7b8e0909df1).ifrag][cxx . . $ coot/minimol/fragment#`operator[]`(52b91a6aa7c0bd12).ires].atomscxx . . $ coot/minimol/residue#atoms..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); iat++) {
1018 if (m[cxx . . $ coot/minimol/molecule#`operator[]`(1062c7b8e0909df1).ifrag][cxx . . $ coot/minimol/fragment#`operator[]`(52b91a6aa7c0bd12).ires][cxx . . $ coot/minimol/residue#`operator[]`(c939a95b009dec1d).iat].namecxx . . $ coot/minimol/atom#name. ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). " CB ") {
1019 c_betas.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(m[cxx . . $ coot/minimol/molecule#`operator[]`(1062c7b8e0909df1).ifrag][cxx . . $ coot/minimol/fragment#`operator[]`(52b91a6aa7c0bd12).ires][cxx . . $ coot/minimol/residue#`operator[]`(c939a95b009dec1d).iat].poscxx . . $ coot/minimol/atom#pos.);
1020 } else {
1021 other_atoms.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(m[cxx . . $ coot/minimol/molecule#`operator[]`(1062c7b8e0909df1).ifrag][cxx . . $ coot/minimol/fragment#`operator[]`(52b91a6aa7c0bd12).ires][cxx . . $ coot/minimol/residue#`operator[]`(c939a95b009dec1d).iat].poscxx . . $ coot/minimol/atom#pos.);
1022 }
1023 }
1024 }
1025 }
1026 return stdcxx . . $ std/pair#pair(62e1774a2dc03c82).::paircxx . . $ std/pair#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth#>, stdcxx . . $ std/::vectorcxx . . $ std/vector#<clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth#> > (other_atoms, c_betas);
1027 }
1028
1029
1030 void
1031 cootcxx . . $ coot/::helix_placementcxx . . $ coot/helix_placement#::discrimination_mapcxx . . $ coot/helix_placement#discrimination_map(83f5f38750778ac8).() const {
1032
1033 clippercxx . . $ clipper/::Xmap_basecxx . . $ clipper/Xmap_base#::Map_reference_indexcxx . . $ clipper/Xmap_base#Map_reference_index# ixcxx . . $ clipper/Xmap_base#Map_reference_index#Map_reference_index(49f6e7a06ebc5aa8).;
1034 clippercxx . . $ clipper/::Xmapcxx . . $ clipper/Xmap#<float> dmapcxx . . $ clipper/Xmap#Xmap(49f6e7a06ebc5aa8).;
1035 dmap.initcxx . . $ clipper/Xmap#init(432bf4c76b0ccf19).(xmapcxx . . $ coot/helix_placement#xmap..spacegroupcxx . . $ clipper/Xmap_base#spacegroup(f2c81a655761ef05).(),
1036 xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).(),
1037 xmapcxx . . $ coot/helix_placement#xmap..grid_samplingcxx . . $ clipper/Xmap_base#grid_sampling(6a52163cca7b365a).());
1038 for (ix =cxx . . $ clipper/Xmap_base#Map_reference_index#`operator=`(abc61d662845fcd6). xmapcxx . . $ coot/helix_placement#xmap..firstcxx . . $ clipper/Xmap_base#first(fe3368967941ca12).(); !ix.lastcxx . . $ clipper/Xmap_base#Map_reference_base#last(50ce9a9e25b4a850).(); ix.nextcxx . . $ clipper/Xmap_base#Map_reference_index#next(d36de1debba4a19d).() ) { // iterator index.
1039 cootcxx . . $ coot/::eigen_info_tcxx . . $ coot/eigen_info_t# e = helix_eigen_systemcxx . . $ coot/helix_placement#helix_eigen_system(bf62a47acffef0f4).(ix.coord_orthcxx . . $ clipper/Xmap_base#Map_reference_index#coord_orth(da49533f68bc3540).(), 10.0);
1040 double eigen_descrimination_factor = e.eigen_valuescxx . . $ coot/eigen_info_t#eigen_values.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).e.best_eigen_value_indexcxx . . $ coot/eigen_info_t#best_eigen_value_index.] * e.eigen_valuescxx . . $ coot/eigen_info_t#eigen_values.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).e.best_eigen_value_indexcxx . . $ coot/eigen_info_t#best_eigen_value_index.] * e.eigen_valuescxx . . $ coot/eigen_info_t#eigen_values.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).e.best_eigen_value_indexcxx . . $ coot/eigen_info_t#best_eigen_value_index.]/(e.eigen_valuescxx . . $ coot/eigen_info_t#eigen_values.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0] * e.eigen_valuescxx . . $ coot/eigen_info_t#eigen_values.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1] * e.eigen_valuescxx . . $ coot/eigen_info_t#eigen_values.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).2]);
1041 dmap[cxx . . $ clipper/Xmap#`operator[]`(97597ad7e4732c9d).ix] = eigen_descrimination_factor;
1042 }
1043
1044 stdcxx . . $ std/::stringcxx . . $ std/string# filenamecxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).("descrimination.map");
1045 clippercxx . . $ clipper/::CCP4MAPfilecxx . . $ clipper/CCP4MAPfile# mapoutcxx . . $ clipper/CCP4MAPfile#CCP4MAPfile(49f6e7a06ebc5aa8).;
1046 mapout.open_writecxx . . $ clipper/CCP4MAPfile#open_write(b4f7366dea7cb22b).(filenamecxx . . $ clipper/String#String(8d4ab0a187bf9331).);
1047 mapout.export_xmapcxx . . $ clipper/CCP4MAPfile#export_xmap(797e83e4b7064356).(dmap);
1048 mapout.close_writecxx . . $ clipper/CCP4MAPfile#close_write(49f6e7a06ebc5aa8).();
1049 }
1050
1051
1052 // modify f,
1053 // return n trim flag, c trim flag
1054 //
1055 stdcxx . . $ std/::paircxx . . $ std/pair#<int, int>
1056 cootcxx . . $ coot/::helix_placementcxx . . $ coot/helix_placement#::trim_endscxx . . $ coot/helix_placement#trim_ends(6312286c277ca48).(cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::fragmentcxx . . $ coot/minimol/fragment# *f, float min_density_limit) const {
1057
1058 // For each end of m, from the end residue (1 or 20) check if the residue is in
1059 // positive density (well, above a particular level). If it is, return,
1060 // If it isn't, chop off the residue and repeat test for test residue.
1061
1062 int ntrim = trim_endcxx . . $ coot/helix_placement#trim_end(2f1f4a0c385f8268).(f, 0, min_density_limit); // Nterm;
1063 int ctrim = trim_endcxx . . $ coot/helix_placement#trim_end(2f1f4a0c385f8268).(f, 1, min_density_limit); // Nterm;
1064 return stdcxx . . $ std/pair#pair(62e1774a2dc03c82).::paircxx . . $ std/pair#<int, int> (ntrim, ctrim);
1065 }
1066
1067 // return if we did a chop or not
1068 int
1069 cootcxx . . $ coot/::helix_placementcxx . . $ coot/helix_placement#::trim_endcxx . . $ coot/helix_placement#trim_end(2f1f4a0c385f8268).(cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::fragmentcxx . . $ coot/minimol/fragment# *f, short int end_type, float min_density_limit) const {
1070
1071 int ichop = 0;
1072 int dir_sign = 1;
1073 int start_resno = f->min_res_nocxx . . $ coot/minimol/fragment#min_res_no(455f465bc33b4cdf).();
1074 int last_resno = f->max_residue_numbercxx . . $ coot/minimol/fragment#max_residue_number(455f465bc33b4cdf).();
1075 if (end_type == 1) {
1076 dir_sign = -1;
1077 start_resno = f->max_residue_numbercxx . . $ coot/minimol/fragment#max_residue_number(455f465bc33b4cdf).();
1078 last_resno = f->min_res_nocxx . . $ coot/minimol/fragment#min_res_no(455f465bc33b4cdf).();
1079 }
1080
1081 for (int ires=start_resno; ires!=last_resno; ires+=dir_sign) {
1082 cootcxx . . $ coot/::utilcxx . . $ coot/util/::density_stats_info_tcxx . . $ coot/util/density_stats_info_t# dsi = score_residuecxx . . $ coot/helix_placement#score_residue(b5a505dc0dda3861).((*f)[cxx . . $ coot/minimol/fragment#`operator[]`(52b91a6aa7c0bd12).ires]);
1083 stdcxx . . $ std/::paircxx . . $ std/pair#<float, float> mv = dsicxx . . $ std/pair#pair(dab76e35023fdb54)..mean_and_variancecxx . . $ coot/util/density_stats_info_t#mean_and_variance(1376e5766acc2ef2).();
1084 if (dsi.ncxx . . $ coot/util/density_stats_info_t#n. > 0.5) { // this residue has atoms...
1085 if (mv.firstcxx . . $ std/pair#first. > min_density_limit) {
1086 break;
1087 } else {
1088 // chop out this residue;
1089 (*f)[cxx . . $ coot/minimol/fragment#`operator[]`(52b91a6aa7c0bd12).ires].atomscxx . . $ coot/minimol/residue#atoms..resizecxx . . $ std/vector#resize(2c44cd906ae4e829).(0);
1090 ichop = 1;
1091 }
1092 }
1093 }
1094 return ichop;
1095 }
1096
1097
1098 void
1099 cootcxx . . $ coot/::helix_placementcxx . . $ coot/helix_placement#::build_on_N_endcxx . . $ coot/helix_placement#build_on_N_end(4d563378ef3fb4e5).(cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::fragmentcxx . . $ coot/minimol/fragment# *f,
1100 float min_density_limit,
1101 float b_factor) const {
1102
1103 // We only come here if we actually mean to do some building. The
1104 // test for whether the end was trimmed must be performed in the
1105 // calling function.
1106
1107 int ires_current_last = f->min_res_nocxx . . $ coot/minimol/fragment#min_res_no(455f465bc33b4cdf).();
1108 cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::residuecxx . . $ coot/minimol/residue# current_last = (*f)[cxx . . $ coot/minimol/fragment#`operator[]`(52b91a6aa7c0bd12).ires_current_last];
1109
1110 bool found_CA = 0;
1111 bool found_N = 0;
1112 bool found_C = 0;
1113 clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# cacxx . . $ clipper/Coord_orth#Coord_orth(49f6e7a06ebc5aa8).;
1114 clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# ncxx . . $ clipper/Coord_orth#Coord_orth(49f6e7a06ebc5aa8).;
1115 clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# ccxx . . $ clipper/Coord_orth#Coord_orth(49f6e7a06ebc5aa8).;
1116
1117 // std::cout << "Trying to build in N terminal residue " << ires_current_last-1
1118 // << std::endl;
1119
1120 for (unsigned int iat=0; iat<current_last.atomscxx . . $ coot/minimol/residue#atoms..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); iat++) {
1121 if (current_last[cxx . . $ coot/minimol/residue#`operator[]`(c939a95b009dec1d).iat].namecxx . . $ coot/minimol/atom#name. ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). " CA ") {
1122 found_CA = 1;
1123 ca =cxx . . $ clipper/Coord_orth#`operator=`(78e738cfe0eb964f). current_last[cxx . . $ coot/minimol/residue#`operator[]`(c939a95b009dec1d).iat].poscxx . . $ coot/minimol/atom#pos.;
1124 }
1125 if (current_last[cxx . . $ coot/minimol/residue#`operator[]`(c939a95b009dec1d).iat].namecxx . . $ coot/minimol/atom#name. ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). " C ") {
1126 found_C = 1;
1127 c =cxx . . $ clipper/Coord_orth#`operator=`(78e738cfe0eb964f). current_last[cxx . . $ coot/minimol/residue#`operator[]`(c939a95b009dec1d).iat].poscxx . . $ coot/minimol/atom#pos.;
1128 }
1129 if (current_last[cxx . . $ coot/minimol/residue#`operator[]`(c939a95b009dec1d).iat].namecxx . . $ coot/minimol/atom#name. ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). " N ") {
1130 found_N = 1;
1131 n =cxx . . $ clipper/Coord_orth#`operator=`(78e738cfe0eb964f). current_last[cxx . . $ coot/minimol/residue#`operator[]`(c939a95b009dec1d).iat].poscxx . . $ coot/minimol/atom#pos.;
1132 }
1133 }
1134 if (found_CA && found_C && found_N) {
1135 cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::residuecxx . . $ coot/minimol/residue# r = build_N_terminal_ALAcxx . . $ coot/helix_placement#build_N_terminal_ALA(48cef1a107f65814).(n, ca, c, ires_current_last-1, b_factor);
1136 // if that residue is in positive density then add it to f and try to add another res
1137 cootcxx . . $ coot/::utilcxx . . $ coot/util/::density_stats_info_tcxx . . $ coot/util/density_stats_info_t# dsi = score_residuecxx . . $ coot/helix_placement#score_residue(b5a505dc0dda3861).(r);
1138 stdcxx . . $ std/::paircxx . . $ std/pair#<float, float> mv = dsicxx . . $ std/pair#pair(dab76e35023fdb54)..mean_and_variancecxx . . $ coot/util/density_stats_info_t#mean_and_variance(1376e5766acc2ef2).();
1139 if (mv.firstcxx . . $ std/pair#first. > min_density_limit) {
1140 // Add on the C-Beta and add the residue to the fragment
1141 stdcxx . . $ std/::paircxx . . $ std/pair#<short int, clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth#> cbeta_info = cootcxx . . $ std/pair#pair(dab76e35023fdb54).::cbeta_positioncxx . . $ coot/cbeta_position(f2851a2830cd9c18).(r);
1142 if (cbeta_info.firstcxx . . $ std/pair#first.)
1143 r.addatomcxx . . $ coot/minimol/residue#addatom(243545f9ac9bffa4).(" CB "cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., " C"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., cbeta_info.secondcxx . . $ std/pair#second., ""cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., 1.0, 30.0);
1144 try {
1145 f->addresiduecxx . . $ coot/minimol/fragment#addresidue(429d90603f4ee4f0).(r, 0);
1146 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "INFO build of N terminal residue " <<cxx . . $ std/basic_ostream#`operator<<`(23b6575433a77e57). ires_current_last-1
1147 <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " success" <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
1148 build_on_N_endcxx . . $ coot/helix_placement#build_on_N_end(4d563378ef3fb4e5).(f, min_density_limit, b_factor);
1149 }
1150 catch (const stdcxx . . $ std/::runtime_errorcxx . . $ std/runtime_error# &rte) {
1151 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "ERROR:: build_on_N_end() " <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). rte.whatcxx . . $ std/runtime_error#what(ba32b354807b2b81).() <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
1152 }
1153 } else {
1154 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "INFO build of N terminal residue " <<cxx . . $ std/basic_ostream#`operator<<`(23b6575433a77e57). ires_current_last-1
1155 <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " failed (bad density fit)" <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
1156 }
1157 } else {
1158 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Not all needed mainchain atoms found in prev. res" <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
1159 }
1160 }
1161
1162 void
1163 cootcxx . . $ coot/::helix_placementcxx . . $ coot/helix_placement#::build_on_C_endcxx . . $ coot/helix_placement#build_on_C_end(4d563378ef3fb4e5).(cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::fragmentcxx . . $ coot/minimol/fragment# *f,
1164 float min_density_limit,
1165 float b_factor) const {
1166
1167 // We only come here if we actually mean to do some building. The
1168 // test for whether the end was trimmed must be performed in the
1169 // calling function.
1170
1171 int ires_current_last = f->max_residue_numbercxx . . $ coot/minimol/fragment#max_residue_number(455f465bc33b4cdf).();
1172 cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::residuecxx . . $ coot/minimol/residue# current_last = (*f)[cxx . . $ coot/minimol/fragment#`operator[]`(52b91a6aa7c0bd12).ires_current_last];
1173
1174 // std::cout << "Trying to build in C terminal residue " << ires_current_last-1
1175 // << std::endl;
1176
1177 bool found_CA = 0;
1178 bool found_N = 0;
1179 bool found_C = 0;
1180 clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# cacxx . . $ clipper/Coord_orth#Coord_orth(49f6e7a06ebc5aa8).;
1181 clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# ncxx . . $ clipper/Coord_orth#Coord_orth(49f6e7a06ebc5aa8).;
1182 clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# ccxx . . $ clipper/Coord_orth#Coord_orth(49f6e7a06ebc5aa8).;
1183
1184 for (unsigned int iat=0; iat<current_last.atomscxx . . $ coot/minimol/residue#atoms..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); iat++) {
1185 if (current_last[cxx . . $ coot/minimol/residue#`operator[]`(c939a95b009dec1d).iat].namecxx . . $ coot/minimol/atom#name. ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). " CA ") {
1186 found_CA = 1;
1187 ca =cxx . . $ clipper/Coord_orth#`operator=`(78e738cfe0eb964f). current_last[cxx . . $ coot/minimol/residue#`operator[]`(c939a95b009dec1d).iat].poscxx . . $ coot/minimol/atom#pos.;
1188 }
1189 if (current_last[cxx . . $ coot/minimol/residue#`operator[]`(c939a95b009dec1d).iat].namecxx . . $ coot/minimol/atom#name. ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). " C ") {
1190 found_C = 1;
1191 c =cxx . . $ clipper/Coord_orth#`operator=`(78e738cfe0eb964f). current_last[cxx . . $ coot/minimol/residue#`operator[]`(c939a95b009dec1d).iat].poscxx . . $ coot/minimol/atom#pos.;
1192 }
1193 if (current_last[cxx . . $ coot/minimol/residue#`operator[]`(c939a95b009dec1d).iat].namecxx . . $ coot/minimol/atom#name. ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). " N ") {
1194 found_N = 1;
1195 n =cxx . . $ clipper/Coord_orth#`operator=`(78e738cfe0eb964f). current_last[cxx . . $ coot/minimol/residue#`operator[]`(c939a95b009dec1d).iat].poscxx . . $ coot/minimol/atom#pos.;
1196 }
1197 }
1198 if (found_CA && found_C && found_N) {
1199 cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::residuecxx . . $ coot/minimol/residue# r = build_C_terminal_ALAcxx . . $ coot/helix_placement#build_C_terminal_ALA(48cef1a107f65814).(n, ca, c, ires_current_last+1, b_factor);
1200 // if that residue is in positive density then add it to f and try to add another res
1201 cootcxx . . $ coot/::utilcxx . . $ coot/util/::density_stats_info_tcxx . . $ coot/util/density_stats_info_t# dsi = score_residuecxx . . $ coot/helix_placement#score_residue(b5a505dc0dda3861).(r);
1202 stdcxx . . $ std/::paircxx . . $ std/pair#<float, float> mv = dsicxx . . $ std/pair#pair(dab76e35023fdb54)..mean_and_variancecxx . . $ coot/util/density_stats_info_t#mean_and_variance(1376e5766acc2ef2).();
1203 if (mv.firstcxx . . $ std/pair#first. > min_density_limit) {
1204 // Add on the C-Beta and add the residue to the fragment
1205 stdcxx . . $ std/::paircxx . . $ std/pair#<short int, clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth#> cbeta_info = cootcxx . . $ std/pair#pair(dab76e35023fdb54).::cbeta_positioncxx . . $ coot/cbeta_position(f2851a2830cd9c18).(r);
1206 if (cbeta_info.firstcxx . . $ std/pair#first.)
1207 r.addatomcxx . . $ coot/minimol/residue#addatom(243545f9ac9bffa4).(" CB "cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., " C"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., cbeta_info.secondcxx . . $ std/pair#second., ""cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., 1.0, 30.0);
1208 try {
1209 f->addresiduecxx . . $ coot/minimol/fragment#addresidue(429d90603f4ee4f0).(r, 0);
1210 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "INFO build of N terminal residue " <<cxx . . $ std/basic_ostream#`operator<<`(23b6575433a77e57). ires_current_last-1
1211 <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " success" <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
1212 build_on_C_endcxx . . $ coot/helix_placement#build_on_C_end(4d563378ef3fb4e5).(f, min_density_limit, b_factor);
1213 }
1214 catch (const stdcxx . . $ std/::runtime_errorcxx . . $ std/runtime_error# &rte) {
1215 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "ERROR:: build_on_C_end() " <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). rte.whatcxx . . $ std/runtime_error#what(ba32b354807b2b81).() <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
1216 }
1217 } else {
1218 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "INFO build of C terminal residue " <<cxx . . $ std/basic_ostream#`operator<<`(23b6575433a77e57). ires_current_last-1
1219 <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " failed (bad density fit)" <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
1220 }
1221 } else {
1222 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Not all needed mainchain atoms found in prev. res" <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
1223 }
1224 }
1225
1226 cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::residuecxx . . $ coot/minimol/residue#
1227 cootcxx . . $ coot/::helix_placementcxx . . $ coot/helix_placement#::build_N_terminal_ALAcxx . . $ coot/helix_placement#build_N_terminal_ALA(48cef1a107f65814).(const clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# &prev_n,
1228 const clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# &prev_ca,
1229 const clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# &prev_c,
1230 int seqno,
1231 float b_factor) const {
1232
1233 // theortical helix CA-N bond: -57.82 phi
1234 // CA-C bond: -47 psi
1235 float phi = -57.82;
1236 float psi = -47.0;
1237 cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::residuecxx . . $ coot/minimol/residue# r = cootcxx . . $ coot/::build_N_terminal_ALAcxx . . $ coot/build_N_terminal_ALA(ac1ebc5d491c6559).(phi, psi, seqno, prev_n, prev_ca, prev_c,
1238 b_factor);
1239
1240 return r;
1241 }
1242
1243 cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::residuecxx . . $ coot/minimol/residue#
1244 cootcxx . . $ coot/::helix_placementcxx . . $ coot/helix_placement#::build_C_terminal_ALAcxx . . $ coot/helix_placement#build_C_terminal_ALA(48cef1a107f65814).(const clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# &prev_n,
1245 const clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# &prev_ca,
1246 const clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# &prev_c,
1247 int seqno,
1248 float b_factor) const {
1249
1250 // theortical helix CA-N bond: -57.82 phi
1251 // CA-C bond: -47 psi
1252 float phi = -57.82;
1253 float psi = -47.0;
1254 cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::residuecxx . . $ coot/minimol/residue# r = cootcxx . . $ coot/::build_C_terminal_ALAcxx . . $ coot/build_C_terminal_ALA(ac1ebc5d491c6559).(phi, psi, seqno, prev_n, prev_ca, prev_c,
1255 b_factor);
1256
1257 return r;
1258 }
1259
1260
1261 // Tinker with m
1262 void
1263 cootcxx . . $ coot/::helix_placementcxx . . $ coot/helix_placement#::trim_and_growcxx . . $ coot/helix_placement#trim_and_grow(b7af30d83b4d586e).(minimolcxx . . $ coot/minimol/::moleculecxx . . $ coot/minimol/molecule# *m, float min_density_limit,
1264 float b_factor) const {
1265
1266 for (unsigned int ifrag=0; ifrag<m->fragmentscxx . . $ coot/minimol/molecule#fragments..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); ifrag++) {
1267 stdcxx . . $ std/::paircxx . . $ std/pair#<int, int> trim_pair = trim_endscxx . . $ coot/helix_placement#trim_ends(6312286c277ca48).(&(*m)[cxx . . $ coot/minimol/molecule#`operator[]`(1062c7b8e0909df1).ifrag], min_density_limit);
1268 if (trim_pair.firstcxx . . $ std/pair#first. == 0) {
1269 build_on_N_endcxx . . $ coot/helix_placement#build_on_N_end(4d563378ef3fb4e5).(&(*m)[cxx . . $ coot/minimol/molecule#`operator[]`(1062c7b8e0909df1).ifrag], min_density_limit, b_factor);
1270 } else {
1271 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "N terminal of placed helix was trimmed" <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
1272 }
1273 if (trim_pair.secondcxx . . $ std/pair#second. == 0) {
1274 build_on_C_endcxx . . $ coot/helix_placement#build_on_C_end(4d563378ef3fb4e5).(&(*m)[cxx . . $ coot/minimol/molecule#`operator[]`(1062c7b8e0909df1).ifrag], min_density_limit, b_factor);
1275 } else {
1276 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "C terminal of placed helix was trimmed" <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
1277 }
1278 }
1279 }
1280
1281
1282 cootcxx . . $ coot/::helix_placement_info_tcxx . . $ coot/helix_placement_info_t#
1283 cootcxx . . $ coot/::helix_placementcxx . . $ coot/helix_placement#::place_strandcxx . . $ coot/helix_placement#place_strand(c04162e362f218fb).(const clippercxx . . $ clipper/::Coord_orthcxx . . $ clipper/Coord_orth# &pt, int strand_length,
1284 int n_strand_samples, float sigma_level) {
1285
1286 bool debug = false;
1287 float map_rmsd = sigma_level / 3; // hack (used in rigid body fitting shift scaling).
1288 cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::moleculecxx . . $ coot/minimol/molecule# rmcxx . . $ coot/minimol/molecule#molecule(49f6e7a06ebc5aa8).;
1289 cootcxx . . $ coot/::helix_placement_info_tcxx . . $ coot/helix_placement_info_t# rcxx . . $ coot/helix_placement_info_t#helix_placement_info_t(d7525711b08e4f59).(rm, 0, "Not Done"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).);
1290
1291 // What is the orientation of the strand? Let's define a tube and search it
1292 //
1293 double cyl_len = 10.0;
1294 double cyl_rad = 1.0;
1295
1296 float dd = 2.5 * sigma_level;
1297 clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth# best_op = find_best_tube_orientationcxx . . $ coot/helix_placement#find_best_tube_orientation(60e92e1d6131eae1).(pt, cyl_len, cyl_rad, dd);
1298
1299 clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth# op_plus_transcxx . . $ clipper/RTop_orth#RTop_orth(cd0dec0763f9cd6f).(best_op.rotcxx . . $ clipper/RTop#rot(9cda91039451a538).(), pt);
1300
1301 if (debug) {
1302 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "DEBUG:: best_op for strand orientation:\n" <<cxx . . $ std/`operator<<`(88df5bef833f7f83). best_op.formatcxx . . $ clipper/RTop#format(9c83e4702554ac51).() <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
1303 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "DEBUG:: best_op with translation :\n" <<cxx . . $ std/`operator<<`(88df5bef833f7f83). op_plus_trans.formatcxx . . $ clipper/RTop#format(9c83e4702554ac51).() <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
1304 }
1305
1306 // get some strands of that length
1307 //
1308 cootcxx . . $ coot/::db_strandscxx . . $ coot/db_strands# dbscxx . . $ coot/db_strands#db_strands(49f6e7a06ebc5aa8).;
1309 stdcxx . . $ std/::vectorcxx . . $ std/vector#<cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::moleculecxx . . $ coot/minimol/molecule#> strands =
1310 dbs.get_reference_strandscxx . . $ coot/db_strands#get_reference_strands(eb0ddd05f638af80).(n_strand_samples, strand_length);
1311
1312 // for each strand, fit as rigid body, both directions and return the score.
1313 float best_score = -999.0;
1314 cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::moleculecxx . . $ coot/minimol/molecule# best_molcxx . . $ coot/minimol/molecule#molecule(49f6e7a06ebc5aa8).;
1315 for (unsigned int imol=0; imol<strands.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); imol++) {
1316 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Scoring fragment " <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). imol+1 <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " of " <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). strands.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).() <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
1317 cootcxx . . $ coot/::scored_helix_info_tcxx . . $ coot/scored_helix_info_t# info = fit_strandcxx . . $ coot/helix_placement#fit_strand(4ffaeb59d5fbf002).(strands[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).imol], op_plus_trans, imol, map_rmsd);
1318 if (info.scorecxx . . $ coot/scored_helix_info_t#score. > best_score) {
1319 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " better score: " <<cxx . . $ std/basic_ostream#`operator<<`(2b73cd0f0517cf77). info.scorecxx . . $ coot/scored_helix_info_t#score. <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
1320 best_score = info.scorecxx . . $ coot/scored_helix_info_t#score.;
1321 best_mol =cxx . . $ coot/minimol/molecule#`operator=`(8e2fab78f4df6d66). info.molcxx . . $ coot/scored_helix_info_t#mol.;
1322 }
1323 }
1324 if (best_score > 0.0) {
1325 r.molcxx . . $ coot/helix_placement_info_t#mol.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0] =cxx . . $ coot/minimol/molecule#`operator=`(8e2fab78f4df6d66). best_mol;
1326 r.successcxx . . $ coot/helix_placement_info_t#success. = 1;
1327 r.failure_messagecxx . . $ coot/helix_placement_info_t#failure_message. =cxx . . $ std/__cxx11/basic_string#`operator=`(978ca1133b5f6e74). "success";
1328 // copy over the cell and symmetry:
1329 float acell[6];
1330 acell[0] = xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).().descrcxx . . $ clipper/Cell#descr(60e29b0f4054320c).().acxx . . $ clipper/Cell_descr#a(cb83ef2068996cec).();
1331 acell[1] = xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).().descrcxx . . $ clipper/Cell#descr(60e29b0f4054320c).().bcxx . . $ clipper/Cell_descr#b(cb83ef2068996cec).();
1332 acell[2] = xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).().descrcxx . . $ clipper/Cell#descr(60e29b0f4054320c).().ccxx . . $ clipper/Cell_descr#c(cb83ef2068996cec).();
1333 acell[3] = clippercxx . . $ clipper/::Utilcxx . . $ clipper/Util#::rad2dcxx . . $ clipper/Util#rad2d(569b37c916856981).(xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).().descrcxx . . $ clipper/Cell#descr(60e29b0f4054320c).().alphacxx . . $ clipper/Cell_descr#alpha(cb83ef2068996cec).());
1334 acell[4] = clippercxx . . $ clipper/::Utilcxx . . $ clipper/Util#::rad2dcxx . . $ clipper/Util#rad2d(569b37c916856981).(xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).().descrcxx . . $ clipper/Cell#descr(60e29b0f4054320c).().betacxx . . $ clipper/Cell_descr#beta(cb83ef2068996cec).());
1335 acell[5] = clippercxx . . $ clipper/::Utilcxx . . $ clipper/Util#::rad2dcxx . . $ clipper/Util#rad2d(569b37c916856981).(xmapcxx . . $ coot/helix_placement#xmap..cellcxx . . $ clipper/Xmap_base#cell(43f43fac4da8b803).().descrcxx . . $ clipper/Cell#descr(60e29b0f4054320c).().gammacxx . . $ clipper/Cell_descr#gamma(cb83ef2068996cec).());
1336 r.molcxx . . $ coot/helix_placement_info_t#mol.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0].set_cellcxx . . $ coot/minimol/molecule#set_cell(e6881f009d13a851).(acell);
1337 r.molcxx . . $ coot/helix_placement_info_t#mol.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0].set_spacegroupcxx . . $ coot/minimol/molecule#set_spacegroup(9c546c94e5fcce4e).(xmapcxx . . $ coot/helix_placement#xmap..spacegroupcxx . . $ clipper/Xmap_base#spacegroup(f2c81a655761ef05).().symbol_hmcxx . . $ clipper/Spgr_descr#symbol_hm(9c83e4702554ac51).());
1338 }
1339 return r;
1340 }
1341
1342 // imol is passed just for writting out score info.
1343 //
1344 cootcxx . . $ coot/::scored_helix_info_tcxx . . $ coot/scored_helix_info_t#
1345 cootcxx . . $ coot/::helix_placementcxx . . $ coot/helix_placement#::fit_strandcxx . . $ coot/helix_placement#fit_strand(4ffaeb59d5fbf002).(const cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::moleculecxx . . $ coot/minimol/molecule# &mol,
1346 const clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth# &rtop,
1347 int imol,
1348 float map_rmsd) const {
1349
1350 cootcxx . . $ coot/::scored_helix_info_tcxx . . $ coot/scored_helix_info_t# sircxx . . $ coot/scored_helix_info_t#scored_helix_info_t(49f6e7a06ebc5aa8).;
1351 float best_score = -9999.9;
1352
1353 stdcxx . . $ std/::vectorcxx . . $ std/vector#<cootcxx . . $ coot/::scored_helix_info_tcxx . . $ coot/scored_helix_info_t#> v =
1354 find_strand_candidates_by_shift_samplingcxx . . $ coot/helix_placement#find_strand_candidates_by_shift_sampling(3c27bd0e13c81a63).(mol, rtop);
1355 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Fitting " <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). v.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " shifted frag candidates from "
1356 <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " candidate fragment number " <<cxx . . $ std/basic_ostream#`operator<<`(23b6575433a77e57). imol+1 <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
1357
1358 for (unsigned int iv=0; iv<v.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); iv++) {
1359 if (v[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iv].scorecxx . . $ coot/scored_helix_info_t#score. < best_score*0.6) {
1360 // std::cout << "Reject - too far " << v[iv].score << " but refined to "
1361 // << score << std::endl;
1362 } else {
1363 cootcxx . . $ coot/::rigid_body_fitcxx . . $ coot/rigid_body_fit(387b8788d6e9adea).(&v[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iv].molcxx . . $ coot/scored_helix_info_t#mol., xmapcxx . . $ coot/helix_placement#xmap., map_rmsd);
1364 float score = score_helix_positioncxx . . $ coot/helix_placement#score_helix_position(a0b84a170f8981cf).(v[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iv].molcxx . . $ coot/scored_helix_info_t#mol.);
1365 if (score > best_score) {
1366 best_score = score;
1367 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Got a better fit in fragment number " <<cxx . . $ std/basic_ostream#`operator<<`(23b6575433a77e57). imol+1
1368 <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " from " <<cxx . . $ std/basic_ostream#`operator<<`(2b73cd0f0517cf77). v[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iv].scorecxx . . $ coot/scored_helix_info_t#score.
1369 <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " to " <<cxx . . $ std/basic_ostream#`operator<<`(2b73cd0f0517cf77). score <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
1370 sir =cxx . . $ coot/scored_helix_info_t#`operator=`(7eee9baafe7e09d6). v[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iv];
1371 sir.scorecxx . . $ coot/scored_helix_info_t#score. = score;
1372 }
1373 }
1374 }
1375 return sir;
1376 }
1377
1378 stdcxx . . $ std/::vectorcxx . . $ std/vector#<cootcxx . . $ coot/::scored_helix_info_tcxx . . $ coot/scored_helix_info_t#>
1379 cootcxx . . $ coot/::helix_placementcxx . . $ coot/helix_placement#::find_strand_candidates_by_shift_samplingcxx . . $ coot/helix_placement#find_strand_candidates_by_shift_sampling(3c27bd0e13c81a63).(const cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::moleculecxx . . $ coot/minimol/molecule# &mol,
1380 const clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth# &rtop) const {
1381
1382 // OK hold on to your hats here!
1383
1384 // Return a vector of the "best-fitting" strands before we do rigid
1385 // body refinement. i.e. there's no need to do rigid body
1386 // refinement on all strands, just the best-fitting ones. So here
1387 // we return the best-fitting ones. And in the calling function of
1388 // this routine, we do the rigid-body fitting of each strand and
1389 // return the best one. Return all strands that have a score of
1390 // more than half the top score.
1391
1392 float top_cut = 0.5; // above this gets through
1393 top_cut = 0.8;
1394
1395 // rtop transform object near the origin (oriented along z) to
1396 // match the orientation and position of the place of interest.
1397 // That transformation happens last. We will move things around
1398 // the origin first.
1399 //
1400 // We need to do some searching of the density, so we need
1401 //
1402 // 1) A forward/backwards transformation (flip)
1403 // 2) a rotation search around the strand (z) axis
1404 // 3) a translation search along the strand axis
1405
1406 float z_shift_step_size = 0.35; // the step size along the strand
1407 // axis, to get the zig-zag in the
1408 // right place.
1409
1410 stdcxx . . $ std/::vectorcxx . . $ std/vector#<cootcxx . . $ coot/::scored_helix_info_tcxx . . $ coot/scored_helix_info_t#> scored_strand_vector_workingcxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
1411 stdcxx . . $ std/::vectorcxx . . $ std/vector#<cootcxx . . $ coot/::scored_helix_info_tcxx . . $ coot/scored_helix_info_t#> scored_strand_vector_returnedcxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
1412
1413 cootcxx . . $ coot/::scored_helix_info_tcxx . . $ coot/scored_helix_info_t# scored_strandcxx . . $ coot/scored_helix_info_t#scored_helix_info_t(49f6e7a06ebc5aa8).;
1414 cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::moleculecxx . . $ coot/minimol/molecule# mc = mol;
1415
1416 // flip up/down (reverse direction search)
1417 stdcxx . . $ std/::vectorcxx . . $ std/vector#<clippercxx . . $ clipper/::Mat33cxx . . $ clipper/Mat33#<double> > flip_rotated_matricescxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
1418 flip_rotated_matrices.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(clippercxx . . $ clipper/Mat33#Mat33(ca294aebd03ed32e).::Mat33cxx . . $ clipper/Mat33#<double>(1,0,0,0,1,0,0,0,1));
1419 flip_rotated_matrices.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(clippercxx . . $ clipper/Mat33#Mat33(ca294aebd03ed32e).::Mat33cxx . . $ clipper/Mat33#<double>(-1, 0, 0, 0, 1, 0, 0, 0, -1));
1420 for (unsigned int iflip=0; iflip<flip_rotated_matrices.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); iflip++) {
1421 // if (iflip == 0) {
1422 // std::cout << " testing forward direction..." << std::endl;
1423 // } else {
1424 // std::cout << " testing reverse direction..." << std::endl;
1425 // }
1426
1427 cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::moleculecxx . . $ coot/minimol/molecule# flip = mc;
1428 clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth# flip_rtopcxx . . $ clipper/RTop_orth#RTop_orth(cd0dec0763f9cd6f).(flip_rotated_matrices[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).iflip],
1429 clippercxx . . $ clipper/Coord_orth#Coord_orth(3374d1a184fcc02e).::Coord_orthcxx . . $ clipper/Coord_orth#(0,0,0));
1430 flip.transformcxx . . $ coot/minimol/molecule#transform(e19fd923a135bced).(flip_rtop);
1431
1432 for (float theta=0; theta<2*M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`!; theta += 0.3) {
1433
1434 double sin_t = sincxx . . $ sin(fbcf3211dfe1bfd1).(theta);
1435 double cos_t = coscxx . . $ cos(fbcf3211dfe1bfd1).(theta);
1436 clippercxx . . $ clipper/::Mat33cxx . . $ clipper/Mat33#<double> theta_matcxx . . $ clipper/Mat33#Mat33(ca294aebd03ed32e).(cos_t,-sin_t,0, sin_t,cos_t,0, 0,0,1);
1437 clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth# theta_rtopcxx . . $ clipper/RTop_orth#RTop_orth(cd0dec0763f9cd6f).(theta_mat, clippercxx . . $ clipper/Coord_orth#Coord_orth(3374d1a184fcc02e).::Coord_orthcxx . . $ clipper/Coord_orth#(0,0,0));
1438 cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::moleculecxx . . $ coot/minimol/molecule# theta_mol = flip;
1439 theta_mol.transformcxx . . $ coot/minimol/molecule#transform(e19fd923a135bced).(theta_rtop);
1440
1441 for (float z_shift= -2.0; z_shift<2.0; z_shift+=z_shift_step_size) {
1442 clippercxx . . $ clipper/::RTop_orthcxx . . $ clipper/RTop_orth# z_shift_rtopcxx . . $ clipper/RTop_orth#RTop_orth(cd0dec0763f9cd6f).(clippercxx . . $ clipper/Mat33#Mat33(ca294aebd03ed32e).::Mat33cxx . . $ clipper/Mat33#<double>(1,0,0,0,1,0,0,0,1),
1443 clippercxx . . $ clipper/Coord_orth#Coord_orth(3374d1a184fcc02e).::Coord_orthcxx . . $ clipper/Coord_orth#(0, 0, z_shift));
1444 cootcxx . . $ coot/::minimolcxx . . $ coot/minimol/::moleculecxx . . $ coot/minimol/molecule# z_shift_mol = theta_mol;
1445 z_shift_mol.transformcxx . . $ coot/minimol/molecule#transform(e19fd923a135bced).(z_shift_rtop);
1446
1447 // Now the transformation we first thought of...
1448 z_shift_mol.transformcxx . . $ coot/minimol/molecule#transform(e19fd923a135bced).(rtop);
1449 float score = score_helix_positioncxx . . $ coot/helix_placement#score_helix_position(a0b84a170f8981cf).(z_shift_mol);
1450
1451 // debug
1452 if (0) {
1453 stdcxx . . $ std/::stringcxx . . $ std/string# filename = "f-"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).;
1454 filename +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). "flip:";
1455 filename +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). cootcxx . . $ coot/::utilcxx . . $ coot/util/::int_to_stringcxx . . $ coot/util/int_to_string(7eb93f795f0defb3).(iflip);
1456 filename +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). "-theta:";
1457 filename +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). cootcxx . . $ coot/::utilcxx . . $ coot/util/::float_to_stringcxx . . $ coot/util/float_to_string(14a4da2464e078e0).(theta);
1458 filename +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). "-shift:";
1459 filename +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). cootcxx . . $ coot/::utilcxx . . $ coot/util/::float_to_stringcxx . . $ coot/util/float_to_string(14a4da2464e078e0).(z_shift);
1460 filename +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). ".pdb";
1461 z_shift_mol.write_filecxx . . $ coot/minimol/molecule#write_file(d292696f89fe1693).(filenamecxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5)., 30.0);
1462 }
1463
1464 scored_strand.scorecxx . . $ coot/scored_helix_info_t#score. = score;
1465 scored_strand.molcxx . . $ coot/scored_helix_info_t#mol. =cxx . . $ coot/minimol/molecule#`operator=`(8e2fab78f4df6d66). z_shift_mol;
1466 scored_strand_vector_working.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(scored_strand);
1467
1468 }
1469 }
1470 }
1471
1472 // now we have lots of vectors in scored_strand_vector_working. Sort them.
1473 stdcxx . . $ std/::sortcxx . . $ std/sort(4d3091562df4e52e).(scored_strand_vector_working.begincxx . . $ std/vector#begin(55a6de06420d4903).(),
1474 scored_strand_vector_working.endcxx . . $ std/vector#end(55a6de06420d4903).(),
1475 compare_scored_strandscxx . . $ coot/compare_scored_strands(3e275b95b61d3837).);
1476
1477 float top_score = 0.0;
1478 for (unsigned int i=0; i<scored_strand_vector_working.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); i++) {
1479 // std::cout << " " << i << " " << scored_strand_vector_working[i].score << std::endl;
1480 if (scored_strand_vector_working[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i].scorecxx . . $ coot/scored_helix_info_t#score. > top_score) {
1481 top_score = scored_strand_vector_working[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i].scorecxx . . $ coot/scored_helix_info_t#score.;
1482 }
1483 }
1484
1485 if (top_score > 0.0) {
1486 for (unsigned int i=0; i<scored_strand_vector_working.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); i++) {
1487 if (scored_strand_vector_working[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i].scorecxx . . $ coot/scored_helix_info_t#score. > top_score*top_cut) {
1488 scored_strand_vector_returned.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(scored_strand_vector_working[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i]);
1489 }
1490 }
1491 }
1492
1493 return scored_strand_vector_returnedcxx . . $ std/vector#vector(6f559d22b039ccdb).;
1494 }
1495
1496
1497 bool
1498 cootcxx . . $ coot/::compare_scored_strandscxx . . $ coot/compare_scored_strands(3e275b95b61d3837).(const scored_helix_info_tcxx . . $ coot/scored_helix_info_t# &a,
1499 const scored_helix_info_tcxx . . $ coot/scored_helix_info_t# &b) {
1500 return (a.scorecxx . . $ coot/scored_helix_info_t#score. > b.scorecxx . . $ coot/scored_helix_info_t#score.);
1501 }