Skip to content

Commit

Permalink
astyle -A14 -w -xW -Y -xG -M -f -p -k3 -y -xL *.h *.cpp tools/*.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
voutcn committed Aug 4, 2015
1 parent b5a35c8 commit 56bc921
Show file tree
Hide file tree
Showing 57 changed files with 3,042 additions and 1,803 deletions.
63 changes: 34 additions & 29 deletions asm_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,43 +25,48 @@
#include "utils.h"
#include "definitions.h"

int main_assemble(int argc, char** argv);
int main_assemble(int argc, char **argv);
int main_local(int argc, char **argv);
int main_iterate(int argc, char **argv);
int main_build_lib(int argc, char **argv);

void show_help(const char *program_name) {
fprintf(stderr, "Usage: %s <sub_program> [sub options]\n"
" sub-programs:\n"
" assemble assemble from SdBG\n"
" local local asssembly\n"
" iterate extract iterative edges\n"
" buildlib build read library\n"
" dumpversion dump version\n",
program_name);
fprintf(stderr, "Usage: %s <sub_program> [sub options]\n"
" sub-programs:\n"
" assemble assemble from SdBG\n"
" local local asssembly\n"
" iterate extract iterative edges\n"
" buildlib build read library\n"
" dumpversion dump version\n",
program_name);
}

int main(int argc, char **argv) {
if (argc < 2) {
show_help(argv[0]);
exit(1);
}
if (argc < 2) {
show_help(argv[0]);
exit(1);
}

if (strcmp(argv[1], "assemble") == 0) {
return main_assemble(argc - 1, argv + 1);
} else if (strcmp(argv[1], "local") == 0) {
return main_local(argc - 1 , argv + 1);
} else if (strcmp(argv[1], "iterate") == 0) {
return main_iterate(argc - 1, argv + 1);
} else if (strcmp(argv[1], "buildlib") == 0) {
return main_build_lib(argc - 1, argv + 1);
} else if (strcmp(argv[1], "dumpversion") == 0) {
printf("%s\n", PACKAGE_VERSION);
return 0;
} else {
show_help(argv[0]);
exit(1);
}
if (strcmp(argv[1], "assemble") == 0) {
return main_assemble(argc - 1, argv + 1);
}
else if (strcmp(argv[1], "local") == 0) {
return main_local(argc - 1 , argv + 1);
}
else if (strcmp(argv[1], "iterate") == 0) {
return main_iterate(argc - 1, argv + 1);
}
else if (strcmp(argv[1], "buildlib") == 0) {
return main_build_lib(argc - 1, argv + 1);
}
else if (strcmp(argv[1], "dumpversion") == 0) {
printf("%s\n", PACKAGE_VERSION);
return 0;
}
else {
show_help(argv[0]);
exit(1);
}

return 0;
return 0;
}
15 changes: 11 additions & 4 deletions assembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,12 @@ void ParseAsmOption(int argc, char *argv[]) {

try {
desc.Parse(argc, argv);

if (opt.sdbg_name == "") {
throw std::logic_error("no succinct de Bruijn graph name!");
}
} catch (std::exception &e) {
}
catch (std::exception &e) {
std::cerr << e.what() << std::endl;
std::cerr << "Usage: " << argv[0] << " -s sdbg_name -o output_prefix" << std::endl;
std::cerr << "options:" << std::endl;
Expand All @@ -126,7 +128,7 @@ void PrintStat(Histgram<int64_t> &h) {

int main_assemble(int argc, char **argv) {
AutoMaxRssRecorder recorder;

ParseAsmOption(argc, argv);

SuccinctDBG dbg;
Expand All @@ -148,6 +150,7 @@ int main_assemble(int argc, char **argv) {
if (opt.num_cpu_threads == 0) {
opt.num_cpu_threads = omp_get_max_threads();
}

omp_set_num_threads(opt.num_cpu_threads);
xlog("Number of CPU threads: %d\n", opt.num_cpu_threads);

Expand Down Expand Up @@ -178,9 +181,11 @@ int main_assemble(int argc, char **argv) {
timer.start();
uint32_t num_bubbles = unitig_graph.MergeBubbles(true, opt.careful_bubble);
uint32_t num_complex_bubbles = 0;

if (opt.merge_len > 0) {
num_complex_bubbles += unitig_graph.MergeComplexBubbles(opt.merge_similar, opt.merge_len, true, opt.careful_bubble);
}

timer.stop();
xlog("Number of bubbles/complex bubbles removed: %u/%u, Time elapsed(sec): %lf\n",
num_bubbles, num_complex_bubbles, timer.elapsed());
Expand Down Expand Up @@ -239,6 +244,7 @@ int main_assemble(int argc, char **argv) {
}

uint32_t num_complex_bubbles = 0;

if (opt.merge_len > 0)
num_complex_bubbles = unitig_graph.MergeComplexBubbles(opt.merge_similar, opt.merge_len, opt.is_final_round, false);

Expand All @@ -250,14 +256,15 @@ int main_assemble(int argc, char **argv) {

if (!opt.is_final_round) {
unitig_graph.OutputContigs(out_addi_contig_file, NULL, hist, true, 0);
} else {
}
else {
// unitig_graph.OutputContigs(out_contig_file, out_final_contig_file, hist, false, opt.min_standalone);
unitig_graph.OutputContigs(out_contig_file, opt.output_standalone ? out_final_contig_file : NULL, hist, false, opt.min_standalone);
}

PrintStat(hist);
fprintf(out_addi_contig_info, "%lld %lld\n", (long long)hist.size(), (long long)hist.sum());

fclose(out_addi_contig_file);
fclose(out_addi_contig_info);
}
Expand Down
24 changes: 19 additions & 5 deletions assembly_algorithms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,26 @@ int64_t Trim(SuccinctDBG &dbg, int len, int min_final_standalone) {
int64_t number_tips = 0;

#pragma omp parallel for reduction(+:number_tips)

for (int64_t node_idx = 0; node_idx < dbg.size; ++node_idx) {
if (dbg.IsLast(node_idx) && !removed_nodes.get(node_idx) && dbg.NodeOutdegreeZero(node_idx)) {
vector<int64_t> path = {node_idx};
int64_t prev_node;
int64_t cur_node = node_idx;
bool is_tip = false;

for (int i = 1; i < len; ++i) {
prev_node = dbg.UniquePrevNode(cur_node);

if (prev_node == -1) {
is_tip = dbg.NodeIndegreeZero(cur_node); // && (i + dbg.kmer_k - 1 < min_final_standalone);
break;
} else if (dbg.UniqueNextNode(prev_node) == -1) {
}
else if (dbg.UniqueNextNode(prev_node) == -1) {
is_tip = true;
break;
} else {
}
else {
path.push_back(prev_node);
cur_node = prev_node;
}
Expand All @@ -69,26 +74,32 @@ int64_t Trim(SuccinctDBG &dbg, int len, int min_final_standalone) {
for (unsigned i = 0; i < path.size(); ++i) {
removed_nodes.set(path[i]);
}

++number_tips;
}
}
}

#pragma omp parallel for reduction(+:number_tips)

for (int64_t node_idx = 0; node_idx < dbg.size; ++node_idx) {
if (dbg.IsLast(node_idx) && !removed_nodes.get(node_idx) && dbg.NodeIndegreeZero(node_idx)) {
vector<int64_t> path = {node_idx};
int64_t next_node;
int64_t cur_node = node_idx;
bool is_tip = false;

for (int i = 1; i < len; ++i) {
next_node = dbg.UniqueNextNode(cur_node);

if (next_node == -1) {
is_tip = dbg.NodeOutdegreeZero(cur_node); // && (i + dbg.kmer_k - 1 < min_final_standalone);
break;
} else if (dbg.UniquePrevNode(next_node) == -1) {
}
else if (dbg.UniquePrevNode(next_node) == -1) {
is_tip = true;
} else {
}
else {
path.push_back(next_node);
cur_node = next_node;
}
Expand All @@ -98,12 +109,14 @@ int64_t Trim(SuccinctDBG &dbg, int len, int min_final_standalone) {
for (unsigned i = 0; i < path.size(); ++i) {
removed_nodes.set(path[i]);
}

++number_tips;
}
}
}

#pragma omp parallel for

for (int64_t node_idx = 0; node_idx < dbg.size; ++node_idx) {
if (removed_nodes.get(node_idx)) {
dbg.DeleteAllEdges(node_idx);
Expand All @@ -117,7 +130,7 @@ int64_t RemoveTips(SuccinctDBG &dbg, int max_tip_len, int min_final_standalone)
int64_t number_tips = 0;
xtimer_t timer;
removed_nodes.reset(dbg.size);

for (int len = 2; len < max_tip_len; len *= 2) {
xlog("Removing tips with length less than %d; ", len);
timer.reset();
Expand All @@ -126,6 +139,7 @@ int64_t RemoveTips(SuccinctDBG &dbg, int max_tip_len, int min_final_standalone)
timer.stop();
xlog_ext("Accumulated tips removed: %lld; time elapsed: %.4f\n", (long long)number_tips, timer.elapsed());
}

xlog("Removing tips with length less than %d; ", max_tip_len);
timer.reset();
timer.start();
Expand Down
19 changes: 13 additions & 6 deletions atomic_bit_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ class AtomicBitVector {
AtomicBitVector(size_t size = 0): size_(size) {
num_words_ = ((size + kBitsPerWord - 1) / kBitsPerWord);
capacity_ = num_words_;

if (num_words_ != 0) {
data_ = (word_t*) MallocAndCheck(sizeof(word_t) * num_words_, __FILE__, __LINE__);
data_ = (word_t *) MallocAndCheck(sizeof(word_t) * num_words_, __FILE__, __LINE__);
memset(data_, 0, sizeof(word_t) * num_words_);
} else {
}
else {
data_ = NULL;
}
}
Expand All @@ -60,13 +62,16 @@ class AtomicBitVector {
bool try_lock(size_t i) {
// assert(i / kBitsPerWord < num_words_);
word_t *p = data_ + i / kBitsPerWord;

while (!((*p >> i % kBitsPerWord) & 1)) {
word_t old_value = *p;
word_t new_value = old_value | (word_t(1) << (i % kBitsPerWord));

if (__sync_bool_compare_and_swap(p, old_value, new_value)) {
return true;
}
}

return false;
}

Expand All @@ -83,17 +88,19 @@ class AtomicBitVector {
void reset(size_t size = 0, int reset_value = 0) {
size_ = size;
num_words_ = (size + kBitsPerWord - 1) / kBitsPerWord;

if (capacity_ < num_words_) {
word_t *new_data = (word_t*) ReAllocAndCheck(data_, sizeof(word_t) * num_words_, __FILE__, __LINE__);
word_t *new_data = (word_t *) ReAllocAndCheck(data_, sizeof(word_t) * num_words_, __FILE__, __LINE__);
data_ = new_data;
capacity_ = num_words_;
}

if (num_words_ != 0) {
if (reset_value) {
memset(data_, -1, sizeof(word_t) * num_words_);
} else {
memset(data_, 0, sizeof(word_t) * num_words_);
memset(data_, -1, sizeof(word_t) * num_words_);
}
else {
memset(data_, 0, sizeof(word_t) * num_words_);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion bit_operation.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ inline int BitToIndex(uint8_t x) {

template<uint32_t number>
struct MostSignificantBit {
static const int value = 1 + MostSignificantBit<(number >> 1)>::value;
static const int value = 1 + MostSignificantBit < (number >> 1) >::value;
};

template<>
Expand Down
22 changes: 11 additions & 11 deletions build_read_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
#include "utils.h"

void DisplayHelp(const char *program) {
fprintf(stderr, "Usage %s <read_lib_file> <out_prefix>\n", program);
fprintf(stderr, "Usage %s <read_lib_file> <out_prefix>\n", program);
}

int main_build_lib(int argc, char **argv) {
AutoMaxRssRecorder recorder;

if (argc < 3) {
DisplayHelp(argv[0]);
exit(1);
}
AutoMaxRssRecorder recorder;

bool is_reverse = false;
bool verbose = true;
ReadAndWriteMultipleLibs(argv[1], is_reverse, argv[2], verbose);
if (argc < 3) {
DisplayHelp(argv[0]);
exit(1);
}

return 0;
bool is_reverse = false;
bool verbose = true;
ReadAndWriteMultipleLibs(argv[1], is_reverse, argv[2], verbose);

return 0;
}
Loading

0 comments on commit 56bc921

Please sign in to comment.