Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
voutcn committed Jul 4, 2015
2 parents 93f8f02 + 86945c6 commit 0b1c1d9
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 18 deletions.
6 changes: 6 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### 0.3.3 / 2015-07-04 HKT

* Fixed segmentation fault when a read is all N
* Fixed continue mode: check continue mode before writing binary reads
* Slightly improve SdBG traversal functions

### 0.3.2-beta / 2015-06-28 HKT

* fine tune local assembly multi-thread schedules
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ifeq ($(use_gpu), 1)
NVCC_VERSION = $(strip $(shell nvcc --version | grep release | sed 's/.*release //' | sed 's/,.*//'))
endif

version = $(shell git describe --tag || echo "git_not_found" 2>/dev/null)
version = $(shell git describe --tag 2>/dev/null || echo "git_not_found" 2>/dev/null)

# detect OS
OSUPPER = $(shell uname -s 2>/dev/null | tr [:lower:] [:upper:])
Expand Down
7 changes: 1 addition & 6 deletions atomic_bit_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class AtomicBitVector {
capacity_ = num_words_;
if (num_words_ != 0) {
data_ = (word_t*) MallocAndCheck(sizeof(word_t) * num_words_, __FILE__, __LINE__);
assert(data_ != NULL);
memset(data_, 0, sizeof(word_t) * num_words_);
} else {
data_ = NULL;
Expand Down Expand Up @@ -85,11 +84,7 @@ class AtomicBitVector {
size_ = size;
num_words_ = (size + kBitsPerWord - 1) / kBitsPerWord;
if (capacity_ < num_words_) {
word_t *new_data = (word_t*) MallocAndCheck(sizeof(word_t) * num_words_, __FILE__, __LINE__);
assert(new_data != NULL);
if (data_ != NULL) {
free(data_);
}
word_t *new_data = (word_t*) ReAllocAndCheck(data_, sizeof(word_t) * num_words_, __FILE__, __LINE__);
data_ = new_data;
capacity_ = num_words_;
}
Expand Down
2 changes: 1 addition & 1 deletion definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "kmer.h"

#ifndef PACKAGE_VERSION
#define PACKAGE_VERSION "0.3.2-beta"
#define PACKAGE_VERSION "v0.3.3"
#endif

typedef uint16_t multi_t;
Expand Down
5 changes: 3 additions & 2 deletions megahit
Original file line number Diff line number Diff line change
Expand Up @@ -951,11 +951,12 @@ def main(argv = None):
logging.info("--- [%s] Start assembly. Number of CPU threads %d ---" % (datetime.now().strftime("%c"), opt.num_cpu_threads))
logging.info("--- [%s] k list: %s ---" % (datetime.now().strftime("%c"), ','.join(map(str, opt.k_list))))

if not opt.continue_mode:
write_opt(argv[1:]) # for --continue

write_lib()
build_lib()

if not opt.continue_mode:
write_opt(argv[1:]) # for --continue
build_first_graph()
assemble(opt.k_min)

Expand Down
6 changes: 3 additions & 3 deletions mem_file_checker-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ inline void* ReAllocAndCheck(void *ptr,
const char *realloc_from_which_file = __FILE__,
int realloc_from_which_line = __LINE__) {
void *new_ptr = realloc(ptr, size_in_byte);
if (size_in_byte == 0 || ptr != NULL) {
return new_ptr;
} else {
if (size_in_byte != 0 && new_ptr == NULL) {
fprintf(stderr, "[ERROR] Ran out of memory while re-applying %llubytes\n", (unsigned long long)size_in_byte);
fprintf(stderr, "In file: %s, line %d\n", realloc_from_which_file, realloc_from_which_line);
fprintf(stderr, "There may be errors as follows:\n");
Expand All @@ -68,6 +66,8 @@ inline void* ReAllocAndCheck(void *ptr,
free(ptr);
exit(-1);
}

return new_ptr;
}

#endif // MEM_FILE_CHECKER_INL_H__
3 changes: 3 additions & 0 deletions sequence_package.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ struct SequencePackage {
max_read_len_ = len;
}

if (len == 0) { return; }
if (len * 2 <= unused_bits_) {
unused_bits_ -= len * 2;
packed_seq.back() |= s[0] >> (kCharsPerWord - len) * 2 << unused_bits_;
Expand Down Expand Up @@ -313,6 +314,8 @@ struct SequencePackage {
}

void AddRevSeqToPackedSeq_(const word_t *rs, int len) {
if (len == 0) { return; }

std::vector<word_t> s(rs, rs + (len + kCharsPerWord - 1) / kCharsPerWord);

for (int j = 0; j < (int)s.size(); ++j) {
Expand Down
9 changes: 7 additions & 2 deletions succinct_dbg.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ class SuccinctDBG {
}
rs_w_.Build(w_, size);
rs_last_.Build(last_, size);

for (int i = 0; i < kAlphabetSize + 2; ++i) {
rank_f_[i] = rs_last_.Rank(f_[i] - 1);
}
}

uint8_t GetW(int64_t x) {
Expand Down Expand Up @@ -138,12 +142,12 @@ class SuccinctDBG {
a -= 4;
}
int64_t count_a = rs_w_.Rank(a, x);
return rs_last_.Select(rs_last_.Rank(f_[a] - 1) + count_a - 1);
return rs_last_.Select(rank_f_[a] + count_a - 1);
}

int64_t Backward(int64_t x) { // the first node points to x
uint8_t a = GetNodeLastChar(x);
int64_t count_a = rs_last_.Rank(x - 1) - rs_last_.Rank(f_[a] - 1);
int64_t count_a = rs_last_.Rank(x - 1) - rank_f_[a];
return rs_w_.Select(a, count_a);
}

Expand Down Expand Up @@ -188,6 +192,7 @@ class SuccinctDBG {
khash_t(k64v16) *large_multi_h_;

long long f_[kAlphabetSize + 2];
long long rank_f_[kAlphabetSize + 2]; // = rs_last_.Rank(f_[i] - 1)

unsigned int num_dollar_nodes_;
int uint32_per_dollar_nodes_;
Expand Down
4 changes: 2 additions & 2 deletions tools/filter_by_len.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ int main_filter_by_len(int argc, char **argv) {

long long total_bases = hist.sum();

fprintf(stderr, "%d contigs, total %lld bp, min %lld bp, max %lld bp, avg %.2lf bp, N50 %lld bp\n",
(int)hist.size(), total_bases, hist.minimum(), hist.maximum(), hist.mean(), hist.Nx(total_bases * 0.5));
fprintf(stderr, "%d contigs, total %lld bp, min %lld bp, max %lld bp, avg %d bp, N50 %lld bp\n",
(int)hist.size(), total_bases, hist.minimum(), hist.maximum(), int(hist.mean() + 0.5), hist.Nx(total_bases * 0.5));

kseq_destroy(seq);
gzclose(fp);
Expand Down
2 changes: 1 addition & 1 deletion unitig_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ void UnitigGraph::OutputContigs(FILE *contig_file, FILE *final_file, Histgram<in
continue;
}

double multi = std::min((double)kMaxMulti_t, (double)vertices_[i].depth / vertices_[i].length + 0.5);
double multi = std::min((double)kMaxMulti_t, (double)vertices_[i].depth / vertices_[i].length);
if (change_only) {
multi = 1;
}
Expand Down

0 comments on commit 0b1c1d9

Please sign in to comment.