Skip to content

Commit

Permalink
Remove submodule logger
Browse files Browse the repository at this point in the history
  • Loading branch information
rvaser committed Nov 12, 2019
1 parent ededb83 commit a4c29df
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 17 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
[submodule "vendor/rampler"]
path = vendor/rampler
url = https://github.com/rvaser/rampler
[submodule "vendor/logger"]
path = vendor/logger
url = https://github.com/rvaser/logger
[submodule "vendor/ClaraGenomicsAnalysis"]
path = vendor/ClaraGenomicsAnalysis
url = https://github.com/clara-genomics/ClaraGenomicsAnalysis
11 changes: 5 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.2)
project(racon)
set(racon_version 1.4.9)
set(racon_version 1.4.10)

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
Expand Down Expand Up @@ -30,6 +30,7 @@ include_directories(${PROJECT_SOURCE_DIR}/src)

set(racon_sources
src/main.cpp
src/logger.cpp
src/polisher.cpp
src/overlap.cpp
src/sequence.cpp
Expand Down Expand Up @@ -58,9 +59,6 @@ endif()
if (NOT TARGET edlib)
add_subdirectory(vendor/edlib EXCLUDE_FROM_ALL)
endif()
if (NOT TARGET logger)
add_subdirectory(vendor/logger EXCLUDE_FROM_ALL)
endif()
if (racon_enable_cuda)
if (DEFINED CLARAGENOMICSANALYSIS_SDK_PATH)
list(APPEND CMAKE_PREFIX_PATH "${CLARAGENOMICSANALYSIS_SDK_PATH}/cmake")
Expand Down Expand Up @@ -90,7 +88,7 @@ if (racon_enable_cuda)
endif()
endif()

target_link_libraries(racon bioparser spoa thread_pool edlib_static logger)
target_link_libraries(racon bioparser spoa thread_pool edlib_static)
if (racon_enable_cuda)
target_link_libraries(racon cudapoa cudaaligner)
endif()
Expand All @@ -106,6 +104,7 @@ if (racon_build_tests)

set(racon_test_sources
test/racon_test.cpp
src/logger.cpp
src/polisher.cpp
src/overlap.cpp
src/sequence.cpp
Expand All @@ -123,7 +122,7 @@ if (racon_build_tests)
add_subdirectory(vendor/googletest/googletest EXCLUDE_FROM_ALL)
endif()

target_link_libraries(racon_test bioparser spoa thread_pool edlib_static logger gtest_main)
target_link_libraries(racon_test bioparser spoa thread_pool edlib_static gtest_main)
if (racon_enable_cuda)
target_link_libraries(racon_test cudapoa cudaaligner)
endif()
Expand Down
2 changes: 1 addition & 1 deletion src/cuda/cudapolisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
#include <cuda_profiler_api.h>

#include "sequence.hpp"
#include "logger.hpp"
#include "cudapolisher.hpp"
#include <claragenomics/utils/cudautils.hpp>

#include "bioparser/bioparser.hpp"
#include "logger/logger.hpp"

namespace racon {

Expand Down
56 changes: 56 additions & 0 deletions src/logger.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*!
* @file logger.cpp
*
* @brief Logger source file
*/

#include <iostream>

#include "logger.hpp"

namespace racon {

Logger::Logger()
: time_(0.), bar_(0), time_point_() {
}

Logger::~Logger() {
}

void Logger::log() {
auto now = std::chrono::steady_clock::now();
if (time_point_ != std::chrono::time_point<std::chrono::steady_clock>()) {
time_ += std::chrono::duration_cast<std::chrono::duration<double>>(now - time_point_).count();
}
time_point_ = now;
}

void Logger::log(const std::string& msg) const {
std::cerr << msg << " " << std::fixed
<< std::chrono::duration_cast<std::chrono::duration<double>>(std::chrono::steady_clock::now() - time_point_).count()
<< " s" << std::endl;
}

void Logger::bar(const std::string& msg) {
++bar_;
std::string progress_bar = "[" + std::string(bar_, '=') + (bar_ == 20 ? "" : ">" + std::string(19 - bar_, ' ')) + "]";

std::cerr << msg << " " << progress_bar << " " << std::fixed
<< std::chrono::duration_cast<std::chrono::duration<double>>(std::chrono::steady_clock::now() - time_point_).count()
<< " s";

bar_ %= 20;
if (bar_ == 0) {
std::cerr << std::endl;
} else {
std::cerr << "\r";
}
}

void Logger::total(const std::string& msg) const {
std::cerr << msg << " " << std::fixed
<< time_ + std::chrono::duration_cast<std::chrono::duration<double>>(std::chrono::steady_clock::now() - time_point_).count()
<< " s" << std::endl;
}

}
56 changes: 56 additions & 0 deletions src/logger.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*!
* @file logger.hpp
*
* @brief Logger header file
*/

#pragma once

#include <cstdint>
#include <chrono>
#include <string>

namespace racon {

static const std::string version = "v1.0.0";

class Logger {
public:
Logger();

Logger(const Logger&) = default;
Logger& operator=(const Logger&) = default;

Logger(Logger&&) = default;
Logger& operator=(Logger&&) = default;

~Logger();

/*!
* @brief Resets the time point
*/
void log();

/*!
* @brief Prints the elapsed time from last time point to stderr
*/
void log(const std::string& msg) const;

/*!
* @brief Prints a progress bar and the elapsed time from last time to
* stderr (the progress bar resets after 20 calls)
*/
void bar(const std::string& msg);

/*!
* @brief Prints the total elapsed time from the first log() call
*/
void total(const std::string& msg) const;

private:
double time_;
std::uint32_t bar_;
std::chrono::time_point<std::chrono::steady_clock> time_point_;
};

}
4 changes: 2 additions & 2 deletions src/polisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "overlap.hpp"
#include "sequence.hpp"
#include "window.hpp"
#include "logger.hpp"
#include "polisher.hpp"
#ifdef CUDA_ENABLED
#include "cuda/cudapolisher.hpp"
Expand All @@ -19,7 +20,6 @@
#include "bioparser/bioparser.hpp"
#include "thread_pool/thread_pool.hpp"
#include "spoa/spoa.hpp"
#include "logger/logger.hpp"

namespace racon {

Expand Down Expand Up @@ -170,7 +170,7 @@ Polisher::Polisher(std::unique_ptr<bioparser::Parser<Sequence>> sparser,
alignment_engines_(), sequences_(), dummy_quality_(window_length, '!'),
window_length_(window_length), windows_(),
thread_pool_(thread_pool::createThreadPool(num_threads)),
thread_to_id_(), logger_(new logger::Logger()) {
thread_to_id_(), logger_(new Logger()) {

uint32_t id = 0;
for (const auto& it: thread_pool_->thread_identifiers()) {
Expand Down
6 changes: 2 additions & 4 deletions src/polisher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ namespace spoa {
class AlignmentEngine;
}

namespace logger {
class Logger;
}

namespace racon {

class Sequence;
class Overlap;
class Window;
class Logger;

enum class PolisherType {
kC, // Contig polishing
Expand Down Expand Up @@ -95,7 +93,7 @@ class Polisher {
std::unique_ptr<thread_pool::ThreadPool> thread_pool_;
std::unordered_map<std::thread::id, uint32_t> thread_to_id_;

std::unique_ptr<logger::Logger> logger_;
std::unique_ptr<Logger> logger_;
};

}
1 change: 0 additions & 1 deletion vendor/logger
Submodule logger deleted from b88c8e

0 comments on commit a4c29df

Please sign in to comment.