Skip to content

Commit

Permalink
Fix read length estimation crash on chromosome-sized "reads"
Browse files Browse the repository at this point in the history
Closes #343
  • Loading branch information
marcelm committed Sep 19, 2023
1 parent a8651a0 commit a876c9d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/readlen.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "readlen.hpp"

int total_read_len(const std::vector<klibpp::KSeq> &records) {
uint64_t total_read_len(const std::vector<klibpp::KSeq> &records) {

int tot_read_len = 0;
uint64_t tot_read_len = 0;
for (size_t i = 0; i < records.size(); ++i) {
tot_read_len += records[i].seq.length();
}
Expand All @@ -13,7 +13,7 @@ int total_read_len(const std::vector<klibpp::KSeq> &records) {
* Return average read length of single-end or paired-end reads.
* Set filename2 to the empty string if data is single end.
*/
int estimate_read_length(InputBuffer& input_buffer) {
uint64_t estimate_read_length(InputBuffer& input_buffer) {
std::vector<klibpp::KSeq> records1;
std::vector<klibpp::KSeq> records2;
std::vector<klibpp::KSeq> records3;
Expand All @@ -27,4 +27,3 @@ int estimate_read_length(InputBuffer& input_buffer) {
auto tot_read_num = records1.size() + records2.size() + records3.size();
return tot_read_len / tot_read_num;
}

2 changes: 1 addition & 1 deletion src/readlen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
#include <zlib.h>
#include "pc.hpp"

int estimate_read_length(InputBuffer& input_buffer);
uint64_t estimate_read_length(InputBuffer& input_buffer);

#endif

0 comments on commit a876c9d

Please sign in to comment.