15 #include <numeric/constants.hh>
26 #include <numeric/xyz.functions.hh>
27 #include <numeric/xyzMatrix.hh>
28 #include <numeric/conversions.hh>
29 #include <utility/io/ozstream.hh>
32 #include <basic/options/option.hh>
33 #include <basic/options/keys/OptionKeys.hh>
34 #include <basic/options/keys/fingerprint.OptionKeys.gen.hh>
35 #include <basic/database/open.hh>
46 #include <utility/vector1.hh>
49 #include <numeric/random/random.fwd.hh>
52 using namespace core::scoring;
59 FingerprintBase::FingerprintBase () :
71 utility::io::ozstream out_stream;
72 out_stream.open(output_filename, std::ios::out);
73 out_stream<<
"/ORI/"<<std::fixed<<std::setprecision(2)<<
origin_.x() <<
"\t" <<std::fixed<<std::setprecision(2)<<
origin_.y() <<
"\t"<<std::fixed<<std::setprecision(3)<<
origin_.z() <<std::endl;
74 out_stream<<
"/COM/"<<std::fixed<<std::setprecision(2)<<
CoM_.x() <<
"\t" <<std::fixed<<std::setprecision(2)<<
CoM_.y() <<
"\t"<<std::fixed<<std::setprecision(3)<<
CoM_.z() <<std::endl;
76 out_stream<<std::fixed<<std::setprecision(2)<< fi->phi <<
"\t" <<std::fixed<<std::setprecision(2)<<fi->psi <<
"\t"<<std::fixed<<std::setprecision(3)<< fi->rho <<std::endl;
91 utility::io::ozstream out_stream;
92 out_stream.open(output_pdbname, std::ios::out);
94 out_stream<<
"HETATM "<<std::setw(2)<<1<<
" C ORI X 0 "<<std::setw(8)<<std::fixed<<std::setprecision(3)<<
origin_.x()+translation.x()<<std::setw(8)<<std::fixed<<std::setprecision(3)<<
origin_.y()+translation.y()<<std::setw(8)<<std::fixed<<std::setprecision(3)<<
origin_.z()+translation.z()<<std::endl;
95 out_stream<<
"HETATM "<<std::setw(2)<<1<<
" C COM X 0 "<<std::setw(8)<<std::fixed<<std::setprecision(3)<<
CoM_.x()+translation.x()<<std::setw(8)<<std::fixed<<std::setprecision(3)<<
CoM_.y()+translation.y()<<std::setw(8)<<std::fixed<<std::setprecision(3)<<
CoM_.z()+translation.z()<<std::endl;
100 out_stream<<
"HETATM "<<std::setw(2)<<1<<
" C MAP A 1 "<<std::setw(8)<<std::fixed<<std::setprecision(3)<<new_coor.x()+translation.x()<<std::setw(8)<<std::fixed<<std::setprecision(3)<<new_coor.y()+translation.y()<<std::setw(8)<<std::fixed<<std::setprecision(3)<<new_coor.z()+translation.z()<<std::endl;
148 utility::io::ozstream outPDB_stream;
149 outPDB_stream.open(output_eggshell_name, std::ios::out);
150 outPDB_stream<<
"HETATM "<<std::setw(2)<<1<<
" C ORI A 1 "<<std::setw(8)<<std::fixed<<std::setprecision(3)<<
origin_.x()<<std::setw(8)<<std::fixed<<std::setprecision(3)<<
origin_.y()<<std::setw(8)<<std::fixed<<std::setprecision(3)<<
origin_.z()<<std::endl;
151 outPDB_stream<<
"HETATM "<<std::setw(2)<<1<<
" C COM A 1 "<<std::setw(8)<<std::fixed<<std::setprecision(3)<<
CoM_.x()<<std::setw(8)<<std::fixed<<std::setprecision(3)<<
CoM_.y()<<std::setw(8)<<std::fixed<<std::setprecision(3)<<
CoM_.z()<<std::endl;
153 outPDB_stream<<
"HETATM "<<std::setw(2)<<1<<
" C EGG A 1 "<<std::setw(8)<<std::fixed<<std::setprecision(3)<<pd->x()<<std::setw(8)<<std::fixed<<std::setprecision(3)<<pd->y()<<std::setw(8)<<std::fixed<<std::setprecision(3)<<pd->z()<<std::endl;
156 outPDB_stream<<
"HETATM "<<std::setw(2)<<1<<
" O EXT B 1 "<<std::setw(8)<<std::fixed<<std::setprecision(3)<<pd->x()<<std::setw(8)<<std::fixed<<std::setprecision(3)<<pd->y()<<std::setw(8)<<std::fixed<<std::setprecision(3)<<pd->z()<<std::endl;
158 outPDB_stream.close();
159 outPDB_stream.clear();
164 using namespace basic::options;
165 int origin_option = option[ OptionKeys::fingerprint::set_origin ];
166 Size best_origin_option(0);
167 if (origin_option == 0){
170 for(
Size set_origin_option = 1; set_origin_option < 4; ++set_origin_option){
173 if ( new_R < best_R ) {
175 best_origin_option = set_origin_option;
180 best_origin_option = origin_option;
199 if ( pt1 == pt2 )
continue;
200 core::Real const curr_angle = std::abs(cos_of( *pt1, *pt2 ));
201 if(curr_angle < min_angle){
202 min_angle = curr_angle;
207 min_rho_difference += std::abs( triplet1.
rho - triplet2.
rho );
210 return min_rho_difference / num_points;
215 if (set_origin_option == 1){
218 }
else if (set_origin_option == 2){
221 }
else if (set_origin_option == 3){
224 }
else if (set_origin_option == 4){
228 std::cout<<
"Error, wrong option for set_origin" << std::endl;
240 Size num_int_points = 0;
244 num_int_points=num_int_points+1;
247 Size num_ext_points = 0;
250 new_triplet.
rho = 0.;
252 num_ext_points=num_ext_points+1;
256 gpu_num_rays_ = num_int_points + num_ext_points;
319 weights[0] = missing_point_weight;
320 weights[1] = steric_weight;
321 weights[2] = extra_point_weight;
322 weights[3] = num_particles;
324 gpu_weights_ = gpu_.AllocateMemory(
sizeof(*weights) * 4);
326 gpu_.WriteData(gpu_weights_, weights,
sizeof(*weights) * 4);
330 if(!gpu_ray_scores_) {
332 gpu_ray_scores_ = gpu_.AllocateMemory(
sizeof(*ray_scores_) *
RAY_SCORE_ARRAY);
335 if(!gpu_particle_scores_) {
337 gpu_particle_scores_ = gpu_.AllocateMemory(
sizeof(*particle_scores_) *
NUMBER_OF_PARTICLES);
340 std::string fn = basic::database::full_name(
"gpu/DARC_PSO.cl");
341 if(!gpu_.RegisterProgram(fn.c_str())) {
342 std::cout <<
"Failed to load CL kernel." << std::endl;
347 gpu_num_particles_ = num_particles;
349 cl_kernel kernel1 = gpu_.BuildKernel(
"Check_for_intersection");
350 gpu_.setKernelArg(kernel1, 0,
sizeof(gpu_rays_), &gpu_rays_);
351 gpu_.setKernelArg(kernel1, 1,
sizeof(gpu_atoms_), &gpu_atoms_);
352 gpu_.setKernelArg(kernel1, 2,
sizeof(gpu_ray_scores_), &gpu_ray_scores_);
353 gpu_.setKernelArg(kernel1, 3,
sizeof(gpu_num_atoms_), &gpu_num_atoms_);
354 gpu_.setKernelArg(kernel1, 4,
sizeof(gpu_weights_), &gpu_weights_);
355 gpu_.setKernelArg(kernel1, 5,
sizeof(gpu_num_rays_), &gpu_num_rays_);
357 cl_kernel kernel2 = gpu_.BuildKernel(
"Get_scores");
358 gpu_.setKernelArg(kernel2, 0,
sizeof(gpu_ray_scores_), &gpu_ray_scores_);
359 gpu_.setKernelArg(kernel2, 1,
sizeof(gpu_particle_scores_), &gpu_particle_scores_);
360 gpu_.setKernelArg(kernel2, 2,
sizeof(gpu_num_rays_), &gpu_num_rays_);
361 gpu_.setKernelArg(kernel2, 3,
sizeof(gpu_num_particles_), &gpu_num_particles_);
366 void NonPlaidFingerprint::free_gpu(){
368 if(gpu_rays_) gpu_.Free(gpu_rays_);
369 if(gpu_atoms_) gpu_.Free(gpu_atoms_);
370 if(gpu_ray_scores_) gpu_.Free(gpu_ray_scores_);
371 if(gpu_particle_scores_) gpu_.Free(gpu_particle_scores_);
372 if(gpu_weights_) gpu_.Free(gpu_weights_);
376 void NonPlaidFingerprint::setup_gpu_rays() {
380 std::cout <<
"Too many pocket points" << std::endl;
386 gpu_ray_scores_ = NULL;
387 gpu_particle_scores_ = NULL;
403 gpu_rays_ = gpu_.AllocateMemory(
sizeof(*rays) *
MAX_NUM_RAYS);
406 gpu_.WriteData(gpu_rays_, rays,
sizeof(*rays) * gpu_num_rays_);
415 ifstream inFile(input_filename.c_str());
417 std::cout<<
"Can't open input file " << input_filename << std::endl;
421 std::list< numeric::xyzVector<core::Real> > temp_eggshell_coord_list;
422 std::list< numeric::xyzVector<core::Real> > temp_extra_coord_list;
423 std::list< numeric::xyzVector<core::Real> > egg_and_extra_coord_list;
424 temp_eggshell_coord_list.clear();
425 temp_extra_coord_list.clear();
426 egg_and_extra_coord_list.clear();
437 while (std::getline(inFile, line)) {
438 name = line.substr(0,6);
439 chainID = line.substr(21,1);
440 restype = line.substr(17,3);
445 if (name==
"END")
break;
446 else if ((name==
"HETATM")&&(restype==
"ORI"))
448 Xstring = line.substr(30,8);
449 origin_.x() = atof(Xstring.c_str());
450 Ystring = line.substr(38,8);
451 origin_.y() = atof(Ystring.c_str());
452 Zstring = line.substr(46,8);
453 origin_.z() = atof(Zstring.c_str());
456 else if ((name==
"HETATM")&&(restype==
"COM"))
458 Xstring = line.substr(30,8);
459 CoM_.x() = atof(Xstring.c_str());
460 Ystring = line.substr(38,8);
461 CoM_.y() = atof(Ystring.c_str());
462 Zstring = line.substr(46,8);
463 CoM_.z() = atof(Zstring.c_str());
466 else if ((name==
"HETATM")&&(restype==
"EGG"))
468 Xstring = line.substr(30,8);
469 pdb_coord.x() = atof(Xstring.c_str());
470 Ystring = line.substr(38,8);
471 pdb_coord.y() = atof(Ystring.c_str());
472 Zstring = line.substr(46,8);
473 pdb_coord.z() = atof(Zstring.c_str());
474 temp_eggshell_coord_list.push_back(pdb_coord);
476 else if ((name==
"HETATM")&&(restype==
"EXT"))
478 Xstring = line.substr(30,8);
479 pdb_coord.x() = atof(Xstring.c_str());
480 Ystring = line.substr(38,8);
481 pdb_coord.y() = atof(Ystring.c_str());
482 Zstring = line.substr(46,8);
483 pdb_coord.z() = atof(Zstring.c_str());
484 temp_extra_coord_list.push_back(pdb_coord);
489 if ( (oricounter == 0) || (comcounter == 0) ){
490 std::cout<<
"Error, No ORIGIN or CoM value specified in input Eggshell file" << std::endl;
492 }
else if ( (oricounter > 1) || (comcounter >1) ){
493 std::cout<<
"Error, More than one ORIGIN or CoM value specified in input Eggshell file" << std::endl;
501 for (std::list<
numeric::xyzVector<core::Real> >::const_iterator pd = temp_eggshell_coord_list.begin(); pd != temp_eggshell_coord_list.end(); ++pd) {
508 new_triplet.
rho = 0.;
521 ifstream inFile(input_filename.c_str());
524 std::cout<<
"Can't open input file " << input_filename << std::endl;
539 while (std::getline(inFile, lineread)) {
541 std::stringstream sss(lineread);
542 std::string Pock_string_phi, Pock_string_psi, Pock_string_rho;
543 core::Real Pock_real_phi, Pock_real_psi, Pock_real_rho;
546 if (lineread[0] ==
'/' && lineread[1] ==
'O' && lineread[2] ==
'R' && lineread[3] ==
'I' && lineread[4] ==
'/') {
548 std::stringstream ori_line(lineread);
549 std::getline(ori_line, Pock_string_phi,
'\t');
550 origin_.x() = atof(Pock_string_phi.c_str());
551 std::getline(ori_line, Pock_string_psi,
'\t');
552 origin_.y() = atof(Pock_string_psi.c_str());
553 std::getline(ori_line, Pock_string_rho,
'\t');
554 origin_.z() = atof(Pock_string_rho.c_str());
559 if (lineread[0] ==
'/' && lineread[1] ==
'C' && lineread[2] ==
'O' && lineread[3] ==
'M' && lineread[4] ==
'/') {
561 std::stringstream com_line(lineread);
562 std::getline(com_line, Pock_string_phi,
'\t');
563 CoM_.x() = atof(Pock_string_phi.c_str());
564 std::getline(com_line, Pock_string_psi,
'\t');
565 CoM_.y() = atof(Pock_string_psi.c_str());
566 std::getline(com_line, Pock_string_rho,
'\t');
567 CoM_.z() = atof(Pock_string_rho.c_str());
572 std::getline(sss, Pock_string_phi,
'\t');
573 Pock_real_phi = atof(Pock_string_phi.c_str());
574 std::getline(sss, Pock_string_psi,
'\t');
575 Pock_real_psi = atof(Pock_string_psi.c_str());
576 std::getline(sss, Pock_string_rho,
'\t');
577 Pock_real_rho = atof(Pock_string_rho.c_str());
579 new_triplet.
phi = Pock_real_phi;
580 new_triplet.
psi = Pock_real_psi;
581 new_triplet.
rho = Pock_real_rho;
584 gpu_num_rays_ = gpu_num_rays_ + 1;
599 std::list< spherical_coor_triplet > triplet_trim_data;
607 if ( ( pro->rho > 0.001 ) && ( lig->rho < 0.001 ) )
continue;
608 triplet_trim_data.push_back(*pro);
615 utility::io::ozstream outPDB_stream;
616 outPDB_stream.open(
"trim_eggshell.pdb", std::ios::out);
617 outPDB_stream<<
"HETATM "<<std::setw(2)<<1<<
" C ORI A 1 "<<std::setw(8)<<std::fixed<<std::setprecision(3)<<
origin_.x()<<std::setw(8)<<std::fixed<<std::setprecision(3)<<
origin_.y()<<std::setw(8)<<std::fixed<<std::setprecision(3)<<
origin_.z()<<std::endl;
618 outPDB_stream<<
"HETATM "<<std::setw(2)<<1<<
" C COM B 2 "<<std::setw(8)<<std::fixed<<std::setprecision(3)<<
CoM_.x()<<std::setw(8)<<std::fixed<<std::setprecision(3)<<
CoM_.y()<<std::setw(8)<<std::fixed<<std::setprecision(3)<<
CoM_.z()<<std::endl;
623 outPDB_stream<<
"HETATM "<<std::setw(2)<<1<<
" C EGG C 3 "<<std::setw(8)<<std::fixed<<std::setprecision(3)<<new_coor.x()<<std::setw(8)<<std::fixed<<std::setprecision(3)<<new_coor.y()<<std::setw(8)<<std::fixed<<std::setprecision(3)<<new_coor.z()<<std::endl;
625 outPDB_stream.close();
626 outPDB_stream.clear();
635 core::Real A11(0.), A12(0.), A13(0.), A22(0.), A23(0.), b1(0.), b2(0.), b3(0.);
637 A11 += pd->x()*pd->x();
638 A12 += pd->x()*pd->y();
640 A22 += pd->y()*pd->y();
642 b1 += pd->x()*pd->z();
643 b2 += pd->y()*pd->z();
656 A(3,3)=egg_and_extra_shell.size();
671 std::list< numeric::xyzVector<core::Real> > plane_coord_list;
673 for (std::list<
numeric::xyzVector<core::Real> >::const_iterator pdebug = egg_and_extra_shell.begin(); pdebug != egg_and_extra_shell.end(); ++pdebug) {
674 plane_coord.x() = pdebug->x();
675 plane_coord.y() = pdebug->y();
676 plane_coord.z() = best_fit_a * pdebug->x() + best_fit_b * pdebug->y() + best_fit_c;
677 plane_coord_list.push_back(plane_coord);
686 plane_normal = cross_product( (plane_coord_list.front() - plane_CoM ), (plane_coord_list.back() - plane_CoM ) );
688 plane_normal.normalize(30.);
697 if( protein_CoM.distance(temp_origin1) > protein_CoM.distance(temp_origin2) ) {
698 closest_origin = temp_origin2;
699 distant_origin = temp_origin1;
701 closest_origin = temp_origin1;
702 distant_origin = temp_origin2;
705 if (set_origin_option == 3){
707 }
else if (set_origin_option == 4){
737 temp_vec += (
CoM_ - *pd);
739 temp_vec.normalize(30.);
748 if( protein_CoM.distance(temp_origin1) > protein_CoM.distance(temp_origin2) ) {
749 closest_origin = temp_origin2;
750 distant_origin = temp_origin1;
752 closest_origin = temp_origin1;
753 distant_origin = temp_origin2;
767 temp_vec.normalize(30.);
776 for (
int j = 1, resnum = protein_pose.
total_residue(); j <= resnum; ++j ) {
780 protein_com.x() += curr_rsd.
atom(i).
xyz()(1);
781 protein_com.y() += curr_rsd.
atom(i).
xyz()(2);
782 protein_com.z() += curr_rsd.
atom(i).
xyz()(3);
787 protein_com /= total_atoms;
823 for(
Size i = 1, i_end = ligand_total_atoms; i <= i_end; ++i) {
824 ligand_CoM.x() += curr_rsd.
atom(i).
xyz()(1);
825 ligand_CoM.y() += curr_rsd.
atom(i).
xyz()(2);
826 ligand_CoM.z() += curr_rsd.
atom(i).
xyz()(3);
828 ligand_CoM /= ligand_total_atoms;
849 for (
int j = 1, resnum = pose.
total_residue(); j <= resnum; ++j ) {
855 if (lig_res_num == 0){
856 std::cout<<
"Error, no ligand for PlaidFingerprint" << std::endl;
866 using namespace basic::options;
867 if (option[ OptionKeys::fingerprint::include_hydrogens ]()){
868 ligand_total_atoms = curr_rsd.
natoms();
872 return ligand_total_atoms;
898 using namespace basic::options;
899 core::Real const radius_scale = option[ OptionKeys::fingerprint::atom_radius_scale ];
900 core::Real const atom_buffer = option[ OptionKeys::fingerprint::atom_radius_buffer ];
923 for (
Size i = 1, i_end = ligand_natoms; i <= i_end; ++i) {
926 core::Real const this_atom_radius = ( curr_ligand_rsd->atom_type(i).lj_radius() - atom_buffer ) * radius_scale;
932 core::Real const tmp_atomx=this_atomcoors.x();
933 core::Real const tmp_atomy=this_atomcoors.y();
934 core::Real const tmp_atomz=this_atomcoors.z();
940 if ( std::abs(tmp_atomz) > 0.00001 ) {
941 core::Real const inside_phi_asin = this_atom_radius / tmp_atomz;
942 if ( std::abs(inside_phi_asin) < 1. ) {
943 core::Real const max_angular_displacement_phi = std::abs( asin( inside_phi_asin ) );
944 curr_max_phi = atom_center.
phi + max_angular_displacement_phi;
945 curr_min_phi = atom_center.
phi - max_angular_displacement_phi;
953 if ( ( std::abs(tmp_atomx) > 0.00001 ) || ( std::abs(tmp_atomx) > 0.00001 ) ) {
954 core::Real const inside_psi_asin = this_atom_radius / sqrt( (tmp_atomx*tmp_atomx) + (tmp_atomy*tmp_atomy) );
955 if ( std::abs(inside_psi_asin) < 1. ) {
956 core::Real const max_angular_displacement_psi = std::abs( asin( inside_psi_asin ) );
957 curr_max_psi = atom_center.
psi + max_angular_displacement_psi;
958 curr_min_psi = atom_center.
psi - max_angular_displacement_psi;
962 if ( curr_max_phi > max_phi ) max_phi = curr_max_phi;
963 if ( curr_max_psi > max_psi ) max_psi = curr_max_psi;
964 if ( curr_min_phi < min_phi ) min_phi = curr_min_phi;
965 if ( curr_min_psi < min_psi ) min_psi = curr_min_psi;
966 atom_max_phi.at(i) = curr_max_phi;
967 atom_max_psi.at(i) = curr_max_psi;
968 atom_min_phi.at(i) = curr_min_phi;
969 atom_min_psi.at(i) = curr_min_psi;
970 atomX.at(i) = this_atomcoors.x();
971 atomY.at(i) = this_atomcoors.y();
972 atomZ.at(i) = this_atomcoors.z();
973 atom_radius.at(i) = this_atom_radius;
989 for (
Size i = 1, i_end = ligand_natoms; i <= i_end; ++i) {
991 if ( atom_radius.at(i) < 0.001 )
continue;
993 while ( curr_phi < atom_min_phi.at(i) ) {
994 curr_phi += numeric::constants::r::pi_2;
996 while ( curr_phi > atom_max_phi.at(i) ) {
997 curr_phi -= numeric::constants::r::pi_2;
999 while ( curr_psi < atom_min_psi.at(i) ) {
1000 curr_psi += numeric::constants::r::pi_2;
1002 while ( curr_psi > atom_max_psi.at(i) ) {
1003 curr_psi -= numeric::constants::r::pi_2;
1005 if ( curr_phi < atom_min_phi.at(i) )
continue;
1006 if ( curr_psi < atom_min_psi.at(i) )
continue;
1007 if ( curr_phi > atom_max_phi.at(i) )
continue;
1008 if ( curr_psi > atom_max_psi.at(i) )
continue;
1013 if ( min_intersect_SQ < best_rho_sq ) {
1014 best_rho_sq = min_intersect_SQ;
1015 best_intersecting_atom = i;
1020 new_triplet.
phi = curr_phi;
1021 new_triplet.
psi = curr_psi;
1023 if ( best_rho_sq < 9998. ) {
1024 new_triplet.
rho = sqrt(best_rho_sq);
1028 new_triplet.
rho = 0.;
1032 if ( update_derivatives ) {
1033 std::cout<<
"DARC derivatives are currently commented out...." << std::endl;
1119 using namespace basic::options;
1120 bool square = option[ OptionKeys::fingerprint::square_score ]();
1129 if ( (li->rho < 0.001) && (pi->rho < 0.001) ) {
1131 }
else if (li->rho < 0.001) {
1132 Total_score += missing_point_weight;
1133 }
else if (pi->rho < 0.001 ) {
1134 Total_score += extra_point_weight;
1136 core::Real dist_deviation = std::abs( pi->rho - li->rho );
1138 if (li->rho > pi->rho) dist_deviation *= dist_deviation;
1139 if (li->rho < pi->rho) dist_deviation *= (dist_deviation * steric_weight);
1142 if (li->rho > pi->rho) dist_deviation = dist_deviation;
1143 if (li->rho < pi->rho) dist_deviation = (dist_deviation * steric_weight);
1145 Total_score += dist_deviation;
1150 return (Total_score/num_rays);
1155 dE_dx = 0.; dE_dy = 0.; dE_dz = 0.; dE_dv4 = 0.; dE_dv5 = 0.; dE_dv6 = 0.;
1158 std::cout<<
"Error, fingerprint derivatives have not been computed" << std::endl;
1168 assert( std::abs( pi->phi - li->phi ) < 0.001 );
1169 assert( std::abs( pi->psi - li->psi ) < 0.001 );
1171 if ( (li->rho < 0.001) && (pi->rho < 0.001) ) {
1173 }
else if (li->rho < 0.001) {
1174 Total_score += missing_point_weight;
1175 }
else if (pi->rho < 0.001 ) {
1176 Total_score += extra_point_weight;
1178 core::Real dist_deviation = std::abs( pi->rho - li->rho );
1181 if (li->rho > pi->rho) {
1182 dE_dx += di->dDist_dv1;
1183 dE_dy += di->dDist_dv2;
1184 dE_dz += di->dDist_dv3;
1185 dE_dv4 += di->dDist_dv4;
1186 dE_dv5 += di->dDist_dv5;
1187 dE_dv6 += di->dDist_dv6;
1189 dist_deviation *= steric_weight;
1190 dE_dx += steric_weight * di->dDist_dv1;
1191 dE_dy += steric_weight * di->dDist_dv2;
1192 dE_dz += steric_weight * di->dDist_dv3;
1193 dE_dv4 += steric_weight * di->dDist_dv4;
1194 dE_dv5 += steric_weight * di->dDist_dv5;
1195 dE_dv6 += steric_weight * di->dDist_dv6;
1197 Total_score += dist_deviation;
1198 Differentiable_score += dist_deviation;
1210 Total_score /= num_rays;
1211 Differentiable_score /= num_rays;
1213 std::cout<<
"DARC score while computing derivatives: " << Total_score << std::endl;
1224 return search_random_poses( fp, num_pose_search, optimal_angle1, optimal_angle2, optimal_angle3, missing_point_weight, steric_weight, extra_point_weight, no_CoM_offset);
1230 core::Real best_score = std::numeric_limits<core::Real>::max();
1232 for (
core::Size j = 0; j < num_pose_search; ++j ){
1233 core::Real curr_angle1 = (
int) (numeric::random::uniform() *359.999);
1234 core::Real curr_angle2 = (
int) (numeric::random::uniform() *359.999);
1235 core::Real curr_angle3 = (
int) (numeric::random::uniform() *359.999);
1238 core::Real curr_score =
fp_compare( fp, missing_point_weight, steric_weight, extra_point_weight );
1240 if ( curr_score < best_score ) {
1241 best_score = curr_score;
1242 optimal_angle1 = curr_angle1;
1243 optimal_angle2 = curr_angle2;
1244 optimal_angle3 = curr_angle3;
1253 return find_optimal_rotation( fp, angle_increment, optimal_angle1, optimal_angle2, optimal_angle3, missing_point_weight, steric_weight, extra_point_weight, no_CoM_offset);
1258 core::Real best_score = std::numeric_limits<core::Real>::max();
1269 core::Real curr_score =
fp_compare( fp, missing_point_weight, steric_weight, extra_point_weight );
1271 if ( curr_score < best_score ) {
1272 best_score = curr_score;
1273 optimal_angle1 = curr_angle1;
1274 optimal_angle2 = curr_angle2;
1275 optimal_angle3 = curr_angle3;
1278 curr_angle3 += angle_increment;
1280 curr_angle2 += angle_increment;
1282 curr_angle1 += angle_increment;
1292 dump_oriented_pose_and_fp_to_pdb(pose_filename, fp_filename, fp, angle1_offset, angle2_offset, angle3_offset, original_pocket_angle_transform, no_CoM_offset );
1299 dump_oriented_pose_and_fp_to_pdb(pose_filename, fp_filename, fp, angle1_offset, angle2_offset, angle3_offset, original_pocket_angle_transform, CoM_offset );
1306 dump_oriented_pose_and_fp_to_pdb(pose_filename, fp_filename, fp, angle1_offset, angle2_offset, angle3_offset, original_pocket_angle_transform, no_CoM_offset );
1328 print_to_pdb( fp_filename, back_to_FingerprintBase_origin );
1330 utility::io::ozstream out_stream;
1331 out_stream.open(pose_filename, std::ios::out);
1333 out_stream<<
"HETATM "<<std::setw(2)<<1<<
" C ORI X 0 "<<std::setw(8)<<std::fixed<<std::setprecision(3)<<fp.
origin().x()<<std::setw(8)<<std::fixed<<std::setprecision(3)<<fp.
origin().y()<<std::setw(8)<<std::fixed<<std::setprecision(3)<<fp.
origin().z()<<std::endl;
1334 out_stream<<
"HETATM "<<std::setw(2)<<1<<
" C COM X 0 "<<std::setw(8)<<std::fixed<<std::setprecision(3)<<
CoM_.x()+back_to_FingerprintBase_origin.x()<<std::setw(8)<<std::fixed<<std::setprecision(3)<<
CoM_.y()+back_to_FingerprintBase_origin.y()<<std::setw(8)<<std::fixed<<std::setprecision(3)<<
CoM_.z()+back_to_FingerprintBase_origin.z()<<std::endl;
1339 for(
Size i = 1, i_end = curr_rsd.
natoms(); i <= i_end; ++i) {
1341 out_stream<<
"HETATM "<<std::setw(2)<<1<<
" C MAP A 1 "<<std::setw(8)<<std::fixed<<std::setprecision(3)<<curr_rsd.
atom(i).
xyz()(1)+back_to_FingerprintBase_origin.x()<<std::setw(8)<<std::fixed<<std::setprecision(3)<< curr_rsd.
atom(i).
xyz()(2)+back_to_FingerprintBase_origin.y() <<std::setw(8)<<std::fixed<<std::setprecision(3)<<curr_rsd.
atom(i).
xyz()(3)+back_to_FingerprintBase_origin.z() <<std::endl;
1354 return oriented_pose;
1375 I_mat.to_identity();
1389 for(
Size i = 1, i_end = ligand_total_atoms; i <= i_end; ++i) {
1390 ligand_com.x() += curr_rsd.
atom(i).
xyz()(1);
1391 ligand_com.y() += curr_rsd.
atom(i).
xyz()(2);
1392 ligand_com.z() += curr_rsd.
atom(i).
xyz()(3);
1394 ligand_com /= ligand_total_atoms;
1411 dist_sum += x_dist + y_dist + z_dist;
1480 double dD_dv1(
const double x0,
const double x2,
const double x3,
const double y0,
const double y2,
const double y3,
const double z0,
const double z2,
const double z3,
const double r){
1492 const double a = x2-x0;
1493 const double b = y2-y0;
1494 const double c = z2-z0;
1497 u =(-(a*x0) + a*x3 - b*y0 + b*y3 - c*z0 - sqrt(4.0*(a*(x0 - x3) + b*(y0 - y3) + c*(z0 - z3))*(a*(x0 - x3) + b*(y0 - y3) + c*(z0 - z3)) - 4.0*(a*a + b*b + c*
c)*(-r*r + (x0 - x3)*(x0-x3) + (y0 - y3)*(y0 - y3) + (z0 - z3)*(z0 - z3)))/2.0 + c*z3)/(a*a + b*b + c*
c);
1505 d = sqrt((xI-x2)*(xI-x2)+(yI-y2)*(yI-y2)+(zI-z2)*(zI-z2)) ;
1508 Q = (a*(xI-x2)+b*(yI-y2)+c*(zI-z2))/d ;
1512 du_dx3 = (a + (2.0*(b*b*(-x0 + x3) + a*b*(y0 - y3) + c*(c*(-x0 + x3) + a*(z0 - z3))))/sqrt(4.0*(a*(x0 - x3) + b*(y0 - y3) + c*(z0 - z3))*(a*(x0 - x3) + b*(y0 - y3) + c*(z0 - z3)) - 4.0*(a*a + b*b + c*c)*(-r*r + (x0 - x3)*(x0-x3) + (y0 - y3)*(y0 - y3) + (z0 - z3)*(z0 - z3))))/(a*a + b*b + c*c) ;
1519 double dD_dv2(
const double x0,
const double x2,
const double x3,
const double y0,
const double y2,
const double y3,
const double z0,
const double z2,
const double z3,
const double r){
1531 const double a = x2-x0;
1532 const double b = y2-y0;
1533 const double c = z2-z0;
1536 u = (-(a*x0) + a*x3 - b*y0 + b*y3 - c*z0 - sqrt(4.0*(a*(x0 - x3) + b*(y0 - y3) + c*(z0 - z3))*(a*(x0 - x3) + b*(y0 - y3) + c*(z0 - z3)) - 4.0*(a*a + b*b + c*
c)*(-r*r + (x0 - x3)*(x0-x3) + (y0 - y3)*(y0 - y3) + (z0 - z3)*(z0 - z3)))/2.0 + c*z3)/(a*a + b*b + c*
c);
1544 d = sqrt((xI-x2)*(xI-x2)+(yI-y2)*(yI-y2)+(zI-z2)*(zI-z2)) ;
1547 Q = (a*(xI-x2)+b*(yI-y2)+c*(zI-z2))/d ;
1550 du_dy3 = (b - (2.0*(a*b*(-x0 + x3) + a*a*(y0 - y3) + c*(c*(y0 - y3) + b*(-z0 + z3))))/sqrt(4.0*(a*(x0 - x3) + b*(y0 - y3) + c*(z0 - z3))*(a*(x0 - x3) + b*(y0 - y3) + c*(z0 - z3)) - 4.0*(a*a + b*b + c*c)*(-r*r + (x0 - x3)*(x0-x3) + (y0 - y3)*(y0 - y3) + (z0 - z3)*(z0 - z3))))/(a*a + b*b + c*c) ;
1556 double dD_dv3(
const double x0,
const double x2,
const double x3,
const double y0,
const double y2,
const double y3,
const double z0,
const double z2,
const double z3,
const double r){
1568 const double a = x2-x0;
1569 const double b = y2-y0;
1570 const double c = z2-z0;
1573 u = (-(a*x0) + a*x3 - b*y0 + b*y3 - c*z0 - sqrt(4.0*(a*(x0 - x3) + b*(y0 - y3) + c*(z0 - z3))*(a*(x0 - x3) + b*(y0 - y3) + c*(z0 - z3)) - 4.0*(a*a + b*b + c*
c)*(-r*r + (x0 - x3)*(x0-x3) + (y0 - y3)*(y0 - y3) + (z0 - z3)*(z0 - z3)))/2.0 + c*z3)/(a*a + b*b + c*
c);
1581 d = sqrt((xI-x2)*(xI-x2)+(yI-y2)*(yI-y2)+(zI-z2)*(zI-z2)) ;
1584 Q = (a*(xI-x2)+b*(yI-y2)+c*(zI-z2))/d ;
1587 du_dz3 = (c + (2.0*(a*c*(x0 - x3) + a*a*(-z0 + z3) + b*(c*(y0 - y3) + b*(-z0 + z3))))/sqrt(4.0*(a*(x0 - x3) + b*(y0 - y3) + c*(z0 - z3))*(a*(x0 - x3) + b*(y0 - y3) + c*(z0 - z3)) - 4.0*(a*a + b*b + c*c)*(-r*r + (x0 - x3)*(x0-x3) + (y0 - y3)*(y0 - y3) + (z0 - z3)*(z0 - z3))))/(a*a + b*b + c*c);
1593 double dD_dv4(
const double x0,
const double x2,
const double x3,
const double y0,
const double y2,
const double y3,
const double z0,
const double z2,
const double z3,
const double r,
const double v4,
const double v5,
const double v6,
const double ,
const double ,
const double yc,
const double ys,
const double zc,
const double zs) {
1600 dx3_dv4 = (-zc + zs)*(-(cos(v6)*sin(v4)*sin(v5)) + cos(v4)*sin(v6)) + (-yc + ys)*(cos(v4)*cos(v6)*sin(v5) + sin(v4)*sin(v6));
1601 dy3_dv4 = (-yc + ys)*(-(cos(v6)*sin(v4)) + cos(v4)*sin(v5)*sin(v6)) + (-zc + zs)*(-(cos(v4)*cos(v6)) - sin(v4)*sin(v5)*sin(v6)) ;
1602 dz3_dv4 = (-yc + ys)*cos(v4)*cos(v5) - (-zc + zs)*cos(v5)*sin(v4) ;
1604 return dD_dv1(x0,x2,x3,y0,y2,y3,z0,z2,z3,r)*dx3_dv4 +
dD_dv2(x0,x2,x3,y0,y2,y3,z0,z2,z3,r)*dy3_dv4 +
dD_dv3(x0,x2,x3,y0,y2,y3,z0,z2,z3,r)*dz3_dv4 ;
1608 double dD_dv5(
const double x0,
const double x2,
const double x3,
const double y0,
const double y2,
const double y3,
const double z0,
const double z2,
const double z3,
const double r,
const double v4,
const double v5,
const double v6,
const double xc,
const double xs,
const double yc,
const double ys,
const double zc,
const double zs) {
1615 dx3_dv5 = (-zc + zs)*cos(v4)*cos(v5)*cos(v6) + (-yc + ys)*cos(v5)*cos(v6)*sin(v4) - (-xc + xs)*cos(v6)*sin(v5) ;
1616 dy3_dv5 = (-zc + zs)*cos(v4)*cos(v5)*sin(v6) + (-yc + ys)*cos(v5)*sin(v4)*sin(v6) - (-xc + xs)*sin(v5)*sin(v6) ;
1617 dz3_dv5 = (xc - xs)*cos(v5) - (-zc + zs)*cos(v4)*sin(v5) - (-yc + ys)*sin(v4)*sin(v5) ;
1619 return dD_dv1(x0,x2,x3,y0,y2,y3,z0,z2,z3,r)*dx3_dv5 +
dD_dv2(x0,x2,x3,y0,y2,y3,z0,z2,z3,r)*dy3_dv5 +
dD_dv3(x0,x2,x3,y0,y2,y3,z0,z2,z3,r)*dz3_dv5 ;
1623 double dD_dv6(
const double x0,
const double x2,
const double x3,
const double y0,
const double y2,
const double y3,
const double z0,
const double z2,
const double z3,
const double r,
const double v4,
const double v5,
const double v6,
const double xc,
const double xs,
const double yc,
const double ys,
const double zc,
const double zs) {
1630 dx3_dv6 = (xc - xs)*cos(v5)*sin(v6) + (-zc + zs)*(cos(v6)*sin(v4) - cos(v4)*sin(v5)*sin(v6)) + (-yc + ys)*(-(cos(v4)*cos(v6)) - sin(v4)*sin(v5)*sin(v6)) ;
1631 dy3_dv6 = (-xc + xs)*cos(v5)*cos(v6) + (-yc + ys)*(cos(v6)*sin(v4)*sin(v5) - cos(v4)*sin(v6)) + (-zc + zs)*(cos(v4)*cos(v6)*sin(v5) + sin(v4)*sin(v6)) ;
1634 return dD_dv1(x0,x2,x3,y0,y2,y3,z0,z2,z3,r)*dx3_dv6 +
dD_dv2(x0,x2,x3,y0,y2,y3,z0,z2,z3,r)*dy3_dv6 +
dD_dv3(x0,x2,x3,y0,y2,y3,z0,z2,z3,r)*dz3_dv6 ;
1646 dirX = large_dist*sin(phiAngle)*cos(psiAngle);
1647 dirY = large_dist*sin(phiAngle)*sin(psiAngle);
1648 dirZ = large_dist*cos(phiAngle);
1651 core::Real const a = (dirX*dirX) + (dirY*dirY) + (dirZ*dirZ);
1652 core::Real const b = 2.0 * ( (dirX*(-atomX)) + (dirY*(-atomY)) + (dirZ*(-atomZ)) );
1653 core::Real const c = atomX*atomX + atomY*atomY + atomZ*atomZ - (atom_radius * atom_radius);
1656 core::Real const inside_sqrt = ( b *
b ) - ( 4. * a * c );
1658 if ( inside_sqrt > 0. ) {
1661 core::Real const mu1 = -(b-inside) / ( 2. * a);
1665 core::Real const dist1_sq = x1*x1 + y1*y1 + z1*z1;
1666 core::Real const mu2 = -(b+inside) / ( 2. * a);
1670 core::Real const dist2_sq = x2*x2 + y2*y2 + z2*z2;
1671 if ( dist2_sq < dist1_sq ) {
1682 std::list<numeric::xyzVector<core::Real> > combined_list;
1683 combined_list.clear();
1685 combined_list.push_back(*pd);
1688 combined_list.push_back(*pd);
1690 return combined_list;