Skip to content

Commit

Permalink
Merge branch '0.1.0' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolai Romashchenko committed Jun 5, 2019
2 parents 3085f73 + e1f97e2 commit be4bdd5
Show file tree
Hide file tree
Showing 18 changed files with 612 additions and 403 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
0.1.0
First released version.
4 changes: 2 additions & 2 deletions build/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ target_sources(build_n

# posterior probability matrix
src/pp_matrix/proba_matrix.cpp
src/pp_matrix/node_entry.cpp
src/pp_matrix/node_entry_view.cpp
src/pp_matrix/phyml.cpp
src/pp_matrix/branch_entry.cpp
src/pp_matrix/branch_entry_view.cpp

src/main.cpp
)
Expand Down
277 changes: 197 additions & 80 deletions build/src/build/db_builder.cpp

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions build/src/build/db_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ namespace core
namespace rappas
{
core::phylo_kmer_db build(const std::string& working_directory, const std::string& ar_probabilities_file,
const std::string& tree_file, const std::string& extended_mapping_file,
const std::string& artree_mapping_file, size_t kmer_size);
const std::string& original_tree_file, const std::string& extended_tree_file,
const std::string& extended_mapping_file, const std::string& artree_mapping_file,
size_t kmer_size, core::phylo_kmer::score_type omega, size_t num_threads);
}

#endif
18 changes: 15 additions & 3 deletions build/src/cli/command_line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ namespace cli
static std::string WORKING_DIR = "workdir", WORKING_DIR_SHORT = "w";
static std::string AR_PROBABILITIES = "ar-probabilities", AR_PROBABILITIES_SHORT = "a";
static std::string REFTREE = "reftree", REFTREE_SHORT = "t";
static std::string EXTENDED_TREE = "extended_tree", EXTENDED_TREE_SHORT = "x";
static std::string EXTENDED_MAPPING = "extended_mapping", EXTENDED_MAPPING_SHORT = "e";
static std::string ARTREE_MAPPING = "artree_mapping", ARTREE_MAPPING_SHORT = "m";
static std::string K = "k", K_SHORT = "k";
static std::string OMEGA="omega", OMEGA_SHORT="o";
static std::string NUM_THREADS = "num_threads", NUM_THREADS_SHORT = "j";

const po::options_description get_opt_description()
{
Expand All @@ -42,13 +45,19 @@ namespace cli
((AR_PROBABILITIES + "," + AR_PROBABILITIES_SHORT).c_str(), po::value<fs::path>()->required(),
"Ancestral reconstruction probabilities file")
((REFTREE + "," + REFTREE_SHORT).c_str(), po::value<fs::path>()->required(),
"Phylogenetic tree file")
"Original phylogenetic tree file")
((EXTENDED_TREE + "," + EXTENDED_TREE_SHORT).c_str(), po::value<fs::path>()->required(),
"Extended phylogenetic tree file")
((EXTENDED_MAPPING + "," + EXTENDED_MAPPING_SHORT).c_str(), po::value<fs::path>()->required(),
"Original mapping file")
((ARTREE_MAPPING + "," + ARTREE_MAPPING_SHORT).c_str(), po::value<fs::path>()->required(),
"Ancestral reconstruction tree mapping file")
((K + "," + K_SHORT).c_str(), po::value<size_t>()->default_value(8),
"k-mer length used at DB build");
"k-mer length used at DB build")
((OMEGA + "," + OMEGA_SHORT).c_str(), po::value<core::phylo_kmer::score_type>()->default_value(1.0),
"Score threshold parameter")
((NUM_THREADS + "," + NUM_THREADS_SHORT).c_str(), po::value<size_t>()->default_value(1),
"Number of threads");
return desc;
}

Expand Down Expand Up @@ -81,10 +90,13 @@ namespace cli

