votca 2024.1-dev
Loading...
Searching...
No Matches
cgengine.cc
Go to the documentation of this file.
1/*
2 * Copyright 2009-2021 The VOTCA Development Team (http://www.votca.org)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18// Standard includes
19#include <fstream>
20#include <memory>
21
22// VOTCA includes
24
25// Local VOTCA includes
26#include "votca/csg/cgengine.h"
27#include "votca/csg/version.h"
28
29namespace votca {
30namespace csg {
31
32using namespace std;
33
34namespace po = boost::program_options;
35
36CGEngine::CGEngine() = default;
37
41std::unique_ptr<TopologyMap> CGEngine::CreateCGTopology(const Topology &in,
42 Topology &out) {
43 const MoleculeContainer &mols = in.Molecules();
44 auto m = std::make_unique<TopologyMap>(&in, &out);
45 for (const auto &mol : mols) {
46 if (IsIgnored(mol.getName())) {
47 continue;
48 }
49 CGMoleculeDef *def = getMoleculeDef(mol.getName());
50 if (!def) {
51 cout << "--------------------------------------\n"
52 << "WARNING: unknown molecule \"" << mol.getName() << "\" with id "
53 << mol.getId() << " in topology" << endl
54 << "molecule will not be mapped to CG representation\n"
55 << "Check weather a mapping file for all molecule exists, was "
56 "specified in --cg "
57 << "separated by ; and the ident tag in xml-file matches the "
58 "molecule name\n"
59 << "--------------------------------------\n";
60 continue;
61 }
62 Molecule *mcg = def->CreateMolecule(out);
63 Map map = def->CreateMap(mol, *mcg);
64 m->AddMoleculeMap(std::move(map));
65 }
67 return m;
68}
69
70void CGEngine::LoadMoleculeType(const string &filename) {
71 tools::Tokenizer tok(filename, ";");
72
73 for (auto &word : tok) {
74 auto def = std::make_unique<CGMoleculeDef>();
75 string file = word;
76 boost::trim(file);
77 def->Load(file);
78 molecule_defs_[def->getIdent()] = std::move(def);
79 }
80}
81
82} // namespace csg
83} // namespace votca
std::unique_ptr< TopologyMap > CreateCGTopology(const Topology &in, Topology &out)
Definition cgengine.cc:41
CGMoleculeDef * getMoleculeDef(const std::string &name)
Definition cgengine.h:93
std::map< std::string, std::unique_ptr< CGMoleculeDef > > molecule_defs_
Definition cgengine.h:88
bool IsIgnored(const std::string &ident)
checks whether molecule is ignored
Definition cgengine.h:108
void LoadMoleculeType(const std::string &filename)
Definition cgengine.cc:70
definition of a coarse grained molecule
Map CreateMap(const Molecule &in, Molecule &out)
Molecule * CreateMolecule(Topology &top)
information about molecules
Definition molecule.h:45
topology of the whole system
Definition topology.h:81
MoleculeContainer & Molecules()
Definition topology.h:182
break string into words
Definition tokenizer.h:72
STL namespace.
boost::container::deque< Molecule, void, block_molecule_4x_t > MoleculeContainer
Definition topology.h:67
base class for all analysis tools
Definition basebead.h:33