3-D Structural Alignment. This naive randomized algorithm finds the transformation that superpose one molecule on another with a small RMSD (3-D alignment). The algorithm works as follows. First, for each molecule : 1. calculate the center of mass 2. transform the mass center to the center of coordinate system (apply this transformation to the whole molecule) Then, randomly rotate the second molecule. Pick up rotation that gives the largest alignment. Relevant classes: Vector3 Atom RigidTrans3 Matrix3 Molecule PDB Match GeomHash Code example: //************************************************* class CAlphaSelector : public PDB::Selector { // This class defines a selector that will pick only C-alpha atoms. public: bool operator()(const char *PDBrec) const { const char *type = PDB::atomType(PDBrec); return (*(type+1) == 'C' && *(type+2) == 'A'); } }; //************************************************* int main(int argc , char* argv[]){ Timer overallTime("Overall Run Time"); overallTime.start(); if(argc !=5) { cerr << "Usage: "< molModel,molTarget; ifstream fileModel(argv[2],ios::in); ifstream fileTarget(argv[1],ios::in); if(!fileModel){ cout<<"File "< gHash(3,m_fDistThr); //loop over all atoms of target molecule for(unsigned int i=0;i result; gHash.query(mol_atom, m_fDistThr, result); //check if the atoms inside distance threshold HashResult::iterator x_end=result.end(), x; for (x = result.begin(); x != x_end; x++) { if (mol_atom.dist(molTarget[*x].position()) <= m_fDistThr) { float score = (1 / (1+(molModel[i].position() | molTarget[ *x ]))); match.add( *x , i, score , score ); } } result.clear(); } //calculates transformation that is a little better than "rotation" match.calculateBestFit( molTarget, molModel); if(iMaxSize < match.size() ){ iMaxSize = match.size(); rtransBest=match.rigidTrans(); } } cout<<"Max Alignment Size: " << iMaxSize <