23#include <boost/format.hpp>
42 out <<
"Create a dlpoly topology template based on an existing (atomistic) "
44 <<
"a mapping xml-file. The created template file needs to be "
45 "inspected and amended by the user!\n\n"
47 <<
"* csg_dlptopol --top .dlpf --out .dlpf --cg cg-map.xml\n convert "
48 "FIELD to FIELD_CGV using cg-map.xml\n"
49 <<
"* csg_dlptopol --top FA-dlpoly.dlpf --out CG-dlpoly.dlpf --cg "
51 <<
"* csg_dlptopol --top FA-gromacs.tpr --out FA-dlpoly.dlpf "
80 " output topology in dlpoly format");
86 string fname =
OptionsMap()[
"top"].as<
string>();
88 if (fname ==
".dlpf") {
92 cout <<
"input file-name: " << fname << endl;
97 cout <<
"output file-name given: " << fname << endl;
100 if (fname ==
".dlpf") {
105 cout <<
"output file-name actual: " << fname << endl;
107 cout <<
"output file-name: " << fname << endl;
113 std::vector<const Molecule *> MolecularTypes;
117 vector<votca::Index> nummols;
119 vector<string> vdw_pairs;
123 for (
const auto &mol : mols) {
128 if (mol.getName() == prv_mol_name) {
133 nummols.push_back(prv_mol_number);
135 prv_mol_name = mol.getName();
137 cout <<
"'" << mol.getName() <<
"' added to CG molecular types" << endl;
139 MolecularTypes.push_back(&mol);
143 for (
votca::Index ib1 = 0; ib1 < mol.BeadCount(); ib1++) {
144 string bead_name1 = mol.getBead(ib1)->getType();
145 bead_name1 = bead_name1.substr(
147 bead_name1.find_first_of(
"#"));
149 for (
const auto &MolecularType : MolecularTypes) {
151 for (
votca::Index ib2 = 0; ib2 < MolecularType->BeadCount(); ib2++) {
153 string bead_name2 = MolecularType->getBead(ib2)->getType();
154 bead_name2 = bead_name2.substr(
155 0, bead_name2.find_first_of(
"#"));
158 stringstream ss_bp1, ss_bp2;
160 ss_bp1 << boost::format(
"%8s%8s") % bead_name1 % bead_name2;
161 ss_bp2 << boost::format(
"%8s%8s") % bead_name2 % bead_name1;
163 bool is_new_pair =
true;
165 for (
const auto &vdw_pair : vdw_pairs) {
166 if (ss_bp1.str() == vdw_pair || ss_bp2.str() == vdw_pair) {
172 vdw_pairs.push_back(ss_bp1.str());
174 cout <<
"'" << ss_bp1.str() <<
"' added to CG vdw pairs" << endl;
181 nummols.push_back(prv_mol_number);
183 if (MolecularTypes.size() > 1) {
184 cout <<
"WARNING: creation of topology for multiple molecular types "
185 "is experimental at this stage\n";
191 fl <<
"From VOTCA with love"
192 <<
" # check/amend this file if needed!\n";
194 fl <<
"molecular types " << MolecularTypes.size() << endl;
202 if (vdw_pairs.size() > 0) {
204 fl <<
"vdw " << vdw_pairs.size() << endl;
206 for (
const auto &vdw_pair : vdw_pairs) {
207 fl << vdw_pair <<
" tab 1.00000 0.00000\n";
211 fl <<
"close" << endl;
213 cout <<
"Created template for dlpoly topology - please, check & amend if "
222 out <<
"atoms " << cg.
BeadCount() << endl;
223 out <<
"# name mass charge nrept ifrozen (optional: ngroup, index, "
224 "name/type, type/residue, index/res-ID) \n";
231 bname = bname.substr(
232 0, bname.find_first_of(
"#"));
233 btype = btype.substr(
234 0, btype.find_first_of(
"#"));
236 out << boost::format(
"%8s %10f %10f 1 0 1 %10d %8s %8s %10d \n") %
237 btype % b->
getMass() % b->
getQ() % (i + 1) % btype % bname %
252 if (nb != ic->BeadCount()) {
254 if (sout.str() !=
"") {
255 out << n_entries << endl << sout.str();
261 nb = ic->BeadCount();
273 string err =
"cannot handle number of beads in interaction:";
274 err += to_string(ic->getMolecule() + 1) +
":" + ic->getGroup();
275 err +=
":" + to_string(ic->getIndex() + 1);
276 throw runtime_error(err);
286 sout << ic->getBeadId(i) + 1 <<
" ";
288 sout <<
" 1.00000 0.00000"
290 sout << to_string(ic->getMolecule() + 1);
291 sout <<
":" + ic->getGroup();
292 sout <<
":" + to_string(ic->getIndex() + 1) << endl;
294 if (sout.str() !=
"") {
295 out << n_entries << endl << sout.str();
302 out <<
"nummols " << nummol << endl;
307 out <<
"finish" << endl;
310int main(
int argc,
char **argv) {
312 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