39 #include "density_clustering.hpp"
41 #include "density_clustering_mpi.hpp"
44 #include "network_builder.hpp"
45 #include "state_filter.hpp"
52 #include <boost/program_options.hpp>
54 int main(
int argc,
char* argv[]) {
55 namespace b_po = boost::program_options;
56 std::string general_help =
57 "clustering - a classification framework for MD data\n"
60 " density: run density clustering\n"
61 " network: build network from density clustering results\n"
62 " mpp: run MPP (Most Probable Path) clustering\n"
63 " (based on density-results)\n"
64 " coring: boundary corrections for clustering results.\n"
65 " filter: filter phase space (e.g. dihedrals) for given state\n"
68 " clustering MODE --option1 --option2 ...\n"
70 "for a list of available options per mode, run with '-h' option, e.g.\n"
71 " clustering density -h\n"
74 enum {DENSITY, MPP, NETWORK, FILTER, CORING} mode;
77 std::cerr << general_help;
81 std::string str_mode(argv[1]);
82 if (str_mode.compare(
"density") == 0) {
84 }
else if (str_mode.compare(
"mpp") == 0) {
86 }
else if (str_mode.compare(
"network") == 0) {
88 }
else if (str_mode.compare(
"filter") == 0) {
90 }
else if (str_mode.compare(
"coring") == 0) {
93 std::cerr <<
"\nerror: unrecognized mode '" << str_mode <<
"'\n\n";
94 std::cerr << general_help;
98 b_po::variables_map args;
99 b_po::positional_options_description pos_opts;
101 b_po::options_description desc_dens (std::string(argv[1]).append(
103 "perform clustering of MD data based on phase space densities.\n"
104 "densities are approximated by counting neighboring frames inside\n"
105 "a n-dimensional hypersphere of specified radius.\n"
106 "distances are measured with n-dim P2-norm.\n"
109 desc_dens.add_options()
110 (
"help,h", b_po::bool_switch()->default_value(
false),
"show this help.")
111 (
"file,f", b_po::value<std::string>()->required(),
"input (required): phase space coordinates (space separated ASCII).")
112 (
"radius,r", b_po::value<float>(),
"parameter: hypersphere radius.")
114 (
"threshold,t", b_po::value<float>(),
"parameter: Free Energy threshold for clustering (FEL is normalized to zero).")
115 (
"threshold-screening,T", b_po::value<std::vector<float>>()->multitoken(),
116 "parameters: screening of free energy landscape. format: FROM STEP TO; e.g.: '-T 0.1 0.1 11.1'.\n"
117 "set -T -1 for default values: FROM=0.1, STEP=0.1, TO=MAX_FE.\n"
118 "parameters may be given partially, e.g.: -T 0.2 0.4 to start at 0.2 and go to MAX_FE at steps 0.4.\n"
119 "for threshold-screening, --output denotes the basename only. output files will have the"
120 " current threshold limit appended to the given filename.")
121 (
"output,o", b_po::value<std::string>(),
"output (optional): clustering information.")
122 (
"input,i", b_po::value<std::string>(),
"input (optional): initial state definition.")
123 (
"radii,R", b_po::value<std::vector<float>>()->multitoken(),
"parameter: list of radii for population/free energy calculations "
124 "(i.e. compute populations/free energies for several radii in one go).")
125 (
"population,p", b_po::value<std::string>(),
"output (optional): population per frame (if -R is set: this defines only the basename).")
126 (
"free-energy,d", b_po::value<std::string>(),
"output (optional): free energies per frame (if -R is set: this defines only the basename).")
127 (
"free-energy-input,D", b_po::value<std::string>(),
"input (optional): reuse free energy info.")
128 (
"nearest-neighbors,b", b_po::value<std::string>(),
"output (optional): nearest neighbor info.")
129 (
"nearest-neighbors-input,B", b_po::value<std::string>(),
"input (optional): reuse nearest neighbor info.")
131 (
"only-initial,I", b_po::bool_switch()->default_value(
false),
132 "only assign initial (i.e. low free energy / high density) frames to clusters. "
133 "leave unclustered frames as state '0'.")
134 (
"nthreads,n", b_po::value<int>()->default_value(0),
135 "number of OpenMP threads. default: 0; i.e. use OMP_NUM_THREADS env-variable.")
136 (
"verbose,v", b_po::bool_switch()->default_value(
false),
"verbose mode: print runtime information to STDOUT.")
139 b_po::options_description desc_mpp (std::string(argv[1]).append(
141 "TODO: description for MPP"
144 desc_mpp.add_options()
145 (
"help,h", b_po::bool_switch()->default_value(
false),
"show this help.")
146 (
"input,i", b_po::value<std::string>()->required(),
"input (required): initial state definition.")
147 (
"free-energy-input,D", b_po::value<std::string>()->required(),
"input (required): reuse free energy info.")
148 (
"lagtime,l", b_po::value<int>()->required(),
"input (required): lagtime in units of frame numbers.")
149 (
"qmin-from", b_po::value<float>()->default_value(0.01,
"0.01"),
"initial Qmin value (default: 0.01).")
150 (
"qmin-to", b_po::value<float>()->default_value(1.0,
"1.00"),
"final Qmin value (default: 1.00).")
151 (
"qmin-step", b_po::value<float>()->default_value(0.01,
"0.01"),
"Qmin stepping (default: 0.01).")
152 (
"concat-nframes", b_po::value<std::size_t>(),
153 "input (parameter): no. of frames per (equally sized) sub-trajectory for concatenated trajectory files.")
154 (
"concat-limits", b_po::value<std::string>(),
155 "input (file): file with frame ids (base 0) of first frames per (not equally sized) sub-trajectory for concatenated trajectory files.")
157 (
"basename", b_po::value<std::string>()->default_value(
"mpp"),
"basename for output files (default: 'mpp').")
158 (
"nthreads,n", b_po::value<int>()->default_value(0),
159 "number of OpenMP threads. default: 0; i.e. use OMP_NUM_THREADS env-variable.")
160 (
"verbose,v", b_po::bool_switch()->default_value(
false),
"verbose mode: print runtime information to STDOUT.")
163 b_po::options_description desc_network (std::string(argv[1]).append(
165 "TODO: description for network builder"
168 desc_network.add_options()
169 (
"help,h", b_po::bool_switch()->default_value(
false),
"show this help.")
171 (
"basename,b", b_po::value<std::string>()->default_value(
"clust.\%0.2f"),
172 "(optional): basename of input files (default: clust.\%0.2f).")
173 (
"min", b_po::value<float>()->default_value(0.1f,
"0.10"),
"(optional): minimum free energy (default: 0.10).")
174 (
"max", b_po::value<float>()->default_value(0.0f,
"0"),
"(optional): maximum free energy (default: 0; i.e. max. available).")
175 (
"step", b_po::value<float>()->default_value(0.1f,
"0.10"),
"(optional): free energy stepping (default: 0.10).")
176 (
"minpop,p", b_po::value<std::size_t>()->default_value(1),
177 "(optional): minimum population of node to be considered for network (default: 1).")
179 (
"verbose,v", b_po::bool_switch()->default_value(
false),
"verbose mode: print runtime information to STDOUT.")
182 b_po::options_description desc_filter (std::string(argv[1]).append(
184 "filter phase space (e.g. dihedral angles, cartesian coords, etc.) for given state."
187 desc_filter.add_options()
188 (
"help,h", b_po::bool_switch()->default_value(
false),
190 (
"states,s", b_po::value<std::string>()->required(),
191 "(required): file with state information (i.e. clustered trajectory).")
192 (
"coords,c", b_po::value<std::string>(),
193 "file with coordinates (either plain ASCII or GROMACS' xtc).")
194 (
"output,o", b_po::value<std::string>(),
196 (
"state,S", b_po::value<std::size_t>(),
197 "state id of selected state.")
199 (
"list", b_po::bool_switch()->default_value(
false),
200 "list states and their populations")
203 b_po::options_description desc_coring (std::string(argv[1]).append(
205 "compute boundary corrections for clustering results."
208 desc_coring.add_options()
209 (
"help,h", b_po::bool_switch()->default_value(
false),
212 (
"states,s", b_po::value<std::string>()->required(),
213 "(required): file with state information (i.e. clustered trajectory")
214 (
"windows,w", b_po::value<std::string>()->required(),
215 "(required): file with window sizes."
216 "format is space-separated lines of\n\n"
217 "STATE_ID WINDOW_SIZE\n\n"
218 "use * as STATE_ID to match all (other) states.\n"
223 "matches 40 frames to state 3, 60 frames to state 4 and 20 frames to all the other states")
224 (
"output,o", b_po::value<std::string>(),
225 "(optional): cored trajectory")
226 (
"distribution,d", b_po::value<std::string>(),
227 "(optional): write waiting time distributions to file.")
228 (
"cores,c", b_po::value<std::string>(),
229 "(optional): write core information to file, i.e. trajectory with state name if in core region or -1 if not in core region")
230 (
"concat-nframes", b_po::value<std::size_t>(),
231 "input (optional parameter): no. of frames per (equally sized) sub-trajectory for concatenated trajectory files.")
232 (
"concat-limits", b_po::value<std::string>(),
233 "input (optional, file): file with frame ids (base 0) of first frames per (not equally sized) sub-trajectory for concatenated trajectory files.")
235 (
"verbose,v", b_po::bool_switch()->default_value(
false),
236 "verbose mode: print runtime information to STDOUT.")
239 b_po::options_description desc;
248 desc.add(desc_network);
251 desc.add(desc_filter);
254 desc.add(desc_coring);
257 std::cerr <<
"error: unknown mode. this should never happen." << std::endl;
261 b_po::store(b_po::command_line_parser(argc, argv).options(desc).run(), args);
263 }
catch (b_po::error& e) {
264 if ( ! args[
"help"].as<bool>()) {
265 std::cerr <<
"\nerror parsing arguments:\n\n" << e.what() <<
"\n\n" << std::endl;
267 std::cerr << desc << std::endl;
270 if (args[
"help"].as<bool>()) {
271 std::cout << desc << std::endl;
275 if (args.count(
"verbose")) {
280 if (args.count(
"nthreads")) {
281 n_threads = args[
"nthreads"].as<
int>();
284 omp_set_num_threads(n_threads);
305 Clustering::Coring::main(args);
308 std::cerr <<
"error: unknown mode. this should never happen." << std::endl;
bool verbose
global flag: use verbose output?
void main(boost::program_options::variables_map args)
void main(boost::program_options::variables_map args)
void main(boost::program_options::variables_map args)
void main(boost::program_options::variables_map args)
void main(boost::program_options::variables_map args)