Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 26 additions & 34 deletions .github/workflows/racon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,40 @@ on:
branches:
- master

env:
BUILD_TYPE: Release

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
compiler:
- g++
- g++-4.8
- clang++
- clang++-4.0

runs-on: ubuntu-18.04
image:
- gcc:7
- silkeh/clang:7
build_type:
- Debug
- Release
container:
image: ${{ matrix.image }}
options: --user root

steps:
- uses: actions/checkout@v2

- if: ${{ matrix.compiler == 'g++-4.8' }}
name: Setup GCC
uses: egor-tensin/setup-gcc@v1
with:
version: "4.8"
platform: x64

- if: ${{ matrix.compiler == 'clang++-4.0' }}
name: Setup Clang
uses: egor-tensin/setup-clang@v1
with:
version: "4.0"
platform: x64

- name: Configure CMake
run: cmake -B ${{ github.workspace }}/build -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}
env:
CXX: ${{ matrix.compiler }}
- uses: actions/checkout@v4

- name: Install build dependencies
run: |
chmod +x ci/install_deps.sh
./ci/install_deps.sh


- name: Generate build files
run: >
cmake -B ./build -G Ninja
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}

- name: Build
run: cmake --build ${{ github.workspace }}/build --config ${{ env.BUILD_TYPE }}
run: cmake --build ./build

- name: Test
working-directory: ${{ github.workspace }}/build
run: |
bin/racon --version
bin/racon_test
./build/bin/racon --version
./build/bin/racon_test
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
cmake_minimum_required(VERSION 3.11)
cmake_minimum_required(VERSION 3.16)

project(racon VERSION 1.5.0
LANGUAGES CXX
DESCRIPTION "Racon is a consensus module for de novo genome assembly.")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

Expand Down Expand Up @@ -57,12 +57,12 @@ if (NOT edlib_FOUND)
endif ()
endif ()

find_package(spoa 4.0.8 QUIET)
find_package(spoa 4.1.4 QUIET)
if (NOT spoa_FOUND)
FetchContent_Declare(
spoa
GIT_REPOSITORY https://github.com/rvaser/spoa
GIT_TAG 4.0.8)
GIT_TAG fd3a5c58c1acbdf649ec956acb7dca5f24638f72)

FetchContent_GetProperties(spoa)
if (NOT spoa_POPULATED)
Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ Racon can also be used as a read error-correction tool. In this scenario, the MH
A **wrapper script** is also available to enable easier usage to the end-user for large datasets. It has the same interface as racon but adds two additional features from the outside. Sequences can be **subsampled** to decrease the total execution time (accuracy might be lower) while target sequences can be **split** into smaller chunks and run sequentially to decrease memory consumption. Both features can be run at the same time as well.

## Dependencies
1. gcc 4.8+ or clang 3.4+
2. cmake 3.2+
1. gcc 7+ or clang 7+
2. cmake 3.12+
3. zlib

### CUDA Support
1. gcc 5.0+
2. cmake 3.10+
1. gcc 7+
2. cmake 3.12+
3. CUDA 9.0+

## Installation
Expand Down Expand Up @@ -95,6 +95,9 @@ Usage of `racon` is as following:
maximum allowed error rate used for filtering overlaps
--no-trimming
disables consensus trimming at window ends
--min-coverage <int>
default: -1
minimal consensus coverage
-m, --match <int>
default: 3
score for matching bases
Expand Down
13 changes: 13 additions & 0 deletions ci/install_deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -eou pipefail

apt update && apt install -y git zlib1g-dev curl ninja-build

VERSION="3.16.5"
MIRROR_URL="https://github.com/Kitware/CMake/releases/download/v$VERSION"
DOWNLOAD="cmake-$VERSION-linux-x86_64.sh"
DOWNLOAD_FILE="/tmp/cmake.sh"

curl -Ls "${MIRROR_URL}/${DOWNLOAD}" --output "${DOWNLOAD_FILE}"
bash "${DOWNLOAD_FILE}" --skip-license --prefix=/usr/local --exclude-subdir
cmake --version
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ project(
default_options : [
'buildtype=release',
'warning_level=3',
'cpp_std=c++11'],
'cpp_std=c++17'],
license : 'MIT',
meson_version : '>= 0.50.0')

