Skip to content

Commit

Permalink
Fix for lower case bases and overflow in POA graph traversal
Browse files Browse the repository at this point in the history
  • Loading branch information
rvaser committed May 23, 2018
1 parent 57aabc5 commit 7198d4b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "sequence.hpp"
#include "polisher.hpp"

static const char* version = "v1.3.1";
static const char* version = "v1.3.2";

static struct option options[] = {
{"include-unpolished", no_argument, 0, 'u'},
Expand Down
23 changes: 14 additions & 9 deletions src/sequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* @brief Sequence class source file
*/

#include <ctype.h>

#include "sequence.hpp"

namespace racon {
Expand All @@ -16,23 +18,26 @@ std::unique_ptr<Sequence> createSequence(const std::string& name,

Sequence::Sequence(const char* name, uint32_t name_length, const char* data,
uint32_t data_length)
: name_(name, name_length), data_(data, data_length),
reverse_complement_(), quality_(), reverse_quality_() {
: name_(name, name_length), data_(), reverse_complement_(), quality_(),
reverse_quality_() {

data_.reserve(data_length);
for (uint32_t i = 0; i < data_length; ++i) {
data_ += toupper(data[i]);
}
}

Sequence::Sequence(const char* name, uint32_t name_length, const char* data,
uint32_t data_length, const char* quality, uint32_t quality_length)
: name_(name, name_length), data_(data, data_length),
reverse_complement_(), quality_(quality, quality_length),
reverse_quality_() {
: Sequence(name, name_length, data, data_length) {

uint32_t quality_sum = 0;
for (const auto& it: quality_) {
quality_sum += it - '!';
for (uint32_t i = 0; i < quality_length; ++i) {
quality_sum += quality[i] - '!';
}

if (quality_sum == 0) {
std::string().swap(quality_);
if (quality_sum > 0) {
quality_.assign(quality, quality_length);
}
}

Expand Down
2 changes: 1 addition & 1 deletion vendor/spoa

0 comments on commit 7198d4b

Please sign in to comment.