Residue ResidueSubstitutionTable::replaceResidue(Residue &_res) { // If this residue isn't in our list of residues to be replaced, // just return it! if( !isResidueInSubstitutionTable(_res) ) return _res; // Clone the current residue, and find the replacement info. Residue newRes; ReplacementInfo ri = find( _res.getResidueName() )->second; string newName = ri.first; AtomHash ah = ri.second; // Loop over all of the atoms in the residue. for(int i=0; i < _res.size(); ++i ){ Atom &currAtom = _res.getAtom(i); string currAtomName = currAtom.getName(); // If the current atom is in the list of atoms we should keep, // add it. if( ah.find(currAtomName) != ah.end() ) newRes.addAtom( currAtom ); } // Set the new name of the residue. newRes.setResidueNumber( _res.getResidueNumber() ); newRes.setResidueIcode( _res.getResidueIcode() ); newRes.setChainId( _res.getChainId() ); newRes.setResidueName( newName ); return newRes; }
bool ResidueSubstitutionTable::isResidueInSubstitutionTable(Residue &_res) { return( find(_res.getResidueName()) != end() ); }