17 #include <basic/options/option.hh>
29 #include <numeric/xyz.functions.hh>
30 #include <numeric/statistics.functions.hh>
40 #include <basic/options/keys/edensity.OptionKeys.gen.hh>
44 #include <basic/Tracer.hh>
47 #include <utility/vector1.hh>
54 #define _USE_MATH_DEFINES
61 namespace electron_density {
81 using namespace core::scoring::methods;
83 static basic::Tracer
TR(
"core.scoring.electron_density.ElecDensEnergy");
94 TR.Debug <<
"Map loaded? " << (
map_loaded ?
"yes" :
"no") << std::endl;
139 utility_exit_with_message(
"Density scoring function called but no map loaded.");
144 int virt_res_idx = root_edge.
start();
148 if (root_res.type().name() !=
"VRT" || root_edge.label() < 0) {
149 utility_exit_with_message(
"Fold tree is not set properly for density scoring!");
156 bool create_new_lre_container(
false );
158 if ( energies.long_range_container( lr_type ) == 0 ) {
159 create_new_lre_container =
true;
164 if ( dec->size() != pose.
total_residue() || dec->fixed() != virt_res_idx ) {
165 create_new_lre_container =
true;
169 if ( create_new_lre_container ) {
170 TR <<
"Creating new LRE container (" << pose.
total_residue() <<
")" << std::endl;
172 energies.set_long_range_container( lr_type, new_dec );
191 TR.Debug <<
"ElecDensCenEnergy::setup_for_scoring() returns CC = " <<
structure_score << std::endl;
231 using namespace numeric::statistics;
238 Real z_CC = cc / 0.1;
239 Real p_null = 0.5 * errfc( z_CC/sqrt(2.0) );
240 Real edensScore = log ( p_null );
257 using namespace numeric::statistics;
263 int resid =
id.rsd();
264 int atmid =
id.atomno();
283 core::Size nres_per = symminfo->num_independent_residues();
284 bool remapSymm = basic::options::option[ basic::options::OptionKeys::edensity::score_symm_complex ]();
289 if (atmid != 2)
return;
293 int nchildren = edges_i.size();
294 if (nchildren < 2)
return;
300 if (! symminfo->jump_is_independent( edge_incoming.
label() ) )
310 for (
int j=1; j<=nchildren; ++j) {
311 int basejump = edges_i[j].label();
312 if (! symminfo->jump_is_independent( basejump ) )
313 basejump = symminfo->jump_follows( basejump );
315 for (
int k=0; k<=(
int)jumpclones.size(); ++k) {
318 if (edges_j.size() > 1 && std::find( vrtclones.begin(), vrtclones.end(), upstream ) == vrtclones.end() ) {
319 vrtclones.push_back( upstream );
325 for (
int i=1; i<=(
int)vrtclones.size(); ++i) {
329 for (
int j=1; j<=nchildren; ++j) {
330 int downstream = edges_i[j].stop();
335 for (
int k=1; k<=(
int)nsubunits; ++k) {
336 if (mapping_j[k] == 0)
continue;
339 for (
int l=1, l_end=nres_per; l<=l_end; ++l) {
341 int source_res = (k-1)*nres_per+l;
342 int target_res = (mapping_j[k]-1)*nres_per+l;
351 Real z_CC = CC / 0.1;
352 Real p_null = 0.5 * errfc( z_CC/sqrt(2.0) );
355 exp(-
SQ( z_CC/sqrt(2.0) )) *
362 Vector const f1( atom_x.cross( atom_y ) );
374 for (
int k=1; k<=(
int)nsubunits; ++k) {
375 if (mapping_i[k] == 0)
continue;
378 for (
int l=1, l_end=nres_per; l<=l_end; ++l) {
380 int source_res = (k-1)*nres_per+l;
381 int target_res = (mapping_i[k]-1)*nres_per+l;
390 Real z_CC = CC / 0.1;
391 Real p_null = 0.5 * errfc( z_CC/sqrt(2.0) );
394 exp(-
SQ( z_CC/sqrt(2.0) )) *
401 Vector const f1( atom_x.cross( atom_y ) );
409 if (! symminfo->bb_is_independent( resid ) )
return;
412 for (
int i=0; i<=(
int)myClones.size(); ++i) {
421 Real z_CC = CC / 0.1;
422 Real p_null = 0.5 * errfc( z_CC/sqrt(2.0) );
427 exp(-
SQ( z_CC/sqrt(2.0) )) *
434 Vector const f1( atom_x.cross( atom_y ) );
447 Real z_CC = CC / 0.1;
448 Real p_null = 0.5 * errfc( z_CC/sqrt(2.0) );
456 exp(-
SQ( z_CC/sqrt(2.0) )) *
464 Vector const f1( atom_x.cross( atom_y ) );