Skip to content

Commit

Permalink
Merge pull request #22 from wtsi-npg/devel
Browse files Browse the repository at this point in the history
devel to master merge
  • Loading branch information
dozy authored Sep 14, 2016
2 parents cfef8aa + 2eea11a commit ffbbe47
Show file tree
Hide file tree
Showing 254 changed files with 1,272 additions and 331 deletions.
59 changes: 38 additions & 21 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Control file for continuous integration testing at http://travis-ci.org/

language: c

addons:
Expand All @@ -9,30 +7,49 @@ addons:

matrix:
include:
- os: linux
compiler: clang
- os: linux
compiler: gcc
# An unoptimised C99 build, for detecting non-static inline functions
- os: linux
compiler: gcc
env: CFLAGS="-std=gnu99 -O0"
- os: osx
compiler: gcc
- os: linux
compiler: clang
- os: linux
compiler: gcc
- os: linux
compiler: gcc
env: CFLAGS="-std=gnu99 -O0"
- os: osx
compiler: gcc

env:
global:
- HTSLIB=`pwd`/htslib
- HTSDIR=$HTSLIB/b
- SAMTOOLSDIR=samtools
- PATH=$SAMTOOLSDIR:$PATH
- HTSLIB=`pwd`/htslib
- HTSDIR=$HTSLIB/b
- SAMTOOLSDIR=`pwd`/samtools
- PATH=$SAMTOOLSDIR:$PATH
- DISTCHECK_CONFIGURE_FLAGS=--with-htslib=$HTSDIR

