void IMGDock::saveAtomPositions() { original_atom_positions_.resize(scoring_function_->getNoLigandAtoms()); Size atom = 0; for (AtomIterator it = ligand_->beginAtom(); +it; it++, atom++) { original_atom_positions_[atom] = it->getPosition(); } }
void GridAnalysis::moveProbeGroup_(const Vector3& destination) { TMatrix4x4<float> M; Vector3 translation_vector = destination-center_; M.setTranslation(translation_vector); for (AtomIterator it = probe_group_.beginAtom(); +it; it++) { it->setPosition(M*it->getPosition()); } center_ = destination; }
void IMGDock::translateLigand(Vector3& v) { TMatrix4x4<float> M; M.setTranslation(v); // transform all atoms of the ligand for (AtomIterator it = ligand_->beginAtom(); it != ligand_->endAtom(); it++) { it->setPosition(M*it->getPosition()); } }
void GridAnalysis::rotateProbeGroup_(int axis, int degree) { TMatrix4x4<float> M; TAngle<float> angle(degree, false); Vector3 axis_vector(axis == 0, axis == 1, axis == 2); M.setRotation(angle, axis_vector); for (AtomIterator it = probe_group_.beginAtom(); it != probe_group_.endAtom(); it++) { it->setPosition(M*(it->getPosition()-center_)+center_); } }
void IMGDock::rotateLigand(int a, int degree) { TMatrix4x4<float> M; TAngle<float> angle(degree, false); Vector3 axis(a == 0, a == 1, a == 2); M.setRotation(angle, axis); const Vector3& origin = scoring_function_->getLigandCenter(); for (AtomIterator it = ligand_->beginAtom(); it != ligand_->endAtom(); it++) { it->setPosition(M*(it->getPosition()-origin)+origin); } }
bool compareMolecules(Molecule& mol1, Molecule& mol2) { if(mol1.countAtoms()!=mol2.countAtoms()) return false; if(mol1.countBonds()!=mol2.countBonds()) return false; AtomIterator ai; vector<Vector3> pos1; vector<float> q1; BALL_FOREACH_ATOM(mol1, ai) { pos1.push_back(ai->getPosition()); q1.push_back(ai->getCharge()); }
void DockingAlgorithm::mapLigandOntoReferenceLigand() { if (!scoring_function_) { Log.error()<<"Error DockingAlgorithm::mapLigandOntoReferenceLigand() : ScoringFunction not set!"<<endl; return; } AtomContainer* ligand = scoring_function_->getLigand(); if (!ligand) { Log.error()<<"Error DockingAlgorithm::mapLigandOntoReferenceLigand() : Ligand not set!"<<endl; return; } if (!reference_ligand_) { Log.error()<<"Error DockingAlgorithm::mapLigandOntoReferenceLigand() : Reference ligand not set!"<<endl; return; } Timer timer; timer.start(); double lower_bound = 2; double upper_bound = 5; double tolerance = 1; Size no_matched_atoms = 0; double rmsd = 0; Matrix4x4 T = mapCompounds(*ligand, *reference_ligand_, no_matched_atoms, rmsd, upper_bound, lower_bound, tolerance); for (AtomIterator it = ligand->beginAtom(); +it; it++) { it->setPosition(T*it->getPosition()); } timer.stop(); Log.level(10)<<"superposing ligand: "<<timer.getClockTime()<<" seconds"<<endl; }
// checking for default mode: reading AntechamberFile f(BALL_TEST_DATA_PATH(AntechamberFile_test1.ac)); TEST_EQUAL(f.isValid(), true) RESULT CHECK(AntechamberFile::read(System& system)) AntechamberFile f(BALL_TEST_DATA_PATH(AntechamberFile_test2.ac)); System S; f.read(S); f.close(); TEST_EQUAL(S.countAtoms(), 2) AtomIterator it = S.beginAtom(); TEST_EQUAL(it->getElement().getSymbol(), "H") TEST_REAL_EQUAL(it->getPosition().x, 0.0) TEST_REAL_EQUAL(it->getPosition().y, 1.0) TEST_REAL_EQUAL(it->getPosition().z, 2.0) it++; TEST_EQUAL(it->getElement().getSymbol(), "O") TEST_REAL_EQUAL(it->getPosition().x, 3.0) TEST_REAL_EQUAL(it->getPosition().y, 4.0) TEST_REAL_EQUAL(it->getPosition().z, 5.0) RESULT CHECK(AntechamberFile::read(System& system)) AntechamberFile f(BALL_TEST_DATA_PATH(AntechamberFile_test1.ac)); System S; f.read(S); f.close();
void PeptideCapProcessor::optimizeCapPosition(Chain& chain, bool start) { Vector3 translation; Atom* axis = NULL; Residue* cap = NULL; std::vector<Atom*> a; std::vector<Atom*> b; Size nr = chain.countResidues(); // cap at the beginning of a peptide if (start) { // put ACE-C to the center for (AtomIterator it = chain.getResidue(1)->beginAtom(); +it; ++it) { if (it->getName() == "N") { translation = it->getPosition(); } b.push_back(&*it); } cap = chain.getResidue(0); for (AtomIterator it = cap->beginAtom(); +it; ++it) { a.push_back(&*it); if (it->getName() == "C") { axis = &*it; } } } //cap at the end of a peptide else { for (AtomIterator it = chain.getResidue(nr-2)->beginAtom(); +it; ++it) { if (it->getName() == "C") { translation = it->getPosition(); } b.push_back(&*it); } cap = chain.getResidue(nr-1); for (AtomIterator it = cap->beginAtom(); +it; ++it) { a.push_back(&*it); if (it->getName() == "N") { axis = &*it; } } } //translate the anchor to origin TranslationProcessor tlp; tlp.setTranslation(translation*-1.0); chain.apply(tlp); //try all torsions float largest_distance = 0.0; float tmp_distance = 0.0; float torsion = 0.0; float step = 2.0; TransformationProcessor tfp; Matrix4x4 m; m.setRotation( Angle(step, false), axis->getPosition()); tfp.setTransformation(m); for (Position r = step; r <= 360; r+=step) { cap->apply(tfp); tmp_distance = computeDistance(a,b); if (largest_distance < tmp_distance) { largest_distance = tmp_distance; torsion = r; } } //apply best rotation angle m.setRotation( Angle(torsion, false), axis->getPosition()); tfp.setTransformation(m); cap->apply(tfp); //now translate the protein back tlp.setTranslation(translation); chain.apply(tlp); }
void EditMode::addStructure_() { QAction* action = dynamic_cast<QAction*>(sender()); if (action == 0) return; String name = ascii(action->text()); scene_->deselect(); if (!fragment_db_) { fragment_db_ = new FragmentDB("fragments/Editing-Fragments.db"); } list<AtomContainer*> containers = scene_->getContainers(); if (containers.size() == 0) return; Residue* residue = fragment_db_->getResidueCopy(name); if (residue == 0) { residue = fragment_db_->getResidueCopy(name + "-Skeleton"); if (residue == 0) return; } Vector3 p; Size nr = 0; AtomIterator ait = residue->beginAtom(); for (;+ait; ++ait) { p += ait->getPosition(); nr++; } if (nr == 0) { BALLVIEW_DEBUG delete residue; return; } p /= (float) nr; QPoint pos = scene_->mapFromGlobal(mouse_pos_new_); Matrix4x4 m; Vector3 x = scene_->mapViewportTo3D(pos.x(), pos.y()); TransformationProcessor tf; Vector3 vv = scene_->getStage()->getCamera().getViewVector(); float l = vv.getLength(); if (!Maths::isZero(l)) vv /= l; Vector3 axis = Vector3(1,0,0) % vv; if (axis.getSquareLength() != 0) { Angle a = vv.getAngle(Vector3(1,0,0)); m.setRotation(a, axis); tf.setTransformation(m); residue->apply(tf); } m.setTranslation(x - p); tf.setTransformation(m); residue->apply(tf); AtomContainer* s = *containers.begin(); if (RTTI::isKindOf<System>(*s)) { System* system = (System*) s; Molecule* mol = system->getMolecule(0); if (mol == 0) { mol = new Molecule(); system->insert(*mol); } s = mol; } s->insert(*residue); scene_->getMainControl()->deselectCompositeRecursive(s, true); scene_->getMainControl()->selectCompositeRecursive(residue, true); scene_->getMainControl()->update(*s); scene_->notify(new NewSelectionMessage); // setMode(MOVE__MODE); }
double Polarity::updateScore() { score_ = 0.0; //float val = 0.0; //float distance; //float R1; //float R2; const HashGrid3<Atom*>* hashgrid = scoring_function_->getHashGrid(); int radius = 1; Size no_neighbor_cells = (Size)pow((double)(radius*2+1), 3); // radius of 1 cell == > 3 cells on each axis double total_sum = 0; AtomPairVector::const_iterator it; for (AtomIterator it = scoring_function_->getLigand()->beginAtom(); +it; it++) { int no_positive_contacts = 0; int no_negative_contacts = 0; bool ligandatom_is_lipophilic = isLipophilic_(&*it); if (!ligandatom_is_lipophilic) { continue; } const HashGridBox3<Atom*>* box = hashgrid->getBox(it->getPosition()); // ligand atom lies outside of grid if (!box) continue; Position pos_x, pos_y, pos_z; hashgrid->getIndices(*box, pos_x, pos_y, pos_z); // indices in HashGrid, where the search for interacting target atoms should begin ( != position of ligand atom) int i = ((int)pos_x)-radius; if (i < 0){i = 0; } int j0 = ((int)pos_y)-radius; if (j0 < 0){j0 = 0; } int k0 = ((int)pos_z)-radius; if (k0 < 0){k0 = 0; } int x_size = (int)hashgrid->getSizeX(); int y_size = (int)hashgrid->getSizeY(); int z_size = (int)hashgrid->getSizeZ(); for (; i <= pos_x+radius && i < x_size; i++) { for (int j = j0; j <= pos_y+radius && j < y_size; j++) { for (int k = k0; k <= pos_z+radius && k < z_size; k++) { const HashGridBox3<Atom*>* box = hashgrid->getBox(i, j, k); if (!box->isEmpty()) { double cell_score = 0; for (HashGridBox3 < Atom* > ::ConstDataIterator d_it = box->beginData(); d_it != box->endData(); d_it++) { if (isBackboneAtom_(*d_it)) continue; bool rec_polar = isPolar_(*d_it); bool rec_lipophilic = 0; if (!rec_polar) rec_lipophilic = isLipophilic_(*d_it); if (!rec_polar && ! rec_lipophilic) continue; double distance = ((*d_it)->getPosition()-it->getPosition()).getLength(); if (distance > (*d_it)->getElement().getVanDerWaalsRadius()+it->getElement().getVanDerWaalsRadius()+1.5) continue; double val; if (distance > 1) val = 1/distance; else val = 1; // lipophilic--lipophilic interaction; else polar rec. -- lipophilic ligand atom if (rec_lipophilic) { val *= -1; } cell_score += val; total_sum += val; if (scoring_function_->storeInteractionsEnabled()) { val = scaleScore(val); it->addInteraction(*d_it, "pol", val); (*d_it)->addInteraction(&*it, "pol", val); } } if (cell_score < -0.1) no_positive_contacts++; else if (cell_score > 0.1) no_negative_contacts++; } // if there is no neighboring receptor atom, there will be water ... // else if(i!=pos_x||j!=pos_y||k!=pos_z) // { // if(ligandatom_is_lipophilic) // { // no_negative_contacts++; // double scaled_atom_score = 1.0/no_neighbor_cells; // scaleScore(scaled_atom_score); // total_sum += scaled_atom_score; // it->addInteraction("pol",scaled_atom_score); // } // } } } } score_ += (no_negative_contacts-no_positive_contacts)/((double)no_neighbor_cells); //cout<<it->getFullName()<<" : "<<no_negative_contacts<<", "<<no_positive_contacts<<" "<<(no_negative_contacts-no_positive_contacts)/((double)no_neighbor_cells)<<endl; } // scaleScore(); // cout<<"polarity: total sum="<<total_sum<<endl; // cout<<"polarity: score="<<score_<<endl; // return score_; return getScaledScore(); }