23#include <unordered_set>
26#include <boost/lexical_cast.hpp>
44 return str.find_first_not_of(
"0123456789") == std::string::npos;
61 for (InteractionContainer::iterator i =
interactions_.begin();
68 bc_ = std::make_unique<OpenBox>();
78 for (
auto &bead_ :
beads_) {
86 res_offset = bead_.getResnr();
89 bname << bead_.getResnr() - res_offset + 1 <<
":"
91 mol->
AddBead(&bead_, bname.str());
92 if (++beadcount == nbeads) {
93 if (--nmolecules <= 0) {
112 for (
const auto &residue_ : top->
residues_) {
117 for (
const auto &bi : top->
beads_) {
118 string type = bi.getType();
119 CreateBead(bi.getSymmetry(), bi.getName(), type, bi.getResnr(),
120 bi.getMass(), bi.getQ());
124 for (
const auto &molecule_ : top->
molecules_) {
126 for (
Index i = 0; i < molecule_.BeadCount(); i++) {
127 Index beadid = molecule_.getBead(i)->getId();
144 string(
"RenameMolecules: num molecules smaller than"));
152 for (
auto &bead :
beads_) {
153 string type = bead.getType();
155 bead.setType(newname);
161 for (
auto &bead :
beads_) {
162 string type = bead.getType();
170 map<string, Index> nbeads;
173 map<string, Index>::iterator entry = nbeads.find(mol.getName());
174 if (entry != nbeads.end()) {
175 if (entry->second != mol.BeadCount()) {
177 "There are molecules which have the same name but different number "
179 "please check the section manual topology handling in the votca "
184 nbeads[mol.getName()] = mol.BeadCount();
202 map<string, vector<Interaction *>>::iterator iter =
205 return vector<Interaction *>();
215 unordered_set<Index> ids;
216 for (pair<const string, Index> type_and_id :
beadtypes_) {
217 ids.insert(type_and_id.second);
224 id = boost::lexical_cast<Index>(type);
225 assert(!ids.count(
id) &&
226 "The type passed in is a number and has already"
227 " been registered. It is likely that you are passing in numbers as "
228 "bead types as well as strings, choose one or the other do not mix "
229 "between using numbers and strings ");
232 while (ids.count(
id)) {
239 const Eigen::Vector3d &r_i,
const Eigen::Vector3d &r_j)
const {
240 return bc_->BCShortestConnection(r_i, r_j);
253 const Eigen::Matrix3d &box)
const {
257 if (box.isApproxToConstant(0)) {
259 }
else if ((box - Eigen::Matrix3d(box.diagonal().asDiagonal()))
260 .isApproxToConstant(0)) {
269 return bc_->getShortestBoxDimension();
void CreateExclusions(Topology *top)
base class for all interactions
const std::string & getGroup() const
void setGroupId(Index id)
information about molecules
void AddBead(Bead *bead, const std::string &name)
Add a bead to the molecule.
void setName(const std::string &name)
set the name of the molecule
const std::string & getName() const
get the name of the residue
topology of the whole system
Residue & CreateResidue(std::string name)
Create a new resiude.
BoundaryCondition::eBoxtype autoDetectBoxType(const Eigen::Matrix3d &box) const
void Cleanup()
Cleans up all the stored data.
std::unordered_map< std::string, Index > beadtypes_
bead types in the topology
void CreateMoleculesByRange(std::string name, Index first, Index nbeads, Index nmolecules)
create molecules based on blocks of atoms
void RenameMolecules(std::string range, std::string name)
rename all the molecules in range
Index getBeadTypeId(std::string type) const
Given a bead type this method returns the id associated with the type.
std::vector< Interaction * > InteractionsInGroup(const std::string &group)
void RenameBeadType(std::string name, std::string newname)
rename all the bead types
bool BeadTypeExist(std::string type) const
Determine if a bead type exists.
MoleculeContainer molecules_
molecules in the topology
std::map< std::string, Index > interaction_groups_
double ShortestBoxSize() const
return the shortest box size
const Eigen::Matrix3d & getBox() const
Bead * CreateBead(Bead::Symmetry symmetry, std::string name, std::string type, Index resnr, double m, double q)
Creates a new Bead.
ExclusionList exclusions_
InteractionContainer interactions_
bonded interactions in the topology
void AddBondedInteraction(Interaction *ic)
Molecule * getMolecule(const Index i)
void RegisterBeadType(std::string type)
Register the bead type with the topology object.
void SetBeadTypeMass(std::string name, double value)
set the mass of all the beads of a certain type
Molecule * CreateMolecule(std::string name)
Creates a new molecule.
std::unique_ptr< BoundaryCondition > bc_
void CheckMoleculeNaming(void)
checks weather molecules with the same name really contain the same number of beads
Eigen::Vector3d getDist(Index bead1, Index bead2) const
pbc correct distance of two beads
Residue & getResidue(const Index i)
Eigen::Vector3d BCShortestConnection(const Eigen::Vector3d &r_i, const Eigen::Vector3d &r_j) const
calculate shortest vector connecting two points
Bead * getBead(const Index i)
Returns a pointer to the bead with index i.
std::map< std::string, std::vector< Interaction * > > interactions_by_group_
BeadContainer beads_
beads in the topology
void CopyTopologyData(Topology *top)
copy topology data of different topology
ResidueContainer residues_
residues in the topology
bool is_digits(const std::string &str)
base class for all analysis tools