<commit_before>#include <iostream>
#include <string>

#include "acmacs-base/argc-argv.hh"
#include "acmacs-base/quicklook.hh"
#include "seqdb/seqdb.hh"

#include "signature-page.hh"
#include "settings.hh"

using namespace std::string_literals;

// ----------------------------------------------------------------------

int main(int argc, const char *argv[])
{
    try {
        argc_argv args(argc, argv, {
                {"--db-dir", ""},
                {"--seqdb", ""},

                {"-s", argc_argv::strings{}}, //value<std::vector<std::string>>(&aOptions.settings_filename), "signature page drawing settings (json) filename")
                {"--init-settings", ""}, // value<std::string>(&aOptions.init_settings_filename), "initialize signature page drawing settings (json) filename")
                {"--report-cumulative", false}, // bool_switch(&aOptions.report_cumulative)->default_value(false), "report cumulative edge lengths for leaf nodes of the tree")
                {"--report-hz-section_antigens", false}, // bool_switch(&aOptions.report_antigens_in_hz_sections)->default_value(false), "report antigens in each hz section")
                {"--list-ladderized", false}, // bool_switch(&aOptions.list_ladderized)->default_value(false), "list strain names after ladderizing")
                {"--no-draw", false}, // bool_switch(&aOptions.no_draw)->default_value(false), "do not generate pdf")
                {"--chart", ""}, // value<std::string>(&aOptions.chart_filename), "path to a chart for the signature page")

                {"--open", false},
                {"-v", false},
                {"--verbose", false},
                {"-h", false},
                {"--help", false},
            });

          // {"tree", value<std::string>(&aOptions.tree_filename)->required(), "path to tree to draw")
          // ("output,o", value<std::string>(&aOptions.output_filename)->required(), "output pdf")

        if (args["-h"] || args["--help"] || args.number_of_arguments() != 2) {
            throw std::runtime_error("Usage: "s + args.program() + " [options] <tree.json> <output.pdf>\n" + args.usage_options());
        }
        const bool verbose = args["-v"] || args["--verbose"];
        seqdb::setup_dbs(args["--db-dir"], verbose);
        if (args["--seqdb"])
            seqdb::setup(args["--seqdb"], verbose);

        SignaturePageDraw signature_page;

        auto load_settings = [&signature_page,verbose](argc_argv::strings aFilenames) {
            for (auto fn: aFilenames) {
                if (verbose)
                    std::cerr << "DEBUG: reading settings from " << fn << '\n';
                signature_page.load_settings(fn);
            }
        };
        if (args["-s"])
            load_settings(args["-s"]);

        signature_page.tree(args[0]);
        if (args["--chart"])
            signature_page.chart(args["--chart"]); // before make_surface!
        signature_page.make_surface(args[1], args["--init-settings"], !args["--no-draw"]); // before init_layout!
        if (args["--init-settings"]) {
            signature_page.init_layout();
            signature_page.init_settings();
        }
        signature_page.prepare();
        if (args["--report-cumulative"])
            signature_page.tree().report_cumulative_edge_length(std::cout);
        if (args["--list-ladderized"])
            signature_page.tree().list_strains(std::cout);
        if (!args["--no-draw"])
            signature_page.draw(args["--report-hz-section_antigens"]);
        if (args["--init-settings"])
            signature_page.write_initialized_settings(args["--init-settings"]);

        if (args["--open"])
            acmacs::open(args[1], 2);

        return 0;
    }
    catch (std::exception& err) {
        std::cerr << "ERROR: " << err.what() << '\n';
        return 1;<commit_msg>minor improvement<commit_after>#include <iostream>
#include <string>

#include "acmacs-base/argc-argv.hh"
#include "acmacs-base/quicklook.hh"
#include "seqdb/seqdb.hh"

#include "signature-page.hh"
#include "settings.hh"

using namespace std::string_literals;

// ----------------------------------------------------------------------

int main(int argc, const char *argv[])
{
    try {
        argc_argv args(argc, argv, {
                {"--db-dir", ""},
                {"--seqdb", ""},

                {"-s", argc_argv::strings{}}, //value<std::vector<std::string>>(&aOptions.settings_filename), "signature page drawing settings (json) filename")
                {"--init-settings", ""}, // value<std::string>(&aOptions.init_settings_filename), "initialize signature page drawing settings (json) filename")
                {"--report-cumulative", false}, // bool_switch(&aOptions.report_cumulative)->default_value(false), "report cumulative edge lengths for leaf nodes of the tree")
                {"--report-hz-section_antigens", false}, // bool_switch(&aOptions.report_antigens_in_hz_sections)->default_value(false), "report antigens in each hz section")
                {"--list-ladderized", false}, // bool_switch(&aOptions.list_ladderized)->default_value(false), "list strain names after ladderizing")
                {"--no-draw", false}, // bool_switch(&aOptions.no_draw)->default_value(false), "do not generate pdf")
                {"--chart", ""}, // value<std::string>(&aOptions.chart_filename), "path to a chart for the signature page")

                {"--open", false},
                {"-v", false},
                {"--verbose", false},
                {"-h", false},
                {"--help", false},
            });

          // {"tree", value<std::string>(&aOptions.tree_filename)->required(), "path to tree to draw")
          // ("output,o", value<std::string>(&aOptions.output_filename)->required(), "output pdf")

        if (args["-h"] || args["--help"] || args.number_of_arguments() != 2) {
            throw std::runtime_error("Usage: "s + args.program() + " [options] <tree.json> <output.pdf>\n" + args.usage_options());
        }
        const bool verbose = args["-v"] || args["--verbose"];
        seqdb::setup_dbs(args["--db-dir"], verbose);
        if (args["--seqdb"])
            seqdb::setup(args["--seqdb"], verbose);

        {
            SignaturePageDraw signature_page;

            auto load_settings = [&signature_page,verbose](argc_argv::strings aFilenames) {
                                     for (auto fn: aFilenames) {
                                         if (verbose)
                                             std::cerr << "DEBUG: reading settings from " << fn << '\n';
                                         signature_page.load_settings(fn);
                                     }
                                 };
            if (args["-s"])
                load_settings(args["-s"]);

            signature_page.tree(args[0]);
            if (args["--chart"])
                signature_page.chart(args["--chart"]); // before make_surface!
            signature_page.make_surface(args[1], args["--init-settings"], !args["--no-draw"]); // before init_layout!
            if (args["--init-settings"]) {
                signature_page.init_layout();
                signature_page.init_settings();
            }
            signature_page.prepare();
            if (args["--report-cumulative"])
                signature_page.tree().report_cumulative_edge_length(std::cout);
            if (args["--list-ladderized"])
                signature_page.tree().list_strains(std::cout);
            if (!args["--no-draw"])
                signature_page.draw(args["--report-hz-section_antigens"]);
            if (args["--init-settings"])
                signature_page.write_initialized_settings(args["--init-settings"]);
        }

        if (args["--open"])
            acmacs::open(args[1], 2);

        return 0;
    }
    catch (std::exception& err) {
        std::cerr << "ERROR: " << err.what() << '\n';
        return 1;
{'fraction_non_alphanumeric': 0.1908724155320222, 'fraction_numerical': 0.0017650025214321734, 'mean_word_length': 2.0867704280155643, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2786236', 'n_tokens_mistral': 2282, 'n_tokens_neox': 2194, 'n_words': 410}