23#include <boost/format.hpp>
43 out <<
"Create a dlpoly topology template based on an existing (atomistic) "
45 <<
"a mapping xml-file. The created template file needs to be "
46 "inspected and amended by the user!\n\n"
48 <<
"* csg_dlptopol --top .dlpf --out .dlpf --cg cg-map.xml\n convert "
49 "FIELD to FIELD_CGV using cg-map.xml\n"
50 <<
"* csg_dlptopol --top FA-dlpoly.dlpf --out CG-dlpoly.dlpf --cg "
52 <<
"* csg_dlptopol --top FA-gromacs.tpr --out FA-dlpoly.dlpf "
81 " output topology in dlpoly format");
87 string fname =
OptionsMap()[
"top"].as<
string>();
89 if (fname ==
".dlpf") {
93 cout <<
"input file-name: " << fname << endl;
98 cout <<
"output file-name given: " << fname << endl;
101 if (fname ==
".dlpf") {
106 cout <<
"output file-name actual: " << fname << endl;
108 cout <<
"output file-name: " << fname << endl;
114 std::vector<const Molecule *> MolecularTypes;
118 vector<votca::Index> nummols;
120 vector<string> vdw_pairs;
124 for (
const auto &mol : mols) {
129 if (mol.getName() == prv_mol_name) {
134 nummols.push_back(prv_mol_number);
136 prv_mol_name = mol.getName();
138 cout <<
"'" << mol.getName() <<
"' added to CG molecular types" << endl;
140 MolecularTypes.push_back(&mol);
144 for (
votca::Index ib1 = 0; ib1 < mol.BeadCount(); ib1++) {
145 string bead_name1 = mol.getBead(ib1)->getType();
146 bead_name1 = bead_name1.substr(
148 bead_name1.find_first_of(
"#"));
150 for (
const auto &MolecularType : MolecularTypes) {
152 for (
votca::Index ib2 = 0; ib2 < MolecularType->BeadCount(); ib2++) {
154 string bead_name2 = MolecularType->getBead(ib2)->getType();
155 bead_name2 = bead_name2.substr(
156 0, bead_name2.find_first_of(
"#"));
159 stringstream ss_bp1, ss_bp2;
161 ss_bp1 << format(
"%8s%8s") % bead_name1 % bead_name2;
162 ss_bp2 << format(
"%8s%8s") % bead_name2 % bead_name1;
164 bool is_new_pair =
true;
166 for (
const auto &vdw_pair : vdw_pairs) {
167 if (ss_bp1.str() == vdw_pair || ss_bp2.str() == vdw_pair) {
173 vdw_pairs.push_back(ss_bp1.str());
175 cout <<
"'" << ss_bp1.str() <<
"' added to CG vdw pairs" << endl;
182 nummols.push_back(prv_mol_number);
184 if (MolecularTypes.size() > 1) {
185 cout <<
"WARNING: creation of topology for multiple molecular types "
186 "is experimental at this stage\n";
192 fl <<
"From VOTCA with love"
193 <<
" # check/amend this file if needed!\n";
195 fl <<
"molecular types " << MolecularTypes.size() << endl;
203 if (vdw_pairs.size() > 0) {
205 fl <<
"vdw " << vdw_pairs.size() << endl;
207 for (
const auto &vdw_pair : vdw_pairs) {
208 fl << vdw_pair <<
" tab 1.00000 0.00000\n";
212 fl <<
"close" << endl;
214 cout <<
"Created template for dlpoly topology - please, check & amend if "
223 out <<
"atoms " << cg.
BeadCount() << endl;
224 out <<
"# name mass charge nrept ifrozen (optional: ngroup, index, "
225 "name/type, type/residue, index/res-ID) \n";
232 bname = bname.substr(
233 0, bname.find_first_of(
"#"));
234 btype = btype.substr(
235 0, btype.find_first_of(
"#"));
237 out << format(
"%8s %10f %10f 1 0 1 %10d %8s %8s %10d \n") %
238 btype % b->
getMass() % b->
getQ() % (i + 1) % btype % bname %
253 if (nb != ic->BeadCount()) {
255 if (sout.str() !=
"") {
256 out << n_entries << endl << sout.str();
262 nb = ic->BeadCount();
274 string err =
"cannot handle number of beads in interaction:";
275 err += to_string(ic->getMolecule() + 1) +
":" + ic->getGroup();
276 err +=
":" + to_string(ic->getIndex() + 1);
277 throw runtime_error(err);
287 sout << ic->getBeadId(i) + 1 <<
" ";
289 sout <<
" 1.00000 0.00000"
291 sout << to_string(ic->getMolecule() + 1);
292 sout <<
":" + ic->getGroup();
293 sout <<
":" + to_string(ic->getIndex() + 1) << endl;
295 if (sout.str() !=
"") {
296 out << n_entries << endl << sout.str();
303 out <<
"nummols " << nummol << endl;
308 out <<
"finish" << endl;
311int main(
int argc,
char **argv) {
313 return app.
Exec(argc, argv);
class for writing dlpoly topology files
void HelpText(ostream &out) override
help text of application without version information
void WriteMolecularType(ostream &out, const Molecule &cg, votca::Index nummol)
bool DoMapping(void) override
overload and return true to enable mapping command line options
string ProgramName() override
program name
bool EvaluateOptions(void) override
Process command line options.
void WriteMoleculeAtoms(ostream &out, const Molecule &cg)
bool EvaluateTopology(Topology *top, Topology *top_ref) override
called after topology was loaded
void WriteMoleculeInteractions(ostream &out, const Molecule &cg)
void WriteVDWInteractions(ostream &out, const Molecule &cg)
void Initialize(void) override
Initialize application data.
virtual const std::string getType() const noexcept
std::string getName() const
Gets the name of the bead.
virtual const double & getMass() const noexcept
virtual const double & getQ() const
bool EvaluateOptions() override
Process command line options.
void Initialize() override
Initialize application data.
base class for all interactions
information about molecules
Bead * getBead(Index bead)
get the id of a bead in the molecule
std::vector< Interaction * > Interactions()
const std::string & getName() const
get the name of the molecule
Index BeadCount() const
get the number of beads in the molecule
topology of the whole system
MoleculeContainer & Molecules()
int main(int argc, char **argv)
boost::container::deque< Molecule, void, block_molecule_4x_t > MoleculeContainer