Skip to content

Commit

Permalink
fix off-by-one error #74
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Hall authored and rmcolq committed Oct 24, 2018
1 parent 60433ff commit c44459f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,6 @@ EcoliK12_pandora*

#internal scripts
scripts/*

# local directory - michael
vm-build/
2 changes: 1 addition & 1 deletion include/denovo_discovery/extract_reads.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace denovo_discovery {
std::map<GeneIntervalInfo, ReadPileup>
collect_read_pileups(const std::set<std::pair<ReadCoordinate, GeneIntervalInfo>> &,
const boost::filesystem::path &,
const uint32_t &padding_size = g_local_assembly_kmer_size);
const uint32_t &padding_size = g_local_assembly_kmer_size * 2);
}


Expand Down
3 changes: 0 additions & 3 deletions src/denovo_discovery/local_assembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,6 @@ void local_assembly(const std::vector<std::string> &sequences,
if (not start_found) {
continue;
}

BOOST_LOG_TRIVIAL(debug) << "Found start kmer: " << graph.toString(start_node);

for (const auto &e_kmer: end_kmers) {
// make sure end kmer doesnt exist in the set of start kmers
if (start_kmers.find(e_kmer) != start_kmers.end()) {
Expand Down
15 changes: 4 additions & 11 deletions src/fastaq_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,10 @@ void print(istream &infile) {
}

void FastaqHandler::get_id(const uint32_t &id) {
//cout << "get id " << id << endl;
if (id < num_reads_parsed) {
//cout << "restart buffer as have id " << num_reads_parsed << " and want id " << id << endl;
const uint32_t one_based_id = id + 1;
if (one_based_id < num_reads_parsed) {
BOOST_LOG_TRIVIAL(warning) << "restart buffer as have id " << num_reads_parsed << " and want id "
<< one_based_id << " (" << id << ") with 0-based indexing.";
num_reads_parsed = 0;
name.clear();
read.clear();
Expand All @@ -146,27 +147,19 @@ void FastaqHandler::get_id(const uint32_t &id) {
inbuf.push(fastaq_file);
}

BOOST_LOG_TRIVIAL(trace) << "now have name " << name << " read " << read << " num_reads_parsed " << num_reads_parsed
<< " and line " << line << endl;

while (id > 1 and num_reads_parsed < id) {
skip_next();
if (eof()) {
break;
}
}

BOOST_LOG_TRIVIAL(trace) << "now have name " << name << " read " << read << " num_reads_parsed " << num_reads_parsed
<< " and line " << line << endl;

while (num_reads_parsed <= id) {
get_next();
if (eof()) {
break;
}
}
BOOST_LOG_TRIVIAL(trace) << "now have name " << name << " read " << read << " num_reads_parsed " << num_reads_parsed
<< " and line " << line << endl;
}

void FastaqHandler::close() {
Expand Down
2 changes: 1 addition & 1 deletion src/localPRG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,7 @@ uint32_t median(std::vector<uint32_t> v) {
} else {
int n1 = (v.size() + 2) / 2;
int n2 = (v.size() - 2) / 2;
return (v[n1 - 1] + v[n2 - 1]) / 2;
return (v[n1 - 1] + v[n2 - 1]) / 2;
}
}

Expand Down

0 comments on commit c44459f

Please sign in to comment.