diff --git a/source/BAMfunctions.cpp b/source/BAMfunctions.cpp index af6ce237..632deca5 100644 --- a/source/BAMfunctions.cpp +++ b/source/BAMfunctions.cpp @@ -1,5 +1,5 @@ #include "BAMfunctions.h" -#include "htslib/htslib/kstring.h" +#include string bam_cigarString (bam1_t *b) {//output CIGAR string diff --git a/source/IncludeDefine.h b/source/IncludeDefine.h index f9544484..bd528709 100755 --- a/source/IncludeDefine.h +++ b/source/IncludeDefine.h @@ -30,8 +30,8 @@ #define ERROR_OUT string ( __FILE__ ) +":"+ to_string ( (uint) __LINE__ ) +":"+ string ( __FUNCTION__ ) //external libs -#define SAMTOOLS_BGZF_H "htslib/htslib/bgzf.h" -#define SAMTOOLS_SAM_H "htslib/htslib/sam.h" +#define SAMTOOLS_BGZF_H +#define SAMTOOLS_SAM_H using namespace std; diff --git a/source/Makefile b/source/Makefile index d151788d..8a6c168b 100644 --- a/source/Makefile +++ b/source/Makefile @@ -12,12 +12,26 @@ CXXFLAGSextra ?= CXX ?= g++ # pre-defined flags -LDFLAGS_shared := -pthread -Lhtslib -Bstatic -lhts -Bdynamic -lz -LDFLAGS_static := -static -static-libgcc -pthread -Lhtslib -lhts -lz -LDFLAGS_Mac :=-pthread -lz htslib/libhts.a -LDFLAGS_Mac_static :=-pthread -lz -static-libgcc htslib/libhts.a +LDFLAGS_shared := +LDFLAGS_static := -static -static-libgcc +LDFLAGS_Mac := +LDFLAGS_Mac_static := -static-libgcc LDFLAGS_gdb := $(LDFLAGS_shared) +ifdef SYSTEM_HTSLIB +PKG_CONFIG ?= pkg-config +HTSLIB_CFLAGS = $(shell $(PKG_CONFIG) --cflags htslib) +HTSLIB_LIBS = $(shell $(PKG_CONFIG) --libs htslib) +else +HTSLIB_DEP := htslib + +HTSLIB_CFLAGS := -Ihtslib/ +HTSLIB_LIBS := htslib/libhts.a -lz +endif + +CPPFLAGS += $(HTSLIB_CFLAGS) +LIBS += -pthread $(HTSLIB_LIBS) + DATE_FMT = --iso-8601=seconds ifdef SOURCE_DATE_EPOCH BUILD_DATE ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "$(DATE_FMT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "$(DATE_FMT)" 2>/dev/null || date -u "$(DATE_FMT)") @@ -53,7 +67,7 @@ CXXFLAGS_gdb := -O0 -g3 $(CXXFLAGS_common) OBJECTS = SoloFeature_collapseUMI_Graph.o SoloFeature_collapseUMIall_multiMappers.o ParametersClip_initialize.o ClipMate_clip.o ClipCR4.o opal/opal.o ClipMate_clipChunk.o ClipMate_initialize.o \ SoloFeature_loadRawMatrix.o SoloFeature_emptyDrops_CR.o soloInputFeatureUMI.o SoloFeature_countSmartSeq.o SoloFeature_redistributeReadsByCB.o \ SoloFeature_quantTranscript.o SoloFeature_sumThreads.o SoloFeature_countVelocyto.o SoloFeature_countCBgeneUMI.o \ - Transcriptome_classifyAlign.o Transcriptome_geneFullAlignOverlap_ExonOverIntron.o Transcriptome_alignExonOverlap.cpp \ + Transcriptome_classifyAlign.o Transcriptome_geneFullAlignOverlap_ExonOverIntron.o Transcriptome_alignExonOverlap.o \ SoloFeature_cellFiltering.o \ SoloFeature_statsOutput.o bamSortByCoordinate.o SoloBarcode.o \ ParametersSolo.o SoloRead.o SoloRead_record.o \ @@ -74,22 +88,22 @@ OBJECTS = SoloFeature_collapseUMI_Graph.o SoloFeature_collapseUMIall_multiMapper ReadAlignChunk.o ReadAlignChunk_processChunks.o ReadAlignChunk_mapChunk.o \ OutSJ.o outputSJ.o blocksOverlap.o ThreadControl.o sysRemoveDir.o \ ReadAlign_maxMappableLength2strands.o binarySearch2.o\ - ReadAlign_outputTranscriptSAM.o ReadAlign_outputTranscriptSJ.o ReadAlign_outputTranscriptCIGARp.o ReadAlign_calcCIGAR.cpp \ + ReadAlign_outputTranscriptSAM.o ReadAlign_outputTranscriptSJ.o ReadAlign_outputTranscriptCIGARp.o ReadAlign_calcCIGAR.o \ ReadAlign_createExtendWindowsWithAlign.o ReadAlign_assignAlignToWindow.o ReadAlign_oneRead.o \ ReadAlign_stitchWindowSeeds.o \ ReadAlign_peOverlapMergeMap.o ReadAlign_mappedFilter.o \ ParametersChimeric_initialize.o ReadAlign_chimericDetection.o ReadAlign_chimericDetectionOld.o ReadAlign_chimericDetectionOldOutput.o\ ChimericDetection.o ChimericDetection_chimericDetectionMult.o ReadAlign_chimericDetectionPEmerged.o \ stitchWindowAligns.o extendAlign.o stitchAlignToTranscript.o \ - ChimericSegment.cpp ChimericAlign.cpp ChimericAlign_chimericJunctionOutput.o ChimericAlign_chimericBAMoutput.o ChimericAlign_chimericStitching.o \ + ChimericSegment.o ChimericAlign.o ChimericAlign_chimericJunctionOutput.o ChimericAlign_chimericBAMoutput.o ChimericAlign_chimericStitching.o \ Genome_genomeGenerate.o genomeParametersWrite.o genomeScanFastaFiles.o genomeSAindex.o \ Genome_insertSequences.o insertSeqSA.o funCompareUintAndSuffixes.o funCompareUintAndSuffixesMemcmp.o \ TimeFunctions.o ErrorWarning.o streamFuns.o stringSubstituteAll.o \ Transcriptome.o Transcriptome_quantAlign.o Transcriptome_geneFullAlignOverlap.o \ ReadAlign_quantTranscriptome.o Quantifications.o Transcriptome_geneCountsAddAlign.o \ sjdbLoadFromFiles.o sjdbLoadFromStream.o sjdbPrepare.o sjdbBuildIndex.o sjdbInsertJunctions.o mapThreadsSpawn.o \ - Parameters_readFilesInit.o Parameters_openReadsFiles.cpp Parameters_closeReadsFiles.cpp Parameters_readSAMheader.o \ - bam_cat.o serviceFuns.o GlobalVariables.cpp \ + Parameters_readFilesInit.o Parameters_openReadsFiles.o Parameters_closeReadsFiles.o Parameters_readSAMheader.o \ + bam_cat.o serviceFuns.o GlobalVariables.o \ BAMoutput.o BAMfunctions.o ReadAlign_alignBAM.o BAMbinSortByCoordinate.o signalFromBAM.o bamRemoveDuplicates.o BAMbinSortUnmapped.o SOURCES := $(wildcard *.cpp) $(wildcard *.c) @@ -130,7 +144,7 @@ ifneq ($(MAKECMDGOALS),CLEAN) ifneq ($(MAKECMDGOALS),clean_solo) ifneq ($(MAKECMDGOALS),STARforMac) ifneq ($(MAKECMDGOALS),STARforMacGDB) -Depend.list: $(SOURCES) parametersDefault.xxd htslib +Depend.list: $(SOURCES) parametersDefault.xxd $(HTSLIB_DEP) echo $(SOURCES) 'rm' -f ./Depend.list $(CXX) $(CXXFLAGS_common) -MM $^ >> Depend.list @@ -153,46 +167,46 @@ parametersDefault.xxd: parametersDefault STAR$(SFX) : CXXFLAGS := $(CXXFLAGSextra) $(CXXFLAGS_main) $(CXXFLAGS) STAR$(SFX) : LDFLAGS := $(LDFLAGSextra) $(LDFLAGS_shared) $(LDFLAGS) STAR$(SFX) : Depend.list parametersDefault.xxd $(OBJECTS) - $(CXX) $(CXXFLAGS) $(LDFLAGS) -o STAR$(SFX) $(OBJECTS) + $(CXX) $(CXXFLAGS) $(LDFLAGS) -o STAR$(SFX) $(OBJECTS) $(LIBS) STARstatic$(SFX) : CXXFLAGS := $(CXXFLAGSextra) $(CXXFLAGS_main) $(CXXFLAGS) STARstatic$(SFX) : LDFLAGS := $(LDFLAGSextra) $(LDFLAGS_static) $(LDFLAGS) STARstatic$(SFX) : Depend.list parametersDefault.xxd $(OBJECTS) - $(CXX) $(CXXFLAGS) $(LDFLAGS) -o STAR$(SFX) $(OBJECTS) + $(CXX) $(CXXFLAGS) $(LDFLAGS) -o STAR$(SFX) $(OBJECTS) $(LIBS) STARlong$(SFX) : CXXFLAGS := $(CXXFLAGSextra) $(CXXFLAGS_main) -D'COMPILE_FOR_LONG_READS' $(CXXFLAGS) STARlong$(SFX) : LDFLAGS := $(LDFLAGSextra) $(LDFLAGS_shared) $(LDFLAGS) STARlong$(SFX) : Depend.list parametersDefault.xxd $(OBJECTS) - $(CXX) $(CXXFLAGS) $(LDFLAGS) -o STARlong$(SFX) $(OBJECTS) + $(CXX) $(CXXFLAGS) $(LDFLAGS) -o STARlong$(SFX) $(OBJECTS) $(LIBS) STARlongStatic$(SFX) : CXXFLAGS := $(CXXFLAGSextra) $(CXXFLAGS_main) -D'COMPILE_FOR_LONG_READS' $(CXXFLAGS) STARlongStatic$(SFX) : LDFLAGS := $(LDFLAGSextra) $(LDFLAGS_static) $(LDFLAGS) STARlongStatic$(SFX) : Depend.list parametersDefault.xxd $(OBJECTS) - $(CXX) $(CXXFLAGS) $(LDFLAGS) -o STARlong$(SFX) $(OBJECTS) + $(CXX) $(CXXFLAGS) $(LDFLAGS) -o STARlong$(SFX) $(OBJECTS) $(LIBS) POSIXSHARED : CXXFLAGS := $(CXXFLAGSextra) $(CXXFLAGS_main) -DPOSIX_SHARED_MEM $(CXXFLAGS) POSIXSHARED : LDFLAGS := $(LDFLAGSextra) $(LDFLAGS_shared) $(LDFLAGS) POSIXSHARED : Depend.list parametersDefault.xxd $(OBJECTS) - $(CXX) $(CXXFLAGS) $(LDFLAGS) -o STAR$(SFX) $(OBJECTS) + $(CXX) $(CXXFLAGS) $(LDFLAGS) -o STAR$(SFX) $(OBJECTS) $(LIBS) gdb : CXXFLAGS := $(CXXFLAGSextra) $(CXXFLAGS_gdb) $(CXXFLAGS) gdb : LDFLAGS := $(LDFLAGSextra) $(LDFLAGS_gdb) $(LDFLAGS) gdb : Depend.list parametersDefault.xxd $(OBJECTS) - $(CXX) $(CXXFLAGS) $(LDFLAGS) -o STAR $(OBJECTS) + $(CXX) $(CXXFLAGS) $(LDFLAGS) -o STAR $(OBJECTS) $(LIBS) gdb-long : CXXFLAGS := $(CXXFLAGSextra) $(CXXFLAGS_gdb) -D'COMPILE_FOR_LONG_READS' $(CXXFLAGS) gdb-long : LDFLAGS := $(LDFLAGSextra) $(LDFLAGS_gdb) $(LDFLAGS) gdb-long : Depend.list parametersDefault.xxd $(OBJECTS) - $(CXX) $(CXXFLAGS) $(LDFLAGS) -o STARlong $(OBJECTS) + $(CXX) $(CXXFLAGS) $(LDFLAGS) -o STARlong $(OBJECTS) $(LIBS) STARforMacStatic : CXXFLAGS := $(CXXFLAGSextra) $(CXXFLAGS_main) -D'COMPILE_FOR_MAC' $(CXXFLAGS) STARforMacStatic : LDFLAGS := $(LDFLAGSextra) $(LDFLAGS_Mac_static) $(LDFLAGS) STARforMacStatic : Depend.list parametersDefault.xxd $(OBJECTS) - $(CXX) $(CXXFLAGS) $(LDFLAGS) -o STAR $(OBJECTS) + $(CXX) $(CXXFLAGS) $(LDFLAGS) -o STAR $(OBJECTS) $(LIBS) STARlongForMacStatic : CXXFLAGS := -D'COMPILE_FOR_LONG_READS' $(CXXFLAGSextra) $(CXXFLAGS_main) -D'COMPILE_FOR_MAC' $(CXXFLAGS) STARlongForMacStatic : LDFLAGS := $(LDFLAGSextra) $(LDFLAGS_Mac_static) $(LDFLAGS) STARlongForMacStatic : Depend.list parametersDefault.xxd $(OBJECTS) - $(CXX) $(CXXFLAGS) $(LDFLAGS) -o STARlong $(OBJECTS) + $(CXX) $(CXXFLAGS) $(LDFLAGS) -o STARlong $(OBJECTS) $(LIBS) diff --git a/source/STAR.cpp b/source/STAR.cpp index 32fadb4e..87e4b563 100755 --- a/source/STAR.cpp +++ b/source/STAR.cpp @@ -29,7 +29,7 @@ #include "twoPassRunPass1.h" -#include "htslib/htslib/sam.h" +#include #include "parametersDefault.xxd" void usage(int usageType) { diff --git a/source/bamRemoveDuplicates.cpp b/source/bamRemoveDuplicates.cpp index 13958d02..d7cc7ee3 100644 --- a/source/bamRemoveDuplicates.cpp +++ b/source/bamRemoveDuplicates.cpp @@ -1,7 +1,7 @@ #include #include "bamRemoveDuplicates.h" #include -#include "htslib/htslib/sam.h" +#include #include "IncludeDefine.h" #include SAMTOOLS_BGZF_H #include "ErrorWarning.h" diff --git a/source/bam_cat.c b/source/bam_cat.c index 944cafbb..efaabe4c 100644 --- a/source/bam_cat.c +++ b/source/bam_cat.c @@ -52,8 +52,8 @@ THE SOFTWARE. #include #include -#include "htslib/htslib/bgzf.h" -#include "htslib/htslib/sam.h" +#include +#include #include #define BUF_SIZE 0x10000 diff --git a/source/bam_cat.h b/source/bam_cat.h index 337d150c..f8f7fcda 100644 --- a/source/bam_cat.h +++ b/source/bam_cat.h @@ -1,7 +1,7 @@ #ifndef CODE_bam_cat #define CODE_bam_cat -#include "htslib/htslib/sam.h" +#include int bam_cat(int nfn, char * const *fn, const bam_hdr_t *h, const char* outbam); diff --git a/source/signalFromBAM.h b/source/signalFromBAM.h index 0406fdcd..aac44168 100644 --- a/source/signalFromBAM.h +++ b/source/signalFromBAM.h @@ -1,6 +1,6 @@ #ifndef CODE_signalFromBAM #define CODE_signalFromBAM -#include "htslib/htslib/sam.h" +#include #include #include #include "Stats.h"