Skip to content

Commit

Permalink
Allow for unbundling htslib
Browse files Browse the repository at this point in the history
  • Loading branch information
SoapGentoo committed Jun 18, 2022
1 parent 91ee120 commit acbbbbc
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 28 deletions.
2 changes: 1 addition & 1 deletion source/BAMfunctions.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "BAMfunctions.h"
#include "htslib/htslib/kstring.h"
#include <htslib/kstring.h>


string bam_cigarString (bam1_t *b) {//output CIGAR string
Expand Down
4 changes: 2 additions & 2 deletions source/IncludeDefine.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <htslib/bgzf.h>
#define SAMTOOLS_SAM_H <htslib/sam.h>

using namespace std;

Expand Down
52 changes: 33 additions & 19 deletions source/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand Down Expand Up @@ -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 \
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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)
2 changes: 1 addition & 1 deletion source/STAR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

#include "twoPassRunPass1.h"

#include "htslib/htslib/sam.h"
#include <htslib/sam.h>
#include "parametersDefault.xxd"

void usage(int usageType) {
Expand Down
2 changes: 1 addition & 1 deletion source/bamRemoveDuplicates.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <unordered_map>
#include "bamRemoveDuplicates.h"
#include <iostream>
#include "htslib/htslib/sam.h"
#include <htslib/sam.h>
#include "IncludeDefine.h"
#include SAMTOOLS_BGZF_H
#include "ErrorWarning.h"
Expand Down
4 changes: 2 additions & 2 deletions source/bam_cat.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ THE SOFTWARE.
#include <stdlib.h>
#include <unistd.h>

#include "htslib/htslib/bgzf.h"
#include "htslib/htslib/sam.h"
#include <htslib/bgzf.h>
#include <htslib/sam.h>
#include <cstring>

#define BUF_SIZE 0x10000
Expand Down
2 changes: 1 addition & 1 deletion source/bam_cat.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef CODE_bam_cat
#define CODE_bam_cat

#include "htslib/htslib/sam.h"
#include <htslib/sam.h>

int bam_cat(int nfn, char * const *fn, const bam_hdr_t *h, const char* outbam);

Expand Down
2 changes: 1 addition & 1 deletion source/signalFromBAM.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef CODE_signalFromBAM
#define CODE_signalFromBAM
#include "htslib/htslib/sam.h"
#include <htslib/sam.h>
#include <fstream>
#include <string>
#include "Stats.h"
Expand Down

0 comments on commit acbbbbc

Please sign in to comment.