Skip to content

Commit

Permalink
- Compile examples
Browse files Browse the repository at this point in the history
- Solved memory-greedy (not released) bug on edit/indel --score-only
  • Loading branch information
smarco committed Feb 18, 2022
1 parent 796b24c commit 1d20bef
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 26 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ SUBDIRS=alignment \
system \
utils \
wavefront
TOOLS=tools/align_benchmark \
tools/generate_dataset
TOOLS=tools/generate_dataset \
tools/align_benchmark \
tools/examples


release: CC_FLAGS+=-O3 -march=native -flto
release: build
Expand Down Expand Up @@ -59,6 +61,7 @@ lib_wfa: $(SUBDIRS)
clean:
rm -rf $(FOLDER_BIN) $(FOLDER_BUILD) $(FOLDER_LIB)
$(MAKE) --directory=tools/align_benchmark clean
$(MAKE) --directory=tools/examples clean

###############################################################################
# Subdir rule
Expand Down
4 changes: 2 additions & 2 deletions tools/align_benchmark/benchmark/benchmark_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ void benchmark_print_output_full(
fprintf(stream,"%d\t",align_input->pattern_length); // Pattern length
fprintf(stream,"%d\t",align_input->text_length); // Text length
fprintf(stream,"%d\t",score); // Alignment score
cigar_print(stream,cigar,true); fprintf(stream,"\t"); // CIGAR
fprintf(stream,"%s\t",align_input->pattern); // Pattern sequence
fprintf(stream,"%s\n",align_input->text); // Text sequence
fprintf(stream,"%s\t",align_input->text); // Text sequence
cigar_print(stream,cigar,true); fprintf(stream,"\n"); // CIGAR
}
/*
* Stats
Expand Down
43 changes: 43 additions & 0 deletions tools/examples/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
###############################################################################
# Definitions
###############################################################################
FOLDER_WFA=../..
FOLDER_LIB=../../lib
FOLDER_BIN=bin

###############################################################################
# Rules
###############################################################################
LIB_WFA=$(FOLDER_LIB)/libwfa.a
EXAMPLES_C=wfa_adapt \
wfa_basic \
wfa_repetead
EXAMPLES_CPP=wfa_bindings \
wfa_lambda

all: setup
all: $(EXAMPLES_C) $(EXAMPLES_CPP)

$(EXAMPLES_C): *.c $(LIB_WFA)
$(CC) $(CC_FLAGS) -L$(FOLDER_LIB) -I$(FOLDER_WFA) wfa_basic.c -o wfa_basic -lwfa -lm
$(CC) $(CC_FLAGS) -L$(FOLDER_LIB) -I$(FOLDER_WFA) wfa_adapt.c -o wfa_adapt -lwfa -lm
$(CC) $(CC_FLAGS) -L$(FOLDER_LIB) -I$(FOLDER_WFA) wfa_repeated.c -o wfa_repeated -lwfa -lm

$(EXAMPLES_CPP): *.cpp $(LIB_WFA)
$(CPP) $(CC_FLAGS) -L$(FOLDER_LIB) -I$(FOLDER_WFA) wfa_bindings.cpp -o wfa_bindings -lwfacpp
$(CPP) $(CC_FLAGS) -L$(FOLDER_LIB) -I$(FOLDER_WFA) wfa_lambda.cpp -o wfa_lambda -lwfacpp

setup:
@mkdir -p $(FOLDER_BIN)

clean:
rm -rf $(FOLDER_BIN)

###############################################################################
# Subdir rule
###############################################################################
export
$(SUBDIRS):
$(MAKE) --directory=$@ all

.PHONY: $(SUBDIRS)
19 changes: 0 additions & 19 deletions tools/examples/compile.examples.sh

This file was deleted.

Binary file removed tools/examples/wfa_adapt
Binary file not shown.
Binary file removed tools/examples/wfa_basic
Binary file not shown.
Binary file removed tools/examples/wfa_bindings
Binary file not shown.
2 changes: 1 addition & 1 deletion tools/examples/wfa_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ int main(int argc,char* argv[]) {
string text = "TCTATACTGCGCGTTTGGAGAAATAAAATAGT";

// Create a WFAligner
WFAlignerGapAffine aligner(4,6,2);
WFAlignerGapAffine aligner(4,6,2,WFAligner::Alignment,WFAligner::MemoryHigh);
// Align
aligner.alignEnd2End(pattern,text);
cout << "WFA-Alignment returns score " << aligner.getAlignmentScore() << endl;
Expand Down
Binary file removed tools/examples/wfa_lambda
Binary file not shown.
4 changes: 2 additions & 2 deletions tools/examples/wfa_lambda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ int match_function(

int main(int argc,char* argv[]) {
// Create a WFAligner
WFAlignerGapAffine aligner(1,0,1);
WFAlignerGapAffine aligner(1,0,1,WFAligner::Alignment,WFAligner::MemoryHigh);
aligner.setMatchFunct(match_function,NULL);
// Align
aligner.alignEnd2End(patternLength,textLength);
aligner.alignEnd2EndLambda(patternLength,textLength);
cout << "WFA-Alignment returns score " << aligner.getAlignmentScore() << endl;

// Print CIGAR
Expand Down
Binary file removed tools/examples/wfa_repeated
Binary file not shown.
3 changes: 3 additions & 0 deletions wavefront/wavefront_compute_edit.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ void wavefront_compute_edit(
if (wf_components->memory_modular) { // Modular wavefront
score_prev = score_prev % wf_components->max_score_scope;
score_curr = score_curr % wf_components->max_score_scope;
if (wf_components->mwavefronts[score_curr]) { // Free
wavefront_slab_free(wf_aligner->wavefront_slab,wf_components->mwavefronts[score_curr]);
}
}
// Fetch previous wavefront, compute limits & initialize
wavefront_t* const wf_prev = wf_components->mwavefronts[score_prev];
Expand Down

0 comments on commit 1d20bef

Please sign in to comment.