Skip to content

Commit

Permalink
Release 1.3.2: bin field bug fix, RTLD_GLOBAL plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
jmarshall committed Sep 13, 2016
2 parents 0f298ce + 5586168 commit 6bed35a
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ HTSPREFIX =
include htslib_vars.mk


PACKAGE_VERSION = 1.3.1
PACKAGE_VERSION = 1.3.2
LIBHTS_SOVERSION = 1


Expand Down
13 changes: 12 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
Noteworthy changes in release 1.3.1 (22 April 2016)
Noteworthy changes in release 1.3.2 (13 September 2016)

* Corrected bin calculation when converting directly from CRAM to BAM.
Previously a small fraction of converted reads would fail Picard's
validation with "bin field of BAM record does not equal value computed"
(SAMtools issue #574).

* Plugins can now signal to HTSlib which of RTLD_LOCAL and RTLD_GLOBAL
they wish to be opened with -- previously they were always RTLD_LOCAL.


Noteworthy changes in release 1.3.1 (22 April 2016)

* Improved error checking and reporting, especially of I/O errors when
writing output files (#17, #315, PR #271, PR #317).
Expand Down
4 changes: 4 additions & 0 deletions cram/cram_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "htslib/bgzf.h"
#include "htslib/faidx.h"

#ifndef PATH_MAX
#define PATH_MAX FILENAME_MAX
#endif

#define TRIAL_SPAN 50
#define NTRIALS 3

Expand Down
2 changes: 1 addition & 1 deletion cram/cram_samtools.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ int bam_construct_seq(bam_seq_t **bp, size_t extra_len,

b->core.tid = rname;
b->core.pos = pos-1;
b->core.bin = bam_reg2bin(pos, end);
b->core.bin = bam_reg2bin(pos-1, end);
b->core.qual = mapq;
b->core.l_qname = qname_len+1;
b->core.flag = flag;
Expand Down
6 changes: 2 additions & 4 deletions hfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,6 @@ static hFILE *hopen_mem(const char *data, const char *mode)
* Plugin and hopen() backend dispatcher *
*****************************************/

#include <ctype.h>

#include "hts_internal.h"
#include "htslib/khash.h"

Expand Down Expand Up @@ -717,8 +715,8 @@ static const struct hFILE_scheme_handler *find_scheme_handler(const char *s)
int i;

for (i = 0; i < sizeof scheme; i++)
if (isalnum(s[i]) || s[i] == '+' || s[i] == '-' || s[i] == '.')
scheme[i] = tolower(s[i]);
if (isalnum_c(s[i]) || s[i] == '+' || s[i] == '-' || s[i] == '.')
scheme[i] = tolower_c(s[i]);
else if (s[i] == ':') break;
else return NULL;

Expand Down
9 changes: 4 additions & 5 deletions hts.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ DEALINGS IN THE SOFTWARE. */
#include <config.h>

#include <zlib.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
Expand Down Expand Up @@ -1848,24 +1847,24 @@ long long hts_parse_decimal(const char *str, char **strend, int flags)
char sign = '+', esign = '+';
const char *s;

while (isspace(*str)) str++;
while (isspace_c(*str)) str++;
s = str;

if (*s == '+' || *s == '-') sign = *s++;
while (*s)
if (isdigit(*s)) n = push_digit(n, *s++);
if (isdigit_c(*s)) n = push_digit(n, *s++);
else if (*s == ',' && (flags & HTS_PARSE_THOUSANDS_SEP)) s++;
else break;

if (*s == '.') {
s++;
while (isdigit(*s)) decimals++, n = push_digit(n, *s++);
while (isdigit_c(*s)) decimals++, n = push_digit(n, *s++);
}

if (*s == 'E' || *s == 'e') {
s++;
if (*s == '+' || *s == '-') esign = *s++;
while (isdigit(*s)) e = push_digit(e, *s++);
while (isdigit_c(*s)) e = push_digit(e, *s++);
if (esign == '-') e = -e;
}

Expand Down
2 changes: 1 addition & 1 deletion htsfile.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH htsfile 1 "22 April 2016" "htslib-1.3.1" "Bioinformatics tools"
.TH htsfile 1 "13 September 2016" "htslib-1.3.2" "Bioinformatics tools"
.SH NAME
htsfile \- identify high-throughput sequencing data files
.\"
Expand Down
24 changes: 23 additions & 1 deletion plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,35 @@ const char *hts_path_itr_next(struct hts_path_itr *itr)
return NULL;
}


#ifndef RTLD_NOLOAD
#define RTLD_NOLOAD 0
#endif

void *load_plugin(void **pluginp, const char *filename, const char *symbol)
{
void *lib = dlopen(filename, RTLD_NOW | RTLD_LOCAL);
if (lib == NULL) goto error;

void *sym = dlsym(lib, symbol);
if (sym == NULL) goto error;
if (sym == NULL) {
// Reopen the plugin with RTLD_GLOBAL and check for uniquified symbol
void *libg = dlopen(filename, RTLD_NOLOAD | RTLD_NOW | RTLD_GLOBAL);
if (libg == NULL) goto error;
dlclose(lib);
lib = libg;

kstring_t symbolg = { 0, 0, NULL };
kputs(symbol, &symbolg);
kputc('_', &symbolg);
const char *slash = strrchr(filename, '/');
const char *basename = slash? slash+1 : filename;
kputsn(basename, strcspn(basename, ".-+"), &symbolg);

sym = dlsym(lib, symbolg.s);
free(symbolg.s);
if (sym == NULL) goto error;
}

*pluginp = lib;
return sym;
Expand Down
3 changes: 1 addition & 2 deletions sam.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ DEALINGS IN THE SOFTWARE. */
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include <zlib.h>
#include "htslib/sam.h"
#include "htslib/bgzf.h"
Expand Down Expand Up @@ -888,7 +887,7 @@ int sam_parse1(kstring_t *s, bam_hdr_t *h, bam1_t *b)
uint32_t *cigar;
size_t n_cigar = 0;
for (q = p; *p && *p != '\t'; ++p)
if (!isdigit(*p)) ++n_cigar;
if (!isdigit_c(*p)) ++n_cigar;
if (*p++ != '\t') goto err_ret;
_parse_err(n_cigar == 0, "no CIGAR operations");
_parse_err(n_cigar >= 65536, "too many CIGAR operations");
Expand Down
2 changes: 1 addition & 1 deletion tabix.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH tabix 1 "22 April 2016" "htslib-1.3.1" "Bioinformatics tools"
.TH tabix 1 "13 September 2016" "htslib-1.3.2" "Bioinformatics tools"
.SH NAME
.PP
bgzip \- Block compression/decompression utility
Expand Down

0 comments on commit 6bed35a

Please sign in to comment.