26#include <boost/lexical_cast.hpp>
49using boost::lexical_cast;
70 if (options.
exists(
"cg_bonded")) {
81 beaddef->
name_ = p->get(
"name").as<
string>();
82 beaddef->
type_ = p->get(
"type").as<
string>();
83 beaddef->
mapping_ = p->get(
"mapping").as<
string>();
84 if (p->exists(
"symmetry")) {
88 }
else if (sym == 3) {
91 throw std::runtime_error(
92 "Only beads with spherical(1) or ellipsoidal(3) symmetry "
100 throw std::runtime_error(
string(
"bead name ") + beaddef->
name_ +
101 " not unique in mapping");
103 beads_.push_back(beaddef);
115 maps_[p->get(
"name").as<
string>()] = p;
124 for (
auto &bead_def :
beads_) {
126 string type = bead_def->type_;
130 Bead *bead = top.
CreateBead(bead_def->symmetry_, bead_def->name_, type,
136 map<string, string> had_iagroup;
139 std::list<Index> atoms;
140 string iagroup = prop->get(
"name").as<
string>();
142 if (had_iagroup[iagroup] ==
"yes") {
144 string(
"double occurence of interactions with name ") + iagroup);
146 had_iagroup[iagroup] =
"yes";
149 for (
auto &atom : tok) {
153 string(
"error while trying to create bonded interaction, "
155 atom +
" not found"));
162 if (prop->name() ==
"bond") {
164 }
else if (prop->name() ==
"angle") {
166 }
else if (prop->name() ==
"dihedral") {
170 if ((atoms.size() % NrBeads) != 0) {
171 throw runtime_error(
"Number of atoms in interaction '" +
172 prop->get(
"name").as<
string>() +
173 "' is not a multiple of " +
174 lexical_cast<string>(NrBeads) +
"! Missing beads?");
178 while (!atoms.empty()) {
181 if (prop->name() ==
"bond") {
182 ic =
new IBond(atoms);
183 }
else if (prop->name() ==
"angle") {
185 }
else if (prop->name() ==
"dihedral") {
188 throw runtime_error(
"unknown bonded type in map: " + prop->name());
205 "number of beads for cg molecule and mapping definition do "
206 "not match, check your molecule naming.");
210 for (
auto &bead :
beads_) {
214 throw runtime_error(
string(
"mapping error: reference molecule " +
215 bead->name_ +
" does not exist"));
220 throw runtime_error(
string(
"mapping " + bead->mapping_ +
" not found"));
225 switch (bead->symmetry_) {
233 throw runtime_error(
string(
"unknown symmetry in bead definition!"));
243 map<string, beaddef_t *>::iterator iter =
beads_by_name_.find(name);
245 std::cout <<
"cannot find: <" << name <<
"> in " <<
name_ <<
"\n";
248 return (*iter).second;
252 map<string, tools::Property *>::iterator iter =
maps_.find(name);
253 if (iter ==
maps_.end()) {
254 std::cout <<
"cannot find map " << name <<
"\n";
257 return (*iter).second;
std::string getName() const
Gets the name of the bead.
virtual void Initialize(const Molecule *in, Bead *out, tools::Property *opts_bead, tools::Property *opts_map)=0
void ParseMapping(tools::Property &options)
std::map< std::string, tools::Property * > maps_
Map CreateMap(const Molecule &in, Molecule &out)
std::vector< beaddef_t * > beads_
void Load(std::string filename)
std::map< std::string, beaddef_t * > beads_by_name_
beaddef_t * getBeadByName(const std::string &name)
std::vector< tools::Property * > bonded_
Molecule * CreateMolecule(Topology &top)
tools::Property * getMapByName(const std::string &name)
void ParseBonded(tools::Property &options)
void ParseTopology(tools::Property &options)
void ParseBeads(tools::Property &options)
base class for all interactions
void setGroup(const std::string &group)
void setIndex(const Index &index)
void setMolecule(const Index &mol)
information about molecules
Index getBeadIdByName(const std::string &name) const
void AddBead(Bead *bead, const std::string &name)
Add a bead to the molecule.
Bead * getBead(Index bead)
get the id of a bead in the molecule
Index getBeadByName(const std::string &name) const
find a bead by it's name
void AddInteraction(Interaction *ic)
Add an interaction to the molecule.
Index BeadCount() const
get the number of beads in the molecule
Index getId() const
get the molecule ID
Index getId() const
get the name of the residue
topology of the whole system
Residue & CreateResidue(std::string name)
Create a new resiude.
bool BeadTypeExist(std::string type) const
Determine if a bead type exists.
Bead * CreateBead(Bead::Symmetry symmetry, std::string name, std::string type, Index resnr, double m, double q)
Creates a new Bead.
void AddBondedInteraction(Interaction *ic)
void RegisterBeadType(std::string type)
Register the bead type with the topology object.
Molecule * CreateMolecule(std::string name)
Creates a new molecule.
base class for all analysis tools
tools::Property * options_