26 #include "coords_file/coords_file.hpp"
28 #include <boost/program_options.hpp>
34 #include "state_filter.hpp"
37 int io_error(std::string fname) {
38 std::cerr <<
"error: cannot open file " << fname <<
"." << std::endl;
44 namespace Clustering {
47 main(boost::program_options::variables_map args) {
49 std::string fname_states = args[
"states"].as<std::string>();
50 std::vector<std::size_t> states;
52 std::ifstream ifs(fname_states);
54 exit(io_error(fname_states));
60 states.push_back(buf);
65 if (args[
"list"].as<bool>()) {
66 std::priority_queue<std::pair<std::size_t, std::size_t>> pops;
68 std::set<std::size_t> state_ids(states.begin(), states.end());
69 for (std::size_t
id: state_ids) {
70 std::size_t pop = std::count(states.begin(), states.end(), id);
73 while ( ! pops.empty()) {
74 auto pop_id = pops.top();
76 std::cout << pop_id.second <<
" " << pop_id.first <<
"\n";
80 std::size_t selected_state = args[
"state"].as<std::size_t>();
81 CoordsFile::FilePointer coords_in = CoordsFile::open(args[
"coords"].as<std::string>(),
"r");
82 CoordsFile::FilePointer coords_out = CoordsFile::open(args[
"output"].as<std::string>(),
"w");
83 for (std::size_t s: states) {
84 if (s == selected_state) {
85 coords_out->write(coords_in->next());
void main(boost::program_options::variables_map args)