Expand Down
10 changes: 9 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ static struct option options[] = {
{"quality-threshold", required_argument, 0, 'q'},
{"error-threshold", required_argument, 0, 'e'},
{"no-trimming", no_argument, 0, 'T'},
{"min-coverage", required_argument, nullptr, 'M'},
{"match", required_argument, 0, 'm'},
{"mismatch", required_argument, 0, 'x'},
{"gap", required_argument, 0, 'g'},
Expand All @@ -48,6 +49,7 @@ int main(int argc, char** argv) {
double error_threshold = 0.3;
bool trim = true;

int32_t min_coverage = -1;
int8_t match = 3;
int8_t mismatch = -5;
int8_t gap = -4;
Expand Down Expand Up @@ -87,6 +89,9 @@ int main(int argc, char** argv) {
case 'T':
trim = false;
break;
case 'M':
min_coverage = atoi(optarg);
break;
case 'm':
match = atoi(optarg);
break;
Expand Down Expand Up @@ -147,7 +152,7 @@ int main(int argc, char** argv) {
auto polisher = racon::createPolisher(input_paths[0], input_paths[1],
input_paths[2], type == 0 ? racon::PolisherType::kC :
racon::PolisherType::kF, window_length, quality_threshold,
error_threshold, trim, match, mismatch, gap, num_threads,
error_threshold, trim, match, mismatch, gap, num_threads, min_coverage,
cudapoa_batches, cuda_banded_alignment, cudaaligner_batches,
cudaaligner_band_width);

Expand Down Expand Up @@ -195,6 +200,9 @@ void help() {
" maximum allowed error rate used for filtering overlaps\n"
" --no-trimming\n"
" disables consensus trimming at window ends\n"
" --min-coverage <int>\n"
" default: -1\n"
" minimal consensus coverage\n"
" -m, --match <int>\n"
" default: 3\n"
" score for matching bases\n"
Expand Down
17 changes: 9 additions & 8 deletions src/polisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ void shrinkToFit(std::vector<std::unique_ptr<T>>& src, uint64_t begin) {
std::unique_ptr<Polisher> createPolisher(const std::string& sequences_path,
const std::string& overlaps_path, const std::string& target_path,
PolisherType type, uint32_t window_length, double quality_threshold,
double error_threshold, bool trim, int8_t match, int8_t mismatch, int8_t gap,
uint32_t num_threads, uint32_t cudapoa_batches, bool cuda_banded_alignment,
double error_threshold, bool trim, int8_t match, int8_t mismatch,
int8_t gap, uint32_t num_threads, int32_t min_coverage,
uint32_t cudapoa_batches, bool cuda_banded_alignment,
uint32_t cudaaligner_batches, uint32_t cudaaligner_band_width) {

if (type != PolisherType::kC && type != PolisherType::kF) {
Expand Down Expand Up @@ -158,7 +159,7 @@ std::unique_ptr<Polisher> createPolisher(const std::string& sequences_path,
return std::unique_ptr<Polisher>(new Polisher(std::move(sparser),
std::move(oparser), std::move(tparser), type, window_length,
quality_threshold, error_threshold, trim, match, mismatch, gap,
num_threads));
num_threads, min_coverage));
}
}

Expand All @@ -167,13 +168,13 @@ Polisher::Polisher(std::unique_ptr<bioparser::Parser<Sequence>> sparser,
std::unique_ptr<bioparser::Parser<Sequence>> tparser,
PolisherType type, uint32_t window_length, double quality_threshold,
double error_threshold, bool trim, int8_t match, int8_t mismatch, int8_t gap,
uint32_t num_threads)
uint32_t num_threads, int32_t min_coverage)
: sparser_(std::move(sparser)), oparser_(std::move(oparser)),
tparser_(std::move(tparser)), type_(type), quality_threshold_(
quality_threshold), error_threshold_(error_threshold), trim_(trim),
alignment_engines_(), sequences_(), dummy_quality_(window_length, '!'),
window_length_(window_length), windows_(),
thread_pool_(std::make_shared<thread_pool::ThreadPool>(num_threads)),
min_coverage_(min_coverage), alignment_engines_(), sequences_(),
dummy_quality_(window_length, '!'), window_length_(window_length),
windows_(), thread_pool_(std::make_shared<thread_pool::ThreadPool>(num_threads)),
logger_(new Logger()) {

for (uint32_t i = 0; i < num_threads; ++i) {
Expand Down Expand Up @@ -498,7 +499,7 @@ void Polisher::polish(std::vector<std::unique_ptr<Sequence>>& dst,
[&](uint64_t j) -> bool {
auto it = thread_pool_->thread_map().find(std::this_thread::get_id()); // NOLINT
return windows_[j]->generate_consensus(
alignment_engines_[it->second], trim_);
alignment_engines_[it->second], trim_, min_coverage_);
}, i));
}

Expand Down
11 changes: 7 additions & 4 deletions src/polisher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <memory>
#include <unordered_map>
#include <thread>
#include <string>

namespace bioparser {
template<class T>
Expand Down Expand Up @@ -43,7 +44,7 @@ std::unique_ptr<Polisher> createPolisher(const std::string& sequences_path,
const std::string& overlaps_path, const std::string& target_path,
PolisherType type, uint32_t window_length, double quality_threshold,
double error_threshold, bool trim, int8_t match, int8_t mismatch, int8_t gap,
uint32_t num_threads, uint32_t cuda_batches = 0,
uint32_t num_threads, int32_t min_coverage = -1, uint32_t cuda_batches = 0,
bool cuda_banded_alignment = false, uint32_t cudaaligner_batches = 0,
uint32_t cudaaligner_band_width = 0);

Expand All @@ -60,16 +61,17 @@ class Polisher {
const std::string& overlaps_path, const std::string& target_path,
PolisherType type, uint32_t window_length, double quality_threshold,
double error_threshold, bool trim, int8_t match, int8_t mismatch, int8_t gap,
uint32_t num_threads, uint32_t cuda_batches, bool cuda_banded_alignment,
uint32_t cudaaligner_batches, uint32_t cudaaligner_band_width);
uint32_t num_threads, int32_t min_coverage, uint32_t cuda_batches,
bool cuda_banded_alignment, uint32_t cudaaligner_batches,
uint32_t cudaaligner_band_width);

protected:
Polisher(std::unique_ptr<bioparser::Parser<Sequence>> sparser,
std::unique_ptr<bioparser::Parser<Overlap>> oparser,
std::unique_ptr<bioparser::Parser<Sequence>> tparser,
PolisherType type, uint32_t window_length, double quality_threshold,
double error_threshold, bool trim, int8_t match, int8_t mismatch, int8_t gap,
uint32_t num_threads);
uint32_t num_threads, int32_t min_coverage);
Polisher(const Polisher&) = delete;
const Polisher& operator=(const Polisher&) = delete;
virtual void find_overlap_breaking_points(std::vector<std::unique_ptr<Overlap>>& overlaps);
Expand All @@ -82,6 +84,7 @@ class Polisher {
double quality_threshold_;
double error_threshold_;
bool trim_;
int32_t min_coverage_;
std::vector<std::shared_ptr<spoa::AlignmentEngine>> alignment_engines_;

std::vector<std::unique_ptr<Sequence>> sequences_;
Expand Down
4 changes: 2 additions & 2 deletions src/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void Window::add_layer(const char* sequence, uint32_t sequence_length,
}

bool Window::generate_consensus(std::shared_ptr<spoa::AlignmentEngine> alignment_engine,
bool trim) {
bool trim, int32_t min_coverage) {

if (sequences_.size() < 3) {
consensus_ = std::string(sequences_.front().first, sequences_.front().second);
Expand Down Expand Up @@ -120,7 +120,7 @@ bool Window::generate_consensus(std::shared_ptr<spoa::AlignmentEngine> alignment
}

std::vector<uint32_t> coverages;
consensus_ = graph.GenerateConsensus(&coverages);
consensus_ = graph.GenerateConsensus(&coverages, min_coverage);

if (type_ == WindowType::kTGS && trim) {
uint32_t average_coverage = (sequences_.size() - 1) / 2;
Expand Down
2 changes: 1 addition & 1 deletion src/window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Window {
}

bool generate_consensus(std::shared_ptr<spoa::AlignmentEngine> alignment_engine,
bool trim);
bool trim, int32_t min_coverage);

void add_layer(const char* sequence, uint32_t sequence_length,
const char* quality, uint32_t quality_length, uint32_t begin,
Expand Down