install:
- .travis/clone ${HTSREPO:-git://github.com/samtools/htslib.git} $HTSLIB master
- .travis/clone ${HTSREPO:-git://github.com/samtools/samtools.git} $SAMTOOLSDIR master
- .travis/clone ${HTSREPO:-git://github.com/samtools/htslib.git} $HTSLIB master
- .travis/clone ${HTSREPO:-git://github.com/samtools/samtools.git} $SAMTOOLSDIR master

before_script:
- (cd $HTSLIB && autoreconf && mkdir b && ./configure --prefix=$HTSDIR && make && make install)
- (cd $SAMTOOLSDIR && autoconf && make)
- (cd $HTSLIB && autoreconf && mkdir b && ./configure --prefix=$HTSDIR && make && make install)
- (cd $SAMTOOLSDIR && autoconf && make)

script: autoreconf -i && ./configure -V && ./configure --with-htslib=$HTSDIR && make distcheck

after_success:
- make dist
- export DIST_FILE=$(ls bambi-*.tar.gz)
- export SHA256_FILE=$DIST_FILE.sha256
- shasum -a 256 $DIST_FILE > $SHA256_FILE

script: autoreconf -i && ./configure -V && ./configure --with-htslib=$HTSDIR && make -e && make -e check
deploy:
provider: releases
api_key:
secure: ThARbt8qf7uZsgT/2Di49LOeeUI5NKUP7OKm8WIG2POrjHoxMBFn6xwirRfDLdIGWc93WUjK99y5o0PcHzkvgsqBKMsmBdb3Gar34Wn35Xc7rW/kChv95cXKWAVT12I212Qltiq0M8Ge8tLTou3P5IF/gKZD/aCvTCR+HkZP6WNS63zM+0RxFptw9BUqlPSfBHRJmk6zPLBkxSrq126Um3FEDEr33lU7uOvEiY69gnpQBVNBNS+g4fD/6Trvdj8x3s/IqnnGp4b4Vmz11nK9bkKOavVzFYplq0z//7fpOhhsCppD1pNhyUX9JHZ+/hEkZ1pGzx2QHIHrp23e54CRiWKEFBZ88LJOH7Hjiht7HfdaMUVwF+j8yWD3+3VIhspCk04un9uIFoG0x6IJ1kfzLpvpYuxhdnvCZymfMbsRkvx9vOyeLARZXiw8+UEYDJNxPqho1tJoQtrW5f0CkpQFkSw5qn/VYdotyuVw8fkpK1g/zjzWKS+2Av2XLTFf67ULZeArdaAZqxXI5vnKg3YkJDdkQ8/eiXTYhKkjTP8bx4RXbcdXDTGUPXJBNd6wm4h+KMsa9+Yht1iU3xuALCV3wi8KdNRPA3IDrCH0aXxI5hulqR+iPkMPXsbyhh/TyENkNuB6TgSSNpkeH9Y6kCuODEywT2D5CEEaZMADt+jEINs=
file:
- $DIST_FILE
- $SHA256_FILE
skip_cleanup: true
on:
tags: true
repo: jenniferliddle/bambi
branch: master
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ACLOCAL_AMFLAGS= -I m4
TESTS = test/posfile/t_posfile test/filterfile/t_filterfile test/bclfile/t_bclfile test/decode/t_decode test/i2b/t_i2b
SUBDIRS = src test/posfile test/bclfile test/filterfile test/decode test/i2b
#DIST_SUBDIRS = test/decode/data test/decode/out test/i2b/data test/i2b/out
dist_doc_DATA = README.md LICENSE
AM_COLOR_TESTS=always
3 changes: 2 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
AC_INIT([bambi], m4_esyscmd_s([git describe --dirty --always --tags]), [[email protected]])
AC_ARG_VAR(HTSDIR,Directory to look for hts)
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects tar-pax no-dependencies])
AC_PROG_CC

LT_INIT
Expand All @@ -17,6 +17,7 @@ CPPFLAGS="$HTSLIB_CPPFLAGS"
LDFLAGS="$HTSLIB_LDFLAGS"
AC_CHECK_HEADERS([cram/sam_header.h])
AC_CHECK_LIB([hts], [bam_aux_update_str], [AC_DEFINE([HAVE_BAM_AUX_UPDATE_STR],[1],[Does htslib contain bam_aux_update_str()?])])
AC_CHECK_LIB([hts], [sam_hdr_del], [AC_DEFINE([HAVE_SAM_HDR_DEL],[1],[Does htslib contain sam_hdr_del()?])])
CPPFLAGS="$saved_CPPFLAGS"
LDFLAGS="$saved_LDFLAGS"

Expand Down
4 changes: 3 additions & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ AM_CPPFLAGS = $(HTSLIB_CPPFLAGS)
AM_LDFLAGS = -rdynamic $(HTSLIB_LDFLAGS)

bin_PROGRAMS = bambi
bambi_SOURCES = bambi.c bclfile.c decode.c filterfile.c hts_addendum.c i2b.c posfile.c
bambi_SOURCES = bambi.c bclfile.c decode.c filterfile.c hts_addendum.c i2b.c posfile.c array.c \
bambi.h bclfile.h filterfile.h hts_addendum.h posfile.h array.h
nobase_include_HEADERS = cram/cram_samtools.h cram/pooled_alloc.h cram/sam_header.h cram/string_alloc.h
bambi_CFLAGS = -I/usr/include/libxml2
bambi_LDADD = $(HTSLIB_HOME)/lib/libhts.a -ldl -lxml2 -lz -llzma -lbz2 -lpthread
97 changes: 97 additions & 0 deletions src/array.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/* array.c -- simple array handling functions.
Copyright (C) 2016 Genome Research Ltd.
Author: Jennifer Liddle <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "array.h"

/*
* integer array functions
*/

int ia_compare(const void *ia1, const void *ia2)
{
return *(int *)ia1 - *(int *)ia2;
}

void ia_sort(ia_t *ia)
{
qsort(ia->entries, ia->end, sizeof(int), ia_compare);
}

void ia_push(ia_t *ia, int i)
{
if (ia->end == ia->max) {
// expand the array
ia->max *= 2;
ia->entries = realloc(ia->entries, ia->max * sizeof(int));
}
ia->entries[ia->end] = i;
ia->end++;
}

void ia_free(ia_t *ia)
{
free(ia->entries);
free(ia);
}

ia_t *ia_init(int max)
{
ia_t *ia = calloc(1, sizeof(ia_t));
ia->end = 0;
ia->max = max;
ia->entries = calloc(ia->max, sizeof(int));
return ia;
}


/*
* generic arrays
*/

va_t *va_init(int max, void(*free_entry)(void*))
{
va_t *va = calloc(1,sizeof(va_t));
va->end = 0;
va->max = max;
va->free_entry = free_entry;
va->entries = calloc(va->max, sizeof(void *));
return va;
}

void va_push(va_t *va, void *ent)
{
if (va->end == va->max) {
// expand the array
va->max *= 2;
va->entries = realloc(va->entries, va->max * sizeof(void *));
}
va->entries[va->end] = ent;
va->end++;
}

void va_free(va_t *va)
{
int n;
if (!va) return;
for (n=0; n < va->end; n++) {
va->free_entry(va->entries[n]);
}
free(va->entries);
free(va);
}

60 changes: 60 additions & 0 deletions src/array.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/* array.h -- simple array handling functions.
Copyright (C) 2016 Genome Research Ltd.
Author: Jennifer Liddle <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef __ARRAY_H__
#define __ARRAY_H__

#include <stdbool.h>
#include <stdlib.h>

/*
* integer array functions
*/

typedef struct {
int end;
int max;
int *entries;
} ia_t;

ia_t *ia_init(int max);
int ia_compare(const void *ia1, const void *ia2);
void ia_sort(ia_t *ia);
void ia_push(ia_t *ia, int i);
void ia_free(ia_t *ia);
static inline bool ia_isEmpty(ia_t *ia) { return (ia->end == 0); }


/*
* generic arrays
*/

typedef struct {
int end;
int max;
void (*free_entry)(void *);
void **entries;
} va_t;

va_t *va_init(int max, void(*free_entry)(void*));
void va_push(va_t *va, void *ent);
void va_free(va_t *va);
static inline bool va_isEmpty(va_t *va) { return va->end == 0; }

#endif

2 changes: 1 addition & 1 deletion src/bambi.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef __BAMBI_H__
#define __BAMBI_H__

#include "hts_addendum.h"
#include "config.h"
#include "hts_addendum.h"
const char *bambi_version(void);

#endif
Expand Down
2 changes: 2 additions & 0 deletions src/hts_addendum.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ int bam_aux_update_str(bam1_t *b, const char tag[2], int len, const char *data)
}
#endif

#ifndef HAVE_SAM_HDR_DEL
SAM_hdr *sam_hdr_del(SAM_hdr *hdr, char *type, char *ID_key, char *ID_value) {
int i,n;
int *lines;
Expand All @@ -81,4 +82,5 @@ SAM_hdr *sam_hdr_del(SAM_hdr *hdr, char *type, char *ID_key, char *ID_value) {
free(newtext);
return hdr;
}
#endif

5 changes: 5 additions & 0 deletions src/hts_addendum.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "cram/sam_header.h"
#include "cram/cram_samtools.h"

#ifndef HAVE_BAM_AUX_UPDATE_STR
int bam_aux_update_str(bam1_t *b, const char tag[2], int len, const char *data);
#endif

#ifndef HAVE_SAM_HDR_DEL
SAM_hdr * sam_hdr_del(SAM_hdr *hdr, char *type, char *ID_key, char *ID_value);
#endif

#endif

Loading

0 comments on commit ffbbe47

Please sign in to comment.