Skip to content

Commit

Permalink
Merge pull request #19 from mourisl/dev
Browse files Browse the repository at this point in the history
Add "centrifuger-quant" for quantification
  • Loading branch information
mourisl authored Nov 7, 2024
2 parents 79b01b0 + b6e1b9e commit ab24291
Show file tree
Hide file tree
Showing 7 changed files with 586 additions and 5 deletions.
5 changes: 5 additions & 0 deletions BufferManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ class BufferManager
}
return _buffers[i] ;
}

size_t GetBufferSize(int i)
{
return _bufferSize[i] ;
}
} ;

#endif
81 changes: 81 additions & 0 deletions CentrifugerQuant.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#include <stdio.h>
#include <time.h>
#include <getopt.h>

#include "argvdefs.h"
#include "Taxonomy.hpp"
#include "Quantifier.hpp"

char usage[] = "./centrifuger-quant [OPTIONS]:\n"
"Required:\n"
"\t-x FILE: index prefix\n"
"\t-c FILE: classification result file\n"
//"When not giving "-x"\n"
//"\t--taxonomy-tree FILE: taxonomy tree, i.e., nodes.dmp file\n"
//"\t--name-table FILE: name table, i.e., names.dmp file\n"
//"\t--size-table FILE: size table, table of contig (or genome) sizes\n"
//"\t--conversion-table FILE: a table that converts any id to a taxonomy id\n"
;

static const char *short_options = "x:c:" ;
static struct option long_options[] = {
{ (char *)0, 0, 0, 0}
} ;

int main(int argc, char *argv[])
{
if ( argc <= 1 )
{
fprintf( stderr, "%s", usage ) ;
return 0 ;
}

int c, option_index ;
option_index = 0 ;

char *idxPrefix = NULL ;
char *classificationFile = NULL ;

while (1)
{
c = getopt_long( argc, argv, short_options, long_options, &option_index ) ;

if (c == -1)
break ;

if (c == 'x')
{
idxPrefix = strdup(optarg) ;
}
else if (c == 'c')
{
classificationFile = strdup(optarg) ;
}
else
{
fprintf(stderr, "Unknown parameter found.\n%s", usage) ;
return EXIT_FAILURE ;
}
}

Utils::PrintLog("Centrifuger-quant v" CENTRIFUGER_VERSION " starts." ) ;
if (idxPrefix == NULL)
{
Utils::PrintLog("Need to use -x to specify index prefix.") ;
return EXIT_FAILURE ;
}

Quantifier quantifier ;
quantifier.Init(idxPrefix) ;
quantifier.LoadReadAssignments(classificationFile, 0) ;

quantifier.Quantification() ;

quantifier.Output(stdout, 0) ;

free(idxPrefix) ;
free(classificationFile) ;

Utils::PrintLog("Centrifuger-quant finishes." ) ;
return 0 ;
}
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ifneq ($(asan),)
LDFLAGS+=-fsanitize=address -ldl -g
endif

all: centrifuger centrifuger-build centrifuger-inspect
all: centrifuger centrifuger-build centrifuger-inspect centrifuger-quant

centrifuger-build: CentrifugerBuild.o
$(CXX) -o $@ $(LINKPATH) $(CXXFLAGS) $< $(LINKFLAGS)
Expand All @@ -22,9 +22,14 @@ centrifuger: CentrifugerClass.o
centrifuger-inspect: CentrifugerInspect.o
$(CXX) -o $@ $(LINKPATH) $(CXXFLAGS) $< $(LINKFLAGS)

centrifuger-quant: CentrifugerQuant.o
$(CXX) -o $@ $(LINKPATH) $(CXXFLAGS) $< $(LINKFLAGS)


CentrifugerBuild.o: CentrifugerBuild.cpp Builder.hpp ReadFiles.hpp Taxonomy.hpp defs.h compactds/*.hpp
CentrifugerClass.o: CentrifugerClass.cpp Classifier.hpp ReadFiles.hpp Taxonomy.hpp defs.h ResultWriter.hpp ReadPairMerger.hpp ReadFormatter.hpp BarcodeCorrector.hpp BarcodeTranslator.hpp compactds/*.hpp
CentrifugerInspect.o: CentrifugerInspect.cpp Taxonomy.hpp defs.h compactds/*.hpp
CentrifugerQuant.o: CentrifugerQuant.cpp Quantifier.hpp Taxonomy.hpp compactds/*.hpp

clean:
rm -f *.o centrifuger-build centrifuger centrifuger-inspect
rm -f *.o centrifuger-build centrifuger centrifuger-inspect centrifuger-quant
Loading

0 comments on commit ab24291

Please sign in to comment.