/*************************************************************************** codegen.h - description ------------------- begin : Tue Nov 18 01:45:35 2003 copyright : (C) 1999-2006 by Cavalli Andrea author : : cavalli $ date : : 2003/12/09 11:10:33 $ id : : coor.h,v 1.1.2.2 2003/12/09 11:10:33 cavalli Exp $ email : cavalli@bioc.unizh.ch amc82@cam.ac.uk **************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef __CODEGEN__ #define __CODEGEN__ #include #include #include namespace Almost { // string find_class_doc(string m, string c){ ZModule * zmod; if(SymbolTable::instance().is_modulename(m)){ zmod = (ZModule *)SymbolTable::current()[m]; ZExtClass * zclass; if(zmod->module_map.find(c)!=zmod->module_map.end()){ zclass = (ZExtClass*)zmod->module_map[c]; if(zclass->class_doc.find("__class__")!=zclass->class_doc.end()){ string s = zclass->class_doc["__class__"]; return s; } } } return string(); } string mdbload(string f, string & comment,bool verbose=true){ stringstream s,c; if(verbose){ c<<"\n\n// Load a Molecular database file MDB.
\n" <<"//

Very little can be done in almost, until a molecular database file MDB has been loaded.\n" <<"// Most of the scripts start, therefore, with this command.

\n"; //MDB desc string d = find_class_doc("mdb","MDB"); if(d!="") c<In this HOWTO, we assume that "<toppar of your distribution.

\n" ; comment = c.str(); } s<<"MDB = mdb.MDB(\""< Load a Protein data bank file PDB.
\n"; string d = find_class_doc("pdb","pdb"); if(d!="") c<\n"; comment = c.str(); } s<<"PDB = pdb.pdb(\""<Build a Molecules container and add a protein to it.
\n" <<"//

This operation is, unfortunately, a little bit more involved than one would expect.\n" <<"// The reason is that almost needs to associate to each atom,\n" <<"// bond, etc., the correct force field parameters. In order to do this, atom and fragment names\n" <<"// need to follow the naming convetions definend in the MDB file.\n" <<"// If this is not the case, it is possible to rename them. See HOWTO make a working PDB for more informations.
\n

" <<"//

Here we assume that the PDB you provide is \"correct\".

\n" <<"//

Structures used as starting point in a molecular dynamics simulation (MD)\n" <<"// should have a low energy, to avoid problems in the early stages of the \n" <<"// simulation.\n" <<"// See the tutorial HOWTO minimize a PDB and the documentation of the PDB, MDB and Molecules modules for more informations.

\n"; string d = find_class_doc("molecules","protein"); if(d!="") c<Build a Molecules container and add a protein to it.
\n" <<"//

The protein is build using the build_missing() function. This function differs from the standard build() one,\n" <<"// in what it does if one or more atoms are missing in the PDB.
" <<"// In fact, in case of a missing atom, the default build() function will fire an error message and exit.
\n" <<"// On the contrary, the build_missing() function will try to add all missing atoms\n" <<"// using the default amino-acid geometry as defined in the molecular database file.

\n" <<"//

Proteins build with build_missing() have usually a very high energy due to steric (van der Waals) clashes.\n" <<"// They should, therefore, always be minimized before using them as starting structure in a MD or a Monte Carlo simulation.
\n" <<"// See the tutorial HOWTO minimize a PDB and the documentation of the PDB, MDB and Molecules modules for more informations.

\n"; comment = c.str(); } s<<"p = molecules.protein(\""+p+"\");\n" <<"p.build_missing(PDB[0][0],MDB,\"NTER\",\"CTER\");\n" <<"mols = molecules.molecules();\n" <<"mols.add_protein(p);\n"; return s.str(); } string setupmdoptions( string &comment,bool verbose=true){ stringstream s,c; if(verbose){ c<<"\n\n// Setup the molecular dynamics simulation
\n" <<"//

In almost, a molecular dynamics simulation (MD) is controlled by a structure, mdoptions, that stores all\n" <<"// user setup.
\n" <<"// Molecular dynamics options are of two types: (1) force field options and (2) run options.\n" <<"// With the first category of options one can select the kind of force field to use in the simulation,\n" <<"// with the second group the details of the simulation such as number of steps, temperature, etc.\n" <<"// To make life easier, a convenience function initializes all force field options to their default values.\n" <<"// See the documentation of the md module for additional informations.

\n"; comment = c.str(); } s<<"opts = md.c19_defaults(md.SASA,md.BERE);\n" <<"opts.temp =330;\n" <<"opts.time_step =0.002;\n" <<"opts.nprint =1000;\n" <<"opts.steps = 10000;\n" <<"opts.gamma_water = 5;\n" <<"opts.rst = \"run_sasa.rst\";\n" <<"opts.trj = \"run_sasa.dcd\";\n" <<"opts.dat=\"run_sasa.dat\";\n" <<"print opts;\n"; return s.str(); } string setupenergyoptions(string & comment, bool verbose = true){ stringstream s,c; //coment here if(verbose){ c<<"\n\n// Create a energy_options() object to select the force field\n" <<"// to be used.
" <<"// An energy_options object can be created either using the class \n" <<"// constructor energy.energy_options() or the convenience functions:
\n" <<"// energy.c19_defaults(int) and energy.c22_defaults().
\n" <<"// See the documentation of the energy module for details.\n" ; comment = c.str(); } s<<"opts = energy.c19_defauts();\n"; return s.str(); } string runmd(string &comment, bool verbose = true){ stringstream s,c; if(verbose){ c<<"\n\n// And now run...
\n" <<"//

Now, create a molecular dynamics object and run the simulation.\n" <<"// That's it!

\n" <<"//

The last coordinates are stored in the res Molecules object and saved to\n" <<"// a file with the molecules.molecules2pdb() function.

\n" ; comment = c.str(); } s<<"MD = md.md();\n" <<"res = MD.run(mols,opts,MDB);\n" <<"molecules.molecules2pdb(res,\"res.pdb\");\n" ; return s.str(); } string runmini(string & comment, bool verbose = true){ stringstream s,c; if(verbose){ c<<"Now start the minimization. That's it.\n"; comment = c.str(); } s<<"minimize.sd(mols,opts,MDB,1000,0.001);\n"; return s.str(); } string calcene(string & comment, bool verbose = true){ stringstream s,c; if(verbose){ c<<"//

Now compute the enrgy and print the result.\n" <<"// The energy function return an object of type energy.data.

\n" ; string d =find_class_doc("energy","data"); if(d.size()!=0) c << d; comment = c.str(); } s<<"e = energy.energy(mols,opts,MDB);\n" <<"print e;\n" <<"//print e[\"vdw\"]; // To print a component.\n" ; return s.str(); } string mkhowtostr(string comment, string code){ boost::replace_all(comment,"//",""); // string res = "
"+comment +"
\n"+ // +"\n

"+code+"

\n"; string res = "

"+comment +"

\n"+ +"\n

"+code+"

\n"; return res; } } #endif // Local Variables: // mode:C++ // End: