Pteros  2.0
Molecular modeling library for human beings!
compiled_analysis_task.h
1 /*
2  * This file is a part of
3  *
4  * ============================================
5  * ### Pteros molecular modeling library ###
6  * ============================================
7  *
8  * https://github.com/yesint/pteros
9  *
10  * (C) 2009-2021, Semen Yesylevskyy
11  *
12  * All works, which use Pteros, should cite the following papers:
13  *
14  * 1. Semen O. Yesylevskyy, "Pteros 2.0: Evolution of the fast parallel
15  * molecular analysis library for C++ and python",
16  * Journal of Computational Chemistry, 2015, 36(19), 1480–1488.
17  * doi: 10.1002/jcc.23943.
18  *
19  * 2. Semen O. Yesylevskyy, "Pteros: Fast and easy to use open-source C++
20  * library for molecular analysis",
21  * Journal of Computational Chemistry, 2012, 33(19), 1632–1636.
22  * doi: 10.1002/jcc.22989.
23  *
24  * This is free software distributed under Artistic License:
25  * http://www.opensource.org/licenses/artistic-license-2.0.php
26  *
27 */
28 
29 
30 
31 
32 
33 #ifndef COMPILED_ANALYSIS_TASK_H
34 #define COMPILED_ANALYSIS_TASK_H
35 
36 #include "pteros/analysis/trajectory_reader.h"
37 #include "pteros/analysis/task_plugin.h"
38 #include "pteros/core/pteros_error.h"
39 #include "pteros/core/logging.h"
40 
41 using namespace pteros;
42 using namespace std;
43 
44 // Skeleton of the driver program
45 
46 #define COMPILED_ANALYSIS_TASK(_name, _collector)\
47 int main(int argc, char** argv){\
48  try {\
49  Options options;\
50  parse_command_line(argc,argv,options);\
51  Trajectory_reader engine(options);\
52  auto task = new _name(options);\
53  engine.add_task(task);\
54  engine.register_collector(_collector);\
55  cout << "-------------------------------------------------------------" << endl;\
56  cout << " This is stand-alone Pteros analysis plugin '" #_name "'" << endl;\
57  cout << "-------------------------------------------------------------" << endl;\
58  if(!options.has("f") && !options.has("help")){\
59  cout << "Usage:" << endl;\
60  cout << "\tpteros_" #_name " -f <files> <task options>" << endl;\
61  cout << "\n\tFor specific task options use '-help task'" << endl;\
62  cout << "\tFor trajectory processing options use '-help traj'" << endl;\
63  cout << "\tFor all available options use '-help all' or just '-help'" << endl;\
64  return 1;\
65  }\
66  if(options.has("help")){\
67  string help = options("help","").as_string();\
68  if(help=="traj"){\
69  cout << engine.help() << endl;\
70  } else if(help=="task"){\
71  cout << task->help() << endl;\
72  } else {\
73  cout << task->help() << endl << endl;\
74  cout << engine.help() << endl;\
75  }\
76  return 1;\
77  }\
78  engine.run();\
79  } catch (const std::exception& e) { \
80  LOG()->error(e.what()); \
81  } catch(...) { \
82  LOG()->error("Unknown error"); \
83  }\
84 }
85 
86 
87 #endif
88 
89 
90 
91