Commit 50782b90 authored by Marc Duez's avatar Marc Duez

similarity.cpp : improve command line / produce a tool usable by fuse.py

parent 71edd744
......@@ -30,16 +30,18 @@ LIBCORE=core/vidjil.a lib/lib.a
BINDIR=../
CGIDIR=../browser/cgi/
TOOLDIR=tools/
VIDJIL=$(BINDIR)$(EXEC)
ALIGN_CGI=$(CGIDIR)align.cgi
SIMILARITY_CGI=$(CGIDIR)similarity.cgi
SIMILARITY_TOOL=$(TOOLDIR)similarity
CREATE_VERSION_GIT_H := $(shell test -x ./create-git-version-h.sh && ./create-git-version-h.sh)
.PHONY: all core lib clean forcedep
all: $(VIDJIL) $(ALIGN_CGI) $(SIMILARITY_CGI)
all: $(VIDJIL) $(ALIGN_CGI) $(SIMILARITY_CGI) $(SIMILARITY_TOOL)
###
......@@ -78,6 +80,10 @@ $(ALIGN_CGI): cgi/align.o $(LIBCORE)
$(SIMILARITY_CGI): cgi/similarity.o $(LIBCORE)
make -C core OPTIM="$(OPTIM)"
$(CC) -o $@ $^ $(LDFLAGS) $(LDLIBS) $(CXXFLAGS)
$(SIMILARITY_TOOL): cgi/similarity.o $(LIBCORE)
make -C core OPTIM="$(OPTIM)"
$(CC) -o $@ $^ $(LDFLAGS) $(LDLIBS) $(CXXFLAGS)
###
debug:
......
......@@ -61,9 +61,12 @@ int main(int argc, char* argv[])
bool error = false;
bool cgi_mode;
bool output_json = false;
//CGI
if (argc <= 1){
cgi_mode=true;
output_json=true;
cout <<"Content-type: text/html"<<endl<<endl;
error = ! check_cgi_parameters(result);
......@@ -77,15 +80,37 @@ int main(int argc, char* argv[])
fdata = filename;
}
}
//command
}else{
cgi_mode=false;
fdata = argv[1];
//help !
if (strcmp(argv[1], "-h")==0){
cout << "usage: similarity [-h] [-j] file\n\n";
cout << "file : fasta file\n";
cout << "-h : help\n";
cout << "-j : json output\n";
return 0;
}
if (argc >= 3){
if (strcmp(argv[1], "-j")==0) {
output_json = true;
}
fdata = argv[2];
}else{
fdata = argv[1];
}
}
if (!cgi_mode) cout <<endl;
if (! error) {
Fasta fa(fdata, 1, " ", !cgi_mode);
Fasta fa(fdata, 1, " ", !output_json);
list<Sequence> reads;
reads = fa.getAll();
......@@ -97,10 +122,10 @@ int main(int argc, char* argv[])
SimilarityMatrix matrix = compare_all(reads, labels);
if (cgi_mode) {
if (output_json) {
json j;
j << JsonOutputSimilarityMatrix(matrix);
cout << j.dump(2);
cout << j.dump();
}else{
cout << RawOutputSimilarityMatrix(matrix, 90);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment