void OBRotamerList::Setup(OBMol &mol,OBRotorList &rl) { //clear the old stuff out if necessary _vres.clear(); vector<unsigned char*>::iterator j; for (j = _vrotamer.begin();j != _vrotamer.end();++j) delete [] *j; _vrotamer.clear(); vector<pair<OBAtom**,vector<int> > >::iterator k; for (k = _vrotor.begin();k != _vrotor.end();++k) delete [] k->first; _vrotor.clear(); _vrings.clear(); _vringTors.clear(); //create the new list OBRotor *rotor; vector<OBRotor*>::iterator i; vector<int> children; int ref[4]; OBAtom **atomlist; for (rotor = rl.BeginRotor(i);rotor;rotor = rl.NextRotor(i)) { atomlist = new OBAtom* [4]; rotor->GetDihedralAtoms(ref); atomlist[0] = mol.GetAtom(ref[0]); atomlist[1] = mol.GetAtom(ref[1]); atomlist[2] = mol.GetAtom(ref[2]); atomlist[3] = mol.GetAtom(ref[3]); mol.FindChildren(children,ref[1],ref[2]); _vrotor.push_back(pair<OBAtom**,vector<int> > (atomlist,children)); _vres.push_back(rotor->GetResolution()); } // if the rotor list has ring bonds, build up an index if (rl.HasRingRotors()){ // go through rings // for each step of the path, see if there's a matching rotor vector<int> path; int pSize; vector<double> ringTorsions; vector<int> ringRotors; FOR_RINGS_OF_MOL(r, mol) { ringTorsions.clear(); ringRotors.clear(); pSize = r->Size(); if (pSize < 4) continue; // not rotatable path = r->_path; for (int j = 0; j < pSize; ++j) { double torsion = mol.GetTorsion(path[(j + pSize - 1) % pSize], path[(j + pSize) % pSize], path[(j + pSize + 1) % pSize], path[(j + pSize + 2) % pSize]); ringTorsions.push_back(torsion); // now check to see if any of these things are rotors int rotorIndex = -1; // not a rotor OBBond *bond = mol.GetBond(path[(j + pSize) % pSize], path[(j + pSize + 1) % pSize]); for (rotor = rl.BeginRotor(i);rotor;rotor = rl.NextRotor(i)) { if (bond != rotor->GetBond()) continue; // no match at all // Central bond matches, make sure 1..4 atoms are in the path rotor->GetDihedralAtoms(ref); if ( (ref[0] == path[(j + pSize - 1) % pSize] && ref[3] == path[(j + pSize + 2) % pSize]) || (ref[3] == path[(j + pSize - 1) % pSize] && ref[0] == path[(j + pSize + 2) % pSize]) ) { rotorIndex = rotor->GetIdx(); } } // end checking all the rotors ringRotors.push_back(rotorIndex); // could be -1 if it's not rotatable } _vringTors.push_back(ringTorsions); _vrings.push_back(ringRotors); } // finished with the rings