Author: Michael R. Crusoe <michael.crusoe@gmail.com>
Description: Attempt to use the Debian version of vcflib
but this fails due to the difference between the bundled htslib and the htslib used in Debian's vcflib
--- vg.orig/Makefile
+++ vg/Makefile
@@ -31,12 +31,12 @@
 CXXFLAGS := -O3 -Werror=return-type -std=c++14 -ggdb -g -MMD -MP $(CXXFLAGS)
 
 # Set include flags. All -I options need to go in here, so the first directory listed is genuinely searched first.
-INCLUDE_FLAGS:=$(shell pkg-config --cflags libfastahack) -I$(CWD)/$(INC_DIR) -I. -I$(CWD)/$(SRC_DIR) -I$(CWD)/$(UNITTEST_SRC_DIR) -I$(CWD)/$(SUBCOMMAND_SRC_DIR) -I$(CWD)/$(INC_DIR)/dynamic -I$(CWD)/$(INC_DIR)/sonLib $(shell pkg-config --cflags cairo jansson) $(shell pkg-config --cflags libsmithwaterman)
+INCLUDE_FLAGS:=$(shell pkg-config --cflags libfastahack) -I$(CWD)/$(INC_DIR) -I. -I$(CWD)/$(SRC_DIR) -I$(CWD)/$(UNITTEST_SRC_DIR) -I$(CWD)/$(SUBCOMMAND_SRC_DIR) -I$(CWD)/$(INC_DIR)/dynamic -I$(CWD)/$(INC_DIR)/sonLib $(shell pkg-config --cflags cairo jansson) $(shell pkg-config --cflags libsmithwaterman) $(shell pkg-config --cflags libvcflib)
 
 # Define libraries to link against. Make sure to always link statically against
 # htslib and libdeflate and Protobuf so that we can use position-dependent code
 # there for speed.
-LD_LIB_FLAGS:= -L$(CWD)/$(LIB_DIR) $(CWD)/$(LIB_DIR)/libvgio.a -lz -lvcflib -lgssw -lssw -lprotobuf -lsublinearLS $(CWD)/$(LIB_DIR)/libhts.a -ldeflate -lpthread -ljansson -lncurses -lgcsa2 -lgbwtgraph -lgbwt -ldivsufsort -ldivsufsort64 -lraptor2 -lpinchesandcacti -l3edgeconnected -lsonlib -lfml -llz4 -lstructures -lvw -lboost_program_options -lallreduce -lbdsg -lxg -lsdsl -lhandlegraph $(shell pkg-config --libs libfastahack) $(shell pkg-config --libs libsmithwaterman)
+LD_LIB_FLAGS:= -L$(CWD)/$(LIB_DIR) $(CWD)/$(LIB_DIR)/libvgio.a -lz -lgssw -lssw -lprotobuf -lsublinearLS $(CWD)/$(LIB_DIR)/libhts.a -ldeflate -lpthread -ljansson -lncurses -lgcsa2 -lgbwtgraph -lgbwt -ldivsufsort -ldivsufsort64 -lraptor2 -lpinchesandcacti -l3edgeconnected -lsonlib -lfml -llz4 -lstructures -lvw -lboost_program_options -lallreduce -lbdsg -lxg -lsdsl -lhandlegraph $(shell pkg-config --libs libfastahack) $(shell pkg-config --libs libsmithwaterman) $(shell pkg-config --libs libvcflib)
 # Use pkg-config to find Cairo and all the libs it uses
 LD_LIB_FLAGS += $(shell pkg-config --libs cairo jansson)
 
@@ -209,7 +209,6 @@
 GBWTGRAPH_DIR=deps/gbwtgraph
 PROGRESS_BAR_DIR:=deps/progress_bar
 HTSLIB_DIR:=deps/htslib
-VCFLIB_DIR:=deps/vcflib
 GSSW_DIR:=deps/gssw
 SPARSEPP_DIR:=deps/sparsepp
 SHA1_DIR:=deps/sha1
@@ -243,7 +242,6 @@
 LIB_DEPS += $(LIB_DIR)/libgbwt.a
 LIB_DEPS += $(LIB_DIR)/libgbwtgraph.a
 LIB_DEPS += $(LIB_DIR)/libhts.a
-LIB_DEPS += $(LIB_DIR)/libvcflib.a
 LIB_DEPS += $(LIB_DIR)/libgssw.a
 LIB_DEPS += $(LIB_DIR)/libsonlib.a
 LIB_DEPS += $(LIB_DIR)/libpinchesandcacti.a
@@ -317,7 +315,7 @@
 # And we have submodule deps to build
 deps: $(DEPS)
 
-test: $(BIN_DIR)/$(EXE) $(LIB_DIR)/libvg.a test/build_graph $(BIN_DIR)/shuf $(VCFLIB_DIR)/bin/vcf2tsv 
+test: $(BIN_DIR)/$(EXE) $(LIB_DIR)/libvg.a test/build_graph $(BIN_DIR)/shuf
 	. ./source_me.sh && cd test && prove -v t
 
 docs: $(SRC_DIR)/*.cpp $(SRC_DIR)/*.hpp $(SUBCOMMAND_SRC_DIR)/*.cpp $(SUBCOMMAND_SRC_DIR)/*.hpp $(UNITTEST_SRC_DIR)/*.cpp $(UNITTEST_SRC_DIR)/*.hpp
@@ -412,15 +410,6 @@
 $(LIB_DIR)/libhts%a $(LIB_DIR)/pkgconfig/htslib%pc: $(HTSLIB_DIR)/*.c $(HTSLIB_DIR)/*.h $(HTSLIB_DIR)/htslib/*.h $(HTSLIB_DIR)/cram/*.c $(HTSLIB_DIR)/cram/*.h
 	+. ./source_me.sh && cd $(HTSLIB_DIR) && rm -Rf $(CWD)/$(INC_DIR)/htslib $(CWD)/$(LIB_DIR)/libhts* && autoheader && autoconf && CFLAGS="-I$(CWD)/$(INC_DIR) $(CFLAGS)" LDFLAGS="-L$(CWD)/$(LIB_DIR)" ./configure --with-libdeflate --disable-s3 --disable-gcs --disable-libcurl --disable-plugins --prefix=$(CWD) $(FILTER) && $(MAKE) clean && $(MAKE) $(FILTER) && $(MAKE) install
 
-# We tell the vcflib build to use our own htslib.
-# We link it and libdeflate statically (on Linux) because our lib directory won't
-# necessarily be on the vcflib binaries' search path.
-$(LIB_DIR)/libvcflib.a: $(LIB_DIR)/libhts.a $(VCFLIB_DIR)/src/*.cpp $(VCFLIB_DIR)/src/*.hpp $(VCFLIB_DIR)/intervaltree/*.cpp $(VCFLIB_DIR)/intervaltree/*.h $(VCFLIB_DIR)/tabixpp/*.cpp $(VCFLIB_DIR)/tabixpp/*.hpp
-	+. ./source_me.sh && cd $(VCFLIB_DIR) && $(MAKE) clean && HTS_LIB="$(CWD)/$(LIB_DIR)/libhts.a" HTS_INCLUDES="-I$(CWD)/$(INC_DIR)" HTS_LDFLAGS="-L$(CWD)/$(LIB_DIR) $(START_STATIC) -lhts -ldeflate $(END_STATIC) -lpthread -lm -lbz2 -llzma -lz" $(MAKE) libvcflib.a $(FILTER) && cp lib/* $(CWD)/$(LIB_DIR)/ && cp include/* $(CWD)/$(INC_DIR)/ && cp intervaltree/*.h $(CWD)/$(INC_DIR)/ && cp src/*.h* $(CWD)/$(INC_DIR)/
-
-$(VCFLIB_DIR)/bin/vcf2tsv: $(VCFLIB_DIR)/src/*.cpp $(VCFLIB_DIR)/src/*.h $(LIB_DIR)/libvcflib.a
-	+. ./source_me.sh && cd $(VCFLIB_DIR) && HTS_LIB="$(CWD)/$(LIB_DIR)/libhts.a" HTS_INCLUDES="-I$(CWD)/$(INC_DIR)" HTS_LDFLAGS="-L$(CWD)/$(LIB_DIR) $(START_STATIC) -lhts -ldeflate $(END_STATIC) -lpthread -lm -lbz2 -llzma -lz" $(MAKE) vcf2tsv $(FILTER)
-
 $(LIB_DIR)/libgssw.a: $(GSSW_DIR)/src/gssw.c $(GSSW_DIR)/src/gssw.h
 	+. ./source_me.sh && cd $(GSSW_DIR) && $(MAKE) $(FILTER) && cp lib/* $(CWD)/$(LIB_DIR)/ && cp obj/* $(CWD)/$(OBJ_DIR) && cp src/*.h $(CWD)/$(INC_DIR)
 
@@ -618,7 +607,7 @@
 	$(RM) -r $(OBJ_DIR)/*.o $(OBJ_DIR)/*.d
 	$(RM) -f $(INC_DIR)/vg_system_version.hpp
 
-clean: clean-vcflib
+clean:
 	$(RM) -r $(BIN_DIR)
 	$(RM) -r $(LIB_DIR)
 	$(RM) -r $(UNITTEST_OBJ_DIR)
@@ -635,7 +624,6 @@
 	cd $(DEP_DIR) && cd gssw && $(MAKE) clean
 	cd $(DEP_DIR) && cd progress_bar && $(MAKE) clean
 	cd $(DEP_DIR) && cd sdsl-lite && ./uninstall.sh || true
-	cd $(DEP_DIR) && cd vcflib && $(MAKE) clean
 	cd $(DEP_DIR) && cd gfakluge && $(MAKE) clean
 	cd $(DEP_DIR) && cd sha1 && $(MAKE) clean
 	cd $(DEP_DIR) && cd structures && $(MAKE) clean
@@ -645,7 +633,3 @@
 	cd $(DEP_DIR) && cd libvgio && $(MAKE) clean 
     # lru_cache is never built because it is header-only
     # bash-tap is never built either
-
-clean-vcflib:
-	cd $(DEP_DIR) && cd vcflib && $(MAKE) clean
-	cd $(INC_DIR) && rm -f BedReader.h convert.h join.h mt19937ar.h split.h Variant.h vec128int.h veclib_types.h
--- vg.orig/src/readfilter.cpp
+++ vg/src/readfilter.cpp
@@ -1,5 +1,5 @@
 #include "readfilter.hpp"
-#include "IntervalTree.h"
+#include <intervaltree/IntervalTree.h>
 #include "annotation.hpp"
 #include "alignment_emitter.hpp"
 #include <vg/io/stream.hpp>
--- vg.orig/src/srpe.hpp
+++ vg/src/srpe.hpp
@@ -6,7 +6,7 @@
 #include "filter.hpp"
 #include "index.hpp"
 #include "path_index.hpp"
-#include "IntervalTree.h"
+#include <intervaltree/IntervalTree.h>
 #include <vg/vg.pb.h>
 #include "fml.h"
 #include "vg.hpp"
--- vg.orig/src/subcommand/srpe_main.cpp
+++ vg/src/subcommand/srpe_main.cpp
@@ -26,7 +26,7 @@
 #include <vg/vg.pb.h>
 #include "Variant.h"
 #include "Fasta.h"
-#include "IntervalTree.h"
+#include <intervaltree/IntervalTree.h>
 
 using namespace std;
 using namespace vg;
--- vg.orig/test/Makefile
+++ vg/test/Makefile
@@ -3,19 +3,11 @@
 CXX:=g++
 CXXFLAGS:=-O3 -std=c++11 -fopenmp -g
 
-vg:=../bin/vg
-
 all: test clean
 
-test: build_graph $(vg) vcf2tsv
+test: build_graph 
 	prove -v t
 
-vcf2tsv:
-	cd ../deps/vcflib && $(MAKE) bin/vcf2tsv
-
-$(vg):
-	cd .. && $(MAKE) bin/vg
-
 build_graph: build_graph.cpp
 	cd .. && . ./source_me.sh && $(MAKE) test/build_graph
 
--- vg.orig/test/t/02_vg_construct.t
+++ vg/test/t/02_vg_construct.t
@@ -76,7 +76,7 @@
 # check that we produce a full graph
 
 refbp=$(fastahack -r x small/x.fa | tr -d '\n' | wc -c)
-variantbp=$(zcat < small/x.vcf.gz | ../deps/vcflib/bin/vcf2tsv \
+variantbp=$(zcat < small/x.vcf.gz | vcf2tsv \
     | cut -f 5,4 | tail -n+2 \
     | awk '{ x=length($2)-length($1); if (x > 0) { print x; } else if (x == 0) { print length($2); } }' \
         | awk '{ sum += $1 } END { print sum }')