parameters.working_directory = vm[WORKING_DIR].as<fs::path>().string();
parameters.ar_probabilities_file = vm[AR_PROBABILITIES].as<fs::path>().string();
parameters.tree_file = vm[REFTREE].as<fs::path>().string();
parameters.original_tree_file = vm[REFTREE].as<fs::path>().string();
parameters.extended_tree_file = vm[EXTENDED_TREE].as<fs::path>().string();
parameters.extended_mapping_file = vm[EXTENDED_MAPPING].as<fs::path>().string();
parameters.artree_mapping_file = vm[ARTREE_MAPPING].as<fs::path>().string();
parameters.kmer_size = vm[K].as<size_t>();
parameters.omega = vm[OMEGA].as<core::phylo_kmer::score_type>();
parameters.num_threads = vm[NUM_THREADS].as<size_t>();
}
catch (const po::error& e)
{
Expand Down
6 changes: 5 additions & 1 deletion build/src/cli/command_line.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <exception>
#include <string>
#include <map>
#include <core/phylo_kmer.h>

namespace cli
{
Expand All @@ -19,12 +20,15 @@ namespace cli
action_t action;
std::string working_directory;
std::string ar_probabilities_file;
std::string tree_file;
std::string original_tree_file;
std::string extended_tree_file;
std::string extended_mapping_file;
std::string artree_mapping_file;

// algo options
size_t kmer_size;
core::phylo_kmer::score_type omega;
size_t num_threads;
};

const std::string get_option_list();
Expand Down
43 changes: 33 additions & 10 deletions build/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#include <iostream>
#include <sstream>
#include <chrono>
#include <boost/filesystem.hpp>
#include <chrono>
#include <core/phylo_kmer_db.h>
#include <core/serialization.h>
#include <iomanip>
#include "cli/command_line.h"
#include "cli/exceptions.h"
#include "return.h"
#include "build/db_builder.h"
#include "return.h"

namespace fs = boost::filesystem;

Expand All @@ -19,6 +22,18 @@ return_code print_help()
return return_code::help;
}

std::string generate_db_name(const core::phylo_kmer_db& db)
{
const auto kmer_size = db.kmer_size();
const auto omega = db.omega();
const auto threshold = core::score_threshold(omega, kmer_size);

std::ostringstream out;
out << "DB_k" << kmer_size << "_w" << std::fixed << std::setprecision(2) << omega << "_t" <<
std::setprecision(4) << threshold << ".rps";
return out.str();
}

return_code run(const cli::cli_parameters& parameters)
{
switch (parameters.action)
Expand All @@ -29,11 +44,18 @@ return_code run(const cli::cli_parameters& parameters)
}
case cli::build:
{
if (parameters.kmer_size > core::seq_traits::max_kmer_length)
{
std::cerr << "Maximum k-mer size allowed: " << core::seq_traits::max_kmer_length << std::endl;
return return_code::argument_error;
}

const auto db = rappas::build(parameters.working_directory, parameters.ar_probabilities_file,
parameters.tree_file, parameters.extended_mapping_file,
parameters.artree_mapping_file, parameters.kmer_size);
parameters.original_tree_file, parameters.extended_tree_file,
parameters.extended_mapping_file, parameters.artree_mapping_file,
parameters.kmer_size, parameters.omega, parameters.num_threads);

const auto db_filename = fs::path(parameters.working_directory) / "DB.union";
const auto db_filename = fs::path(parameters.working_directory) / generate_db_name(db);

std::cout << "Saving database to: " << db_filename.string() << "..." << std::endl;
std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now();
Expand All @@ -47,7 +69,7 @@ return_code run(const cli::cli_parameters& parameters)
{
return return_code::unknown_error;
}
};
}
}

int main(int argc, const char* argv[])
Expand All @@ -61,23 +83,24 @@ int main(int argc, const char* argv[])
}
catch (const conflicting_options& e)
{
std::cout << e.what() << std::endl;
std::cerr << e.what() << std::endl;
return 1;
}
catch (const bad_options& e)
{
std::cout << e.what() << std::endl;
std::cerr << e.what() << std::endl;
return 1;
}
catch (const std::runtime_error& e)
{
std::cout << e.what() << std::endl;
std::cerr << e.what() << std::endl;
return 1;
}
/*
catch (...)
{
std::cout << "Unexpected error. " << std::endl;
std::cerr << "Unexpected error. " << std::endl;
return 1;
}
}*/
return 0;
}
194 changes: 0 additions & 194 deletions build/src/pp_matrix/branch_entry_view.cpp

This file was deleted.

Loading

0 comments on commit be4bdd5

Please sign in to comment.