1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797
|
// ----------------------------------------------------
// $Maintainer: Marcel Schumann $
// $Authors: Marcel Schumann $
// ----------------------------------------------------
#include <BALL/SCORING/COMMON/scoreGridSet.h>
using namespace BALL;
using namespace std;
ScoreGridSet::ScoreGridSet(GridBasedScoring* gbs, Vector3& v_origin_, Vector3& size, double& res)
{
origin_ = v_origin_;
original_origin_ = v_origin_;
resolution_ = res;
size_x = (int)size[0];
size_y = (int)size[1];
size_z = (int)size[2];
out_of_grid_penalty_ = 0;
enforce_grid_boundaries_ = 0;
reference_interactions = 0;
T_.setIdentity();
T_i_.setIdentity();
transformed_ = 0;
enabled_ = 1;
interaction_no_scale_ = gbs->getBurialDepthScale(); // as default use the value of the ScoringFunction that was set via Options by use user
parent = gbs;
hashgrid_ = gbs->hashgrid_;
new_hashgrid_ = 0;
score_grids_ = new vector<ScoreGrid*>;
score_grids_->clear(); //set to size of 0
is_reference_ = 0;
pharm_constraint_ = 0;
}
ScoreGridSet::ScoreGridSet(GridBasedScoring* gbs)
{
parent = gbs;
origin_ = Vector3(0, 0, 0);
original_origin_ = Vector3(0, 0, 0);
resolution_ = 0.5;
size_x = 0;
size_y = 0;
size_z = 0;
out_of_grid_penalty_ = 0;
enforce_grid_boundaries_ = 0;
reference_interactions = 0;
T_.setIdentity();
T_i_.setIdentity();
transformed_ = 0;
enabled_ = 1;
interaction_no_scale_ = gbs->getBurialDepthScale(); // as default use the value of the ScoringFunction that was set via Options by use user
hashgrid_ = gbs->hashgrid_;
new_hashgrid_ = 0;
score_grids_ = new vector<ScoreGrid*>;
score_grids_->clear(); //set to size of 0
is_reference_ = 0;
pharm_constraint_ = 0;
}
ScoreGridSet::ScoreGridSet(ScoreGridSet* sgs)
{
parent = sgs->parent;
origin_ = sgs->origin_;
original_origin_ = sgs->original_origin_;
resolution_ = sgs->resolution_;
size_x = sgs->size_x;
size_y = sgs->size_y;
size_z = sgs->size_z;
out_of_grid_penalty_ = sgs->out_of_grid_penalty_;
enforce_grid_boundaries_ = sgs->enforce_grid_boundaries_;
reference_interactions = sgs->reference_interactions;
interaction_no_scale_ = sgs->interaction_no_scale_;
T_ = sgs->T_;
T_i_ = sgs->T_i_;
transformed_ = sgs->transformed_;
enabled_ = sgs->enabled_;
interaction_no_scale_ = sgs->interaction_no_scale_;
hashgrid_ = sgs->hashgrid_;
new_hashgrid_ = 0;
// copy pointer to vector<ScoreGrid*>, thus no need to calculate/save interactions anew!
score_grids_ = sgs->score_grids_;
is_reference_ = 1; // <- make sure data is only calculate once and not deleted twice
pharm_constraint_ = sgs->pharm_constraint_;
}
ScoreGridSet::ScoreGridSet()
{
parent = 0;
origin_ = Vector3(0, 0, 0);
original_origin_ = Vector3(0, 0, 0);
resolution_ = 0.5;
size_x = 0;
size_y = 0;
size_z = 0;
out_of_grid_penalty_ = 0;
enforce_grid_boundaries_ = 0;
reference_interactions = 0;
T_.setIdentity();
T_i_.setIdentity();
transformed_ = 0;
enabled_ = 1;
interaction_no_scale_ = 0;
hashgrid_ = 0;
new_hashgrid_ = 0;
score_grids_ = new vector<ScoreGrid*>;
score_grids_->clear(); //set to size of 0
is_reference_ = 0;
pharm_constraint_ = 0;
}
ScoreGridSet::~ScoreGridSet()
{
if (!is_reference_)
{
for (Size i = 0; i < score_grids_->size(); i++)
{
delete (*score_grids_)[i];
}
delete score_grids_;
}
if (new_hashgrid_)
{
delete hashgrid_;
}
}
void ScoreGridSet::operator += (ScoreGridSet& sgs)
{
if (*getAtomTypesMap() != *sgs.getAtomTypesMap())
{
throw BALL::Exception::GeneralException(__FILE__, __LINE__, "ScoreGridSet::operator += Error", "ScoreGrid to be added must use the same atom types!");
}
for (Size x = 0; x < size_x; x++)
{
for (Size y = 0; y < size_y; y++)
{
for (Size z = 0; z < size_z; z++)
{
for (Size grid = 0; grid < score_grids_->size(); grid++)
{
Vector3 position((x+0.5)*resolution_, (y+0.5)*resolution_, (z+0.5)*resolution_);
(*this)[grid][x][y][z] += sgs.getGridScore(grid, position, false);
}
}
}
}
}
void ScoreGridSet::operator -= (ScoreGridSet& sgs)
{
if (*getAtomTypesMap() != *sgs.getAtomTypesMap())
{
throw BALL::Exception::GeneralException(__FILE__, __LINE__, "ScoreGridSet::operator += Error", "ScoreGrid to be added must use the same atom types!");
}
for (Size x = 0; x < size_x; x++)
{
for (Size y = 0; y < size_y; y++)
{
for (Size z = 0; z < size_z; z++)
{
for (Size grid = 0; grid < score_grids_->size(); grid++)
{
Vector3 position((x+0.5)*resolution_, (y+0.5)*resolution_, (z+0.5)*resolution_);
(*this)[grid][x][y][z] -= sgs.getGridScore(grid, position, false);
}
}
}
}
}
void ScoreGridSet::clearData()
{
for (Size x = 0; x < size_x; x++)
{
for (Size y = 0; y < size_y; y++)
{
for (Size z = 0; z < size_z; z++)
{
for (Size grid = 0; grid < score_grids_->size(); grid++)
{
Vector3 position((x+0.5)*resolution_, (y+0.5)*resolution_, (z+0.5)*resolution_);
(*this)[grid][x][y][z] = 0;
}
}
}
}
}
void ScoreGridSet::enable()
{
enabled_ = 1;
}
void ScoreGridSet::disable()
{
enabled_ = 0;
}
bool ScoreGridSet::isEnabled()
{
return enabled_;
}
std::map<BALL::String, int>* ScoreGridSet::getAtomTypesMap()
{
if (parent) return parent->getAtomTypesMap();
else return &atom_types_map_no_parent_;
}
BALL::String ScoreGridSet::getGridAtomTypeName(int grid_id)
{
if (parent) return parent->getGridAtomTypeName(grid_id);
for (std::map < String, int > ::iterator it = atom_types_map_no_parent_.begin(); it != atom_types_map_no_parent_.end(); it++)
{
if (it->second == grid_id) return it->first;
}
String mess = "No ScoreGrid with ID="+String(grid_id)+" !!";
throw BALL::Exception::GeneralException(__FILE__, __LINE__, "ScoreGridSet::getGridAtomTypeName() error", mess);
return "";
}
void ScoreGridSet::initializeEmptyGrids(int no)
{
// delete old grids first (if any)
for (Size i = 0; i < score_grids_->size(); i++)
{
delete (*score_grids_)[i];
}
score_grids_->clear();
int no_grids = no;
if (no == -1)
{
if (parent) no_grids = parent->getAtomTypesMap()->size();
else no_grids = 1;
}
score_grids_->resize(no_grids);
std::vector<double> v1((int)size_z, 0);
std::vector<vector<double> > v2((int)size_y, v1);
for (int i = 0; i < no_grids; i++)
{
(*score_grids_)[i] = new ScoreGrid((int)size_x, v2);
}
}
void ScoreGridSet::setHashGrid(HashGrid3<Atom*>* hashgrid)
{
hashgrid_ = hashgrid;
new_hashgrid_ = 1;
}
double ScoreGridSet::getGridScore(Size grid, Vector3 pos, bool interpolation)
{
if (grid > score_grids_->size())
{
String s = "ScoreGrid "; s += String(grid)+" does not exist (yet) !";
throw Exception::GeneralException(__FILE__, __LINE__, "ScoreGridSet::getGridScore() error", s);
}
if (transformed_)
{
pos = T_i_*pos;
}
int x = (int)((pos.x-original_origin_.x)/resolution_); // indices of cell
int y = (int)((pos.y-original_origin_.y)/resolution_);
int z = (int)((pos.z-original_origin_.z)/resolution_);
if (x < 0 || y < 0 || z < 0 || x >= (int)size_x || y >= (int)size_y || z >= (int)size_z )
{
return out_of_grid_penalty_; // (if desired) treat atoms outside of grid as sterical clashes
}
if (interpolation)
{
// calculate the distance between the point and the center of the assigned cell along each of the 3 axes
double center_x = (x+0.5)*resolution_+original_origin_.x;
double center_y = (y+0.5)*resolution_+original_origin_.y;
double center_z = (z+0.5)*resolution_+original_origin_.z;
double factor_x = (center_x-pos.x)/resolution_;
double factor_y = (center_y-pos.y)/resolution_;
double factor_z = (center_z-pos.z)/resolution_;
double score = 0;
int x_neighbor = x;
if (factor_x < -0.3) x_neighbor += 1;
else if (factor_x > 0.3) x_neighbor -= 1;
int y_neighbor = y;
if (factor_y < -0.3) y_neighbor += 1;
else if (factor_y > 0.3) y_neighbor -= 1;
int z_neighbor = z;
if (factor_z < -0.3) z_neighbor += 1;
else if (factor_z > 0.3) z_neighbor -= 1;
if (x_neighbor == x && y_neighbor == y && z_neighbor == z)
{
return (*(*score_grids_)[grid])[x][y][z];
}
if (x_neighbor >= 0 && x_neighbor < (int)size_x && y_neighbor >= 0 && y_neighbor < (int)size_y
&& z_neighbor>=0&&z_neighbor<(int)size_z)
{
Vector3 center(center_x, center_y, center_z);
Vector3 neighbor_center((x_neighbor+0.5)*resolution_+original_origin_.x, (y_neighbor+0.5)*resolution_+original_origin_.y, (z_neighbor+0.5)*resolution_+original_origin_.z);
double dist1 = pos.getDistance(center);
double dist2 = pos.getDistance(neighbor_center);
double factor = dist1/(dist1+dist2);
score = factor*(*(*score_grids_)[grid])[x][y][z]
+ (1-factor)*(*(*score_grids_)[grid])[x_neighbor][y_neighbor][z_neighbor];
return score;
}
else return (*(*score_grids_)[grid])[x][y][z];
}
return (*(*score_grids_)[grid])[x][y][z];
}
HashGrid3<Atom*>* ScoreGridSet::getHashGrid()
{
return hashgrid_;
}
ScoreGrid& ScoreGridSet::operator[](int i)
{
return *(*score_grids_)[i];
}
void ScoreGridSet::transform(TMatrix4x4 < float > & T)
{
TMatrix4x4<float> T_i;
T.invert(T_i); // store inverse of T in T_i
T_ *= T;
T_i_ *= T_i ; // store the inverse of all transformations in T_i_
transformed_ = 1;
origin_ = T*origin_;
}
void ScoreGridSet::moveTo(Vector3& destination)
{
Vector3 translate = destination - getCenter();
Matrix4x4 T;
T.setTranslation(translate);
transform(T);
}
Vector3 ScoreGridSet::getOrigin()
{
return origin_;
}
Vector3 ScoreGridSet::getCenter()
{
Vector3 center = origin_;
center.x += 0.5*size_x*resolution_;
center.y += 0.5*size_y*resolution_;
center.z += 0.5*size_z*resolution_;
return center;
}
Size ScoreGridSet::sizeX()
{
return size_x;
}
Size ScoreGridSet::sizeY()
{
return size_y;
}
Size ScoreGridSet::sizeZ()
{
return size_z;
}
Size ScoreGridSet::noGrids()
{
return score_grids_->size();
}
void ScoreGridSet::binaryWrite(std::ostream& outfile)
{
BinaryFileAdaptor<Size> adapt_size;
BinaryFileAdaptor<Vector3> adapt_vector3;
BinaryFileAdaptor<double> adapt_double;
BinaryFileAdaptor<bool> adapt_bool;
BinaryFileAdaptor<char> adapt_char;
// save information about the number of grids
adapt_size.setData(score_grids_->size());
outfile << adapt_size;
// save information about the number of cells on each axis of each grid
adapt_size.setData(sizeX());
outfile << adapt_size;
adapt_size.setData(sizeY());
outfile << adapt_size;
adapt_size.setData(sizeZ());
outfile << adapt_size;
adapt_double.setData(resolution_);
outfile << adapt_double;
adapt_vector3.setData(original_origin_);
outfile << adapt_vector3;
adapt_double.setData(out_of_grid_penalty_);
outfile << adapt_double;
adapt_bool.setData(enforce_grid_boundaries_);
outfile << adapt_bool;
// now save each score-grid
for (Size g = 0; g < score_grids_->size(); g++)
{
String type_name = getGridAtomTypeName(g).c_str();
Size no_chars = type_name.size();
// write the number of chars of the type-name
adapt_size.setData(no_chars);
outfile << adapt_size;
// .. and now write the type-name itself
for (Size t = 0; t < no_chars; t++)
{
char c = type_name[t];
adapt_char.setData(c);
outfile << adapt_char;
}
for (Size i = 0; i < (*score_grids_)[g]->size(); i++)
{
for (Size j = 0; j < (*(*score_grids_)[g])[i].size(); j++)
{
for (Size k = 0; k < (*(*score_grids_)[g])[i][j].size(); k++)
{
adapt_double.setData((*(*score_grids_)[g])[i][j][k]);
outfile << adapt_double;
}
}
}
}
}
void ScoreGridSet::binaryRead(std::istream& infile)
{
BinaryFileAdaptor<Size> adapt_size;
BinaryFileAdaptor<Vector3> adapt_vector3;
BinaryFileAdaptor<double> adapt_double;
BinaryFileAdaptor<bool> adapt_bool;
BinaryFileAdaptor<char> adapt_char;
infile >> adapt_size;
Size no_grids = adapt_size.getData();
infile >> adapt_size;
size_x = adapt_size.getData();
infile >> adapt_size;
size_y = adapt_size.getData();
infile >> adapt_size;
size_z = adapt_size.getData();
infile >> adapt_double;
resolution_ = adapt_double.getData();
infile >> adapt_vector3;
original_origin_ = adapt_vector3.getData();
origin_ = original_origin_;
infile >> adapt_double;
out_of_grid_penalty_ = adapt_double.getData();
infile >> adapt_bool;
enforce_grid_boundaries_ = adapt_bool.getData();
initializeEmptyGrids(no_grids);
std::map<String, int>* type_map = getAtomTypesMap();
bool replace = 0;
if (!parent || parent->grid_sets_.size() == 1)
{
type_map->clear(); // remove old atomTypes from map, if there is only ONE ScoreGridSet (this one)
replace = 1;
}
// now read each score-grid
for (Size g = 0; g < no_grids; g++)
{
// read information about the number of chars of the type-name
infile >> adapt_size;
Size no_chars = adapt_size.getData();
// .. and now read the type-name itself
String type_name ="";
for (Size t = 0; t < no_chars; t++)
{
infile >> adapt_char;
char c = adapt_char.getData();
type_name += c;
}
if (replace)
{
type_map->insert(make_pair(type_name, g));
}
// if there is more than one ScoreGridSet, AtomTypes MUST be identical for all ScoreGridSets !!
else
{
String expected_atomtype = getGridAtomTypeName(g);
if (type_name != expected_atomtype)
{
std::cout<<type_name<<" "<<expected_atomtype<<std::endl;
throw BALL::Exception::GeneralException(__FILE__, __LINE__, "ScoreGridSet::readFromFile() error", "If using more than one ScoreGridSet, all ScoreGridSets MUST contain the same AtomTypes!!");
}
}
for (Size i = 0; i < (*score_grids_)[g]->size(); i++)
{
for (Size j = 0; j < (*(*score_grids_)[g])[i].size(); j++)
{
for (Size k = 0; k < (*(*score_grids_)[g])[i][j].size(); k++)
{
infile >> adapt_double;
(*(*score_grids_)[g])[i][j][k] = adapt_double.getData();
}
}
}
}
}
void ScoreGridSet::saveToFile(std::ostream& out, String receptor_name)
{
out<<"ScoreGridSet for receptor "<<receptor_name<<endl;
out<<"no of grids: "<<score_grids_->size()<<endl;
out<<"no of grid boxes: "<<sizeX()<<" "<<sizeY()<<" "<<sizeZ()<<endl;
out<<"resolution_ (in Angstroem): "<<resolution_<<endl;
out<<"origin_: "<<original_origin_[0]<<" "<<original_origin_[1]<<" "<<original_origin_[2]<<endl;
out<<"out_of_grid_penalty_: "<<out_of_grid_penalty_<<endl;
out<<"enforce_grid_boundaries_?: "<<enforce_grid_boundaries_<<endl;
//cout<<filename<<" "<<score_grids_->size()<<" "<<getAtomTypesMap()->size()<<endl;
for (Size grid = 0; grid < score_grids_->size(); grid++)
{
out<<endl<<"===========================================\n\n";
//out<<"ScoreGrid for AtomType: "<< it->first << endl; it++;
out<<"ScoreGrid for AtomType: "<< getGridAtomTypeName(grid) << endl;
int no_overlaps = 0;
for (Size i = 0; i < size_x; i++)
{
for (Size j = 0; j < size_y; j++)
{
for (Size k = 0; k < size_z; k++)
{
if ((*(*score_grids_)[grid])[i][j][k] >= 1e10)
{
no_overlaps++;
}
else
{
// write information about impossible positions for ligands atoms in compressed format
if (no_overlaps > 0)
{
if (no_overlaps > 1)
{
out<<"NA "<<no_overlaps<<"\t";
}
else
{
out<<out_of_grid_penalty_<<"\t";
}
no_overlaps = 0;
}
out <<(*(*score_grids_)[grid])[i][j][k]<<"\t";
}
}
if (no_overlaps == 0) out<<endl;
}
}
if (no_overlaps > 1)
{
out<<"NA "<<no_overlaps<<"\t" << endl;
}
else if (no_overlaps == 1)
{
out<<out_of_grid_penalty_<<"\t" << endl;
}
}
}
void ScoreGridSet::readFromFile(istream& input)
{
String tmp;
Size no_grids = 0;
double x_origin = 0; double y_origin = 0; double z_origin = 0;
getline(input, tmp); // skip first line containing the name of the receptor
input>>tmp; input>>tmp; input>>tmp;
input>>no_grids; // read the number of energy grids ( == no of atom types)
input>>tmp; input>>tmp; input>>tmp; input>>tmp;
input >> size_x; input >> size_y; input>>size_z;
initializeEmptyGrids(no_grids);
input>>tmp; input>>tmp; input>>tmp;
input>>resolution_; // read resolution_ of grids
input>>tmp;
input>>x_origin; input>>y_origin; input>>z_origin;
origin_ = Vector3(x_origin, y_origin, z_origin);
original_origin_ = origin_;
input>>tmp; input>>out_of_grid_penalty_;
input>>tmp; input>>enforce_grid_boundaries_;
map<String, int>* type_map = getAtomTypesMap();
bool replace = 0;
if (!parent || parent->grid_sets_.size() == 1)
{
type_map->clear(); // remove old atomTypes from map, if there is only ONE ScoreGridSet (this one)
replace = 1;
}
// empty line is skipped automatically
for (Size a = 0; a < no_grids; a++)
{
input>>tmp; // skip partitioner ("======")
// empty line is skipped automatically
input>>tmp; input>>tmp; input>>tmp;
String atomtype;
input >> atomtype;
if (replace)
{
type_map->insert(make_pair(atomtype, a));
}
// if there is more than one ScoreGridSet, AtomTypes MUST be identical for all ScoreGridSets !!
else
{
String expected_atomtype = getGridAtomTypeName(a);
if (atomtype != expected_atomtype)
{
cout<<atomtype<<" "<<expected_atomtype<<endl;
throw BALL::Exception::GeneralException(__FILE__, __LINE__, "ScoreGridSet::readFromFile() error", "If using more than one ScoreGridSet, all ScoreGridSets MUST contain the same AtomTypes!!");
}
}
int no_overlaps = 0;
for (Size i = 0; i < (*score_grids_)[a]->size(); i++)
{
for (Size j = 0; j < (*(*score_grids_)[a])[i].size(); j++)
{
for (Size k = 0; k < (*(*score_grids_)[a])[i][j].size(); k++)
{
if (no_overlaps > 0)
{
(*(*score_grids_)[a])[i][j][k] = 1e10;
no_overlaps--;
}
else
{
// read information about impossible positions for ligands atoms in compressed format
String v;
double value = 1e10;
input>>v;
if (v == "NA")
{
input>>no_overlaps;
no_overlaps--;
}
else
{
value = v.toFloat();
}
(*(*score_grids_)[a])[i][j][k] = value;
}
}
// empty line is skipped automatically
}
// empty line is skipped automatically
}
// the following line is also skipped automatically
//cout<<(*all_energy_grids_[a])[x_boxes-1][y_boxes-1][z_boxes-1]<<endl;
}
// read just past the end of the last line
getline(input, tmp);
}
list<pair<String, RegularData3D*> > ScoreGridSet::convertToRegularData3DGrids()
{
list<pair<String, RegularData3D*> > reg3d_list;
for (Size g = 0; g < noGrids(); g++)
{
Vector3 resolution(resolution_, resolution_, resolution_);
Vector3 dimension(resolution_*sizeX(), resolution_*sizeY(), resolution_*sizeZ());
RegularData3D* reg3d = new RegularData3D(origin_, dimension, resolution);
ScoreGrid& scoregrid((*this)[g]);
for (Size i = 0; i < sizeX(); i++)
{
for (Size j = 0; j < sizeY(); j++)
{
for (Size k = 0; k < sizeZ(); k++)
{
RegularData3D::IndexType index(i, j, k);
reg3d->getData(index) = scoregrid[i][j][k];
}
}
}
String name = getGridAtomTypeName(g);
reg3d_list.push_back(make_pair(name, reg3d));
}
return reg3d_list;
}
PharmacophoreConstraint* ScoreGridSet::getPharmacophoreConstraint()
{
return pharm_constraint_;
}
void ScoreGridSet::setPharmacophoreConstraint(PharmacophoreConstraint* phc)
{
pharm_constraint_ = phc;
}
void ScoreGridSet::setParameters(bool enforce_grid_boundaries, double out_of_grid_penalty, double interaction_no_scale)
{
enforce_grid_boundaries_ = enforce_grid_boundaries;
out_of_grid_penalty_ = out_of_grid_penalty;
interaction_no_scale_ = interaction_no_scale;
}
|