const CHARMMAtomTopology &CHARMMResidueTopologyBase::get_atom(std::string name) const { base::Vector<CHARMMAtomTopology>::const_iterator it = std::find_if(atoms_.begin(), atoms_.end(), atom_has_name(name)); if (it != atoms_.end()) { return *it; } else { IMP_THROW("atom " << name << " not found in residue topology", ValueException); } }
CHARMMAtomTopology &CHARMMResidueTopologyBase::get_atom(std::string name) { // A map would be more elegant here (avoid linear lookup time) but // a) atoms need to be ordered and b) residues rarely have more than ~30 atoms base::Vector<CHARMMAtomTopology>::iterator it = std::find_if(atoms_.begin(), atoms_.end(), atom_has_name(name)); if (it != atoms_.end()) { return *it; } else { IMP_THROW("atom " << name << " not found in residue topology", ValueException); } }
void CHARMMIdealResidueTopology::remove_atom(std::string name) { base::Vector<CHARMMAtomTopology>::iterator it = std::find_if(atoms_.begin(), atoms_.end(), atom_has_name(name)); if (it != atoms_.end()) { atoms_.erase(it); } else { IMP_THROW("atom " << name << " not found in residue topology", ValueException); } // Remove any bonds that refer to this atom bonds_.erase(std::remove_if(bonds_.begin(), bonds_.end(), bond_has_atom<2>(name)), bonds_.end()); angles_.erase(std::remove_if(angles_.begin(), angles_.end(), bond_has_atom<3>(name)), angles_.end()); dihedrals_.erase(std::remove_if(dihedrals_.begin(), dihedrals_.end(), bond_has_atom<4>(name)), dihedrals_.end()); impropers_.erase(std::remove_if(impropers_.begin(), impropers_.end(), bond_has_atom<4>(name)), impropers_.end()); }