Skip to content
Commits on Source (3)
......@@ -8,15 +8,19 @@ INCLUDES?= -Ihtslib
HTS_HEADERS?= htslib/htslib/bgzf.h htslib/htslib/tbx.h
HTS_LIB?= htslib/libhts.a
LIBPATH?= -L. -Lhtslib
LIBS?= -lhts -lpthread -lm -lbz2 -llzma -lz
DFLAGS= -D_FILE_OFFSET_BITS=64 -D_USE_KNETFILE
PROG= tabix++
SUBDIRS=.
ifeq ($(OS),Windows_NT)
LIBS += -lws2_32
endif
.SUFFIXES:.c .o
.c.o:
$(CC) -c $(CXXFLAGS) $(DFLAGS) $(INCLUDES) $< -o $@
$(CC) $(CPPFLAGS) -c $(CXXFLAGS) $(DFLAGS) $(INCLUDES) $< -o $@
all-recur lib-recur clean-recur cleanlocal-recur install-recur:
@target=`echo $@ | sed s/-recur//`; \
......@@ -32,14 +36,13 @@ all-recur lib-recur clean-recur cleanlocal-recur install-recur:
all: $(PROG)
tabix.o: $(HTS_HEADERS) tabix.cpp tabix.hpp
$(CXX) $(CXXFLAGS) -c tabix.cpp $(INCLUDES)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c tabix.cpp $(INCLUDES)
htslib/libhts.a:
cd htslib && $(MAKE) lib-static
tabix++: tabix.o main.cpp $(HTS_LIB)
$(CXX) $(CXXFLAGS) -o $@ main.cpp tabix.o $(INCLUDES) $(LIBPATH) \
-lhts -lpthread -lm -lz
$(CXX) $(LDFLAGS) $(CPPFLAGS) $(CXXFLAGS) -o $@ main.cpp tabix.o $(INCLUDES) $(LIBPATH) $(LIBS)
cleanlocal:
rm -fr gmon.out *.o a.out *.dSYM $(PROG) *~ *.a tabix.aux tabix.log \
......
libtabixpp (1.1.0-1) UNRELEASED; urgency=medium
* Team upload.
* New upstream release.
* Freshen patches; hardening patch applied upstream
PENDING: libhts 1.10-2 with libhts3
-- Michael R. Crusoe <michael.crusoe@gmail.com> Sat, 14 Dec 2019 15:04:39 +0100
libtabixpp (1.0.0-5) unstable; urgency=medium
* Team upload.
......
......@@ -7,6 +7,7 @@ Priority: optional
Build-Depends: debhelper (>= 11~),
libhts-dev,
zlib1g-dev,
libbz2-dev,
d-shlibs
Standards-Version: 4.2.1
Vcs-Browser: https://salsa.debian.org/med-team/libtabixpp
......
libtabixpp.so.0 libtabixpp0 #MINVER#
_ZN5Tabix11getNextLineERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Base 1.0.0
_ZN5Tabix13getKstringPtrEv@Base 1.1.0
_ZN5Tabix13getNextLineKSEv@Base 1.1.0
_ZN5Tabix9getHeaderERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Base 1.0.0
_ZN5Tabix9setRegionERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Base 1.0.0
_ZN5TabixC1ERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Base 1.0.0
......
......@@ -4,25 +4,28 @@ Description: Build shared lib with Debian's htslib
Debian's shared libhts from the archive.
Also builds a shared library instead of a static one.
Author: Sascha Steinbiss <sascha@steinbiss.name>
--- a/Makefile
+++ b/Makefile
@@ -3,11 +3,12 @@
--- libtabixpp.orig/Makefile
+++ libtabixpp/Makefile
@@ -3,7 +3,7 @@
CC?= gcc
CXX?= g++
-CXXFLAGS?= -g -Wall -O2 -fPIC #-m64 #-arch ppc
+CXXFLAGS+= -fPIC
+CXXFLAGS+= -fPIC
INCLUDES?= -Ihtslib
HTS_HEADERS?= htslib/htslib/bgzf.h htslib/htslib/tbx.h
HTS_LIB?= htslib/libhts.a
LIBPATH?= -L. -Lhtslib
+SONUMBER=0
@@ -12,6 +12,7 @@
DFLAGS= -D_FILE_OFFSET_BITS=64 -D_USE_KNETFILE
PROG= tabix++
@@ -18,32 +19,24 @@
SUBDIRS=.
+SONUMBER=0
ifeq ($(OS),Windows_NT)
LIBS += -lws2_32
@@ -22,31 +23,22 @@
.c.o:
$(CC) -c $(CXXFLAGS) $(DFLAGS) $(INCLUDES) $< -o $@
$(CC) $(CPPFLAGS) -c $(CXXFLAGS) $(DFLAGS) $(INCLUDES) $< -o $@
-all-recur lib-recur clean-recur cleanlocal-recur install-recur:
- @target=`echo $@ | sed s/-recur//`; \
......@@ -34,13 +37,13 @@ Author: Sascha Steinbiss <sascha@steinbiss.name>
- || exit 1; \
- cd $$wdir; \
- done;
+all: $(PROG) libtabixpp.so.$(SONUMBER) libtabixpp.a
+all: $(PROG) libtabixpp.so.$(SONUMBER) libtabixpp.a
-all: $(PROG)
-
-tabix.o: $(HTS_HEADERS) tabix.cpp tabix.hpp
+tabix.o: tabix.cpp tabix.hpp
$(CXX) $(CXXFLAGS) -c tabix.cpp $(INCLUDES)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c tabix.cpp $(INCLUDES)
-htslib/libhts.a:
- cd htslib && $(MAKE) lib-static
......@@ -52,15 +55,13 @@ Author: Sascha Steinbiss <sascha@steinbiss.name>
-tabix++: tabix.o main.cpp $(HTS_LIB)
+tabix++: tabix.o main.cpp
$(CXX) $(CXXFLAGS) -o $@ main.cpp tabix.o $(INCLUDES) $(LIBPATH) \
-lhts -lpthread -lm -lz
$(CXX) $(LDFLAGS) $(CPPFLAGS) $(CXXFLAGS) -o $@ main.cpp tabix.o $(INCLUDES) $(LIBPATH) $(LIBS)
cleanlocal:
rm -fr gmon.out *.o a.out *.dSYM $(PROG) *~ *.a tabix.aux tabix.log \
- tabix.pdf *.class libtabix.*.dylib libtabix.so*
- cd htslib && $(MAKE) clean
+ tabix.pdf *.class libtabix*.dylib libtabix*so*
+ #cd htslib && $(MAKE) clean
-clean:cleanlocal-recur
+clean: cleanlocal
Author: Michael R. Crusoe <michael.crusoe@gmail.com>
Description: enable hardening flags passthrough
--- libtabixpp.orig/Makefile
+++ libtabixpp/Makefile
@@ -17,12 +17,12 @@
.SUFFIXES:.c .o
.c.o:
- $(CC) -c $(CXXFLAGS) $(DFLAGS) $(INCLUDES) $< -o $@
+ $(CC) $(CPPFLAGS) -c $(CXXFLAGS) $(DFLAGS) $(INCLUDES) $< -o $@
all: $(PROG) libtabixpp.so.$(SONUMBER) libtabixpp.a
tabix.o: tabix.cpp tabix.hpp
- $(CXX) $(CXXFLAGS) -c tabix.cpp $(INCLUDES)
+ $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c tabix.cpp $(INCLUDES)
libtabixpp.a: tabix.o
ar rcs $@ $<
@@ -31,7 +31,7 @@
$(CXX) -shared -o $@ $< -fPIC -Wl,-soname,libtabixpp.so.$(SONUMBER) $(LDFLAGS) -lhts
tabix++: tabix.o main.cpp
- $(CXX) $(CXXFLAGS) -o $@ main.cpp tabix.o $(INCLUDES) $(LIBPATH) \
+ $(CXX) $(LDFLAGS) $(CPPFLAGS) $(CXXFLAGS) -o $@ main.cpp tabix.o $(INCLUDES) $(LIBPATH) \
-lhts -lpthread -lm -lz
cleanlocal:
build_shared_lib_with_debian_htslib.patch
hardening
......@@ -5,6 +5,9 @@ Tabix::Tabix(void) { }
Tabix::Tabix(string& file) {
has_jumped = false;
filename = file;
str.l = 0;
str.m = 0;
str.s = NULL;
const char* cfilename = file.c_str();
struct stat stat_tbi,stat_vcf;
char *fnidx = (char*) calloc(strlen(cfilename) + 5, 1);
......@@ -47,18 +50,22 @@ Tabix::Tabix(string& file) {
// set up the iterator, defaults to the beginning
current_chrom = chroms.begin();
iter = tbx_itr_querys(tbx, current_chrom->c_str());
iter = tbx_itr_querys(tbx, (current_chrom != chroms.end() ? current_chrom->c_str() : ""));
}
Tabix::~Tabix(void) {
tbx_itr_destroy(iter);
tbx_destroy(tbx);
free(str.s);
}
const kstring_t * Tabix::getKstringPtr(){
return &str;
}
void Tabix::getHeader(string& header) {
header.clear();
kstring_t str = {0,0,0};
while ( hts_getline(fn, KS_SEP_LINE, &str) >= 0 ) {
if ( !str.l || str.s[0]!=tbx->conf.meta_char ) {
break;
......@@ -70,7 +77,7 @@ void Tabix::getHeader(string& header) {
// set back to start
current_chrom = chroms.begin();
if (iter) tbx_itr_destroy(iter);
iter = tbx_itr_querys(tbx, current_chrom->c_str());
iter = tbx_itr_querys(tbx, (current_chrom != chroms.end() ? current_chrom->c_str() : ""));
}
bool Tabix::setRegion(string& region) {
......@@ -81,7 +88,6 @@ bool Tabix::setRegion(string& region) {
}
bool Tabix::getNextLine(string& line) {
kstring_t str = {0,0,0};
if (has_jumped) {
if (iter && tbx_itr_next(fn, tbx, iter, &str) >= 0) {
line = string(str.s);
......@@ -93,8 +99,8 @@ bool Tabix::getNextLine(string& line) {
line = string(str.s);
return true;
} else {
++current_chrom;
while (current_chrom != chroms.end()) {
// While we aren't at the end, advance. While we're still not at the end...
while (current_chrom != chroms.end() && ++current_chrom != chroms.end()) {
tbx_itr_destroy(iter);
iter = tbx_itr_querys(tbx, current_chrom->c_str());
if (iter && tbx_itr_next(fn, tbx, iter, &str) >= 0) {
......@@ -108,3 +114,33 @@ bool Tabix::getNextLine(string& line) {
}
}
}
bool Tabix::getNextLineKS() {
if (has_jumped) {
if (iter &&
tbx_itr_next(fn, tbx, iter, &str) >= 0) {
//line = &str;
return true;
} else
return false;
} else { // step through all sequences in the file
// we've never jumped, so read everything
if (iter && tbx_itr_next(fn, tbx, iter, &str) >= 0) {
//line = &str;
return true;
} else {
// While we aren't at the end, advance. While we're still not at the end...
while (current_chrom != chroms.end() && ++current_chrom != chroms.end()) {
tbx_itr_destroy(iter);
iter = tbx_itr_querys(tbx, current_chrom->c_str());
if (iter && tbx_itr_next(fn, tbx, iter, &str) >= 0) {
//line = &str;
return true;
} else {
++current_chrom;
}
}
return false;
}
}
}
......@@ -15,6 +15,7 @@ class Tabix {
htsFile* fn;
tbx_t* tbx;
kstring_t str;
hts_itr_t* iter;
const tbx_conf_t *idxconf;
int tid, beg, end;
......@@ -23,7 +24,6 @@ class Tabix {
vector<string>::iterator current_chrom;
public:
string filename;
vector<string> chroms;
......@@ -31,8 +31,10 @@ public:
Tabix(string& file);
~Tabix(void);
const kstring_t * getKstringPtr();
void getHeader(string& header);
bool setRegion(string& region);
bool getNextLine(string& line);
bool getNextLineKS();
};