From 10f36fe01c48503c496c8634b9b0e91fffccd660 Mon Sep 17 00:00:00 2001 From: Devon Ryan Date: Sat, 6 Feb 2021 18:23:44 +0100 Subject: [PATCH 1/5] Fix issue #111, handle empty files AND those with empty summaries. --- libBigWig/bwRead.c | 2 +- pyBigWig.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libBigWig/bwRead.c b/libBigWig/bwRead.c index 893cd7c..c467a45 100644 --- a/libBigWig/bwRead.c +++ b/libBigWig/bwRead.c @@ -371,7 +371,7 @@ bigWigFile_t *bwOpen(char *fname, CURLcode (*callBack) (CURL*), const char *mode } //Read in the index - if(bwg->hdr->nBasesCovered) { + if(bwg->hdr->indexOffset) { bwg->idx = bwReadIndex(bwg, 0); if(!bwg->idx) { fprintf(stderr, "[bwOpen] bwg->idx is NULL bwg->hdr->dataOffset 0x%"PRIx64"!\n", bwg->hdr->dataOffset); diff --git a/pyBigWig.c b/pyBigWig.c index 6bf2adc..16e7109 100644 --- a/pyBigWig.c +++ b/pyBigWig.c @@ -197,7 +197,8 @@ char *getNumpyStr(PyArrayObject *obj, Py_ssize_t i) { //Return 1 if there are any entries at all int hasEntries(bigWigFile_t *bw) { - if(bw->hdr->nBasesCovered > 0) return 1; + if(bw->hdr->indexOffset != 0) return 1; // No index, no entries pyBigWig issue #111 + //if(bw->hdr->nBasesCovered > 0) return 1; // Sometimes headers are broken return 0; } From f694f5abbd99c86857ab3b94503b027787ca7ed0 Mon Sep 17 00:00:00 2001 From: Devon Ryan Date: Sun, 7 Feb 2021 11:37:18 +0100 Subject: [PATCH 2/5] Bump version, switch to github actions --- .environmentLinux.yaml | 12 ++++++++++++ .github/workflows/build.yml | 20 ++++++++++++++++++++ libBigWig/bigWig.h | 10 +++++++++- libBigWig/bigWigIO.h | 8 ++++++++ libBigWig/bwValues.h | 5 +++++ pyBigWig.h | 2 +- setup.py | 2 +- 7 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 .environmentLinux.yaml create mode 100644 .github/workflows/build.yml diff --git a/.environmentLinux.yaml b/.environmentLinux.yaml new file mode 100644 index 0000000..582ab4a --- /dev/null +++ b/.environmentLinux.yaml @@ -0,0 +1,12 @@ +name: foo +channels: + - conda-forge + - bioconda + - default +dependencies: + - gcc_linux-64 + - curl + - zlib + - python 3.8 + - pip + - numpy diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..6c82a56 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,20 @@ +on: pull_request +jobs: + testLinux: + name: TestLinux + runs-on: "ubuntu-latest" + defaults: + run: + shell: bash -l {0} + steps: + - uses: actions/checkout@v2 + - uses: conda-incubator/setup-miniconda@v2 + with: + activate-environment: foo + environment-file: .environmentLinux.yaml + python-version: 3.8 + auto-activate-base: false + - run: | + CFLAGS="$CFLAGS -g -Wall -O3 -Wsign-compare" + LIBS="$LDFLAGS -lcurl -lm -lz" + make test CC=$CC CFLAGS="$CFLAGS" LIBS="$LIBS" diff --git a/libBigWig/bigWig.h b/libBigWig/bigWig.h index 313459a..1e8a5ba 100644 --- a/libBigWig/bigWig.h +++ b/libBigWig/bigWig.h @@ -1,3 +1,6 @@ +#ifndef LIBBIGWIG_H +#define LIBBIGWIG_H + #include "bigWigIO.h" #include "bwValues.h" #include @@ -53,15 +56,18 @@ extern "C" { /*! * The library version number */ -#define LIBBIGWIG_VERSION 0.4.4 +#define LIBBIGWIG_VERSION 0.4.6 /*! * If 1, then this library was compiled with remote file support. */ #ifdef NOCURL #define LIBBIGWIG_CURL 0 +#ifndef CURLTYPE_DEFINED +#define CURLTYPE_DEFINED typedef int CURLcode; typedef void CURL; +#endif #else #define LIBBIGWIG_CURL 1 #endif @@ -596,3 +602,5 @@ int bwAppendIntervalSpanSteps(bigWigFile_t *fp, float *values, uint32_t n); #ifdef __cplusplus } #endif + +#endif // LIBBIGWIG_H diff --git a/libBigWig/bigWigIO.h b/libBigWig/bigWigIO.h index 3e7889e..106de2f 100644 --- a/libBigWig/bigWigIO.h +++ b/libBigWig/bigWigIO.h @@ -1,9 +1,15 @@ +#ifndef LIBBIGWIG_IO_H +#define LIBBIGWIG_IO_H + #ifndef NOCURL #include #else #include +#ifndef CURLTYPE_DEFINED +#define CURLTYPE_DEFINED typedef int CURLcode; typedef void CURL; +#endif #define CURLE_OK 0 #define CURLE_FAILED_INIT 1 #endif @@ -100,3 +106,5 @@ URL_t *urlOpen(char *fname, CURLcode (*callBack)(CURL*), const char* mode); * @warning URL will no longer point to a valid location in memory! */ void urlClose(URL_t *URL); + +#endif // LIBBIGWIG_IO_H diff --git a/libBigWig/bwValues.h b/libBigWig/bwValues.h index 2dcf062..75f8acf 100644 --- a/libBigWig/bwValues.h +++ b/libBigWig/bwValues.h @@ -1,3 +1,6 @@ +#ifndef LIBBIGWIG_VALUES_H +#define LIBBIGWIG_VALUES_H + #include /*! \file bwValues.h * @@ -70,3 +73,5 @@ typedef struct { uint8_t type; /** #include "bigWig.h" -#define pyBigWigVersion "0.3.17" +#define pyBigWigVersion "0.3.18" typedef struct { PyObject_HEAD diff --git a/setup.py b/setup.py index 8806a7d..e9e1915 100755 --- a/setup.py +++ b/setup.py @@ -62,7 +62,7 @@ include_dirs = include_dirs) setup(name = 'pyBigWig', - version = '0.3.17', + version = '0.3.18', description = 'A package for accessing bigWig files using libBigWig', author = "Devon P. Ryan", author_email = "ryan@ie-freiburg.mpg.de", From a3a6b8da8fff093376f4b314bfb6b6d88c8301b7 Mon Sep 17 00:00:00 2001 From: Devon Ryan Date: Sun, 7 Feb 2021 11:40:09 +0100 Subject: [PATCH 3/5] update github actions --- .environmentLinux.yaml | 1 + .github/workflows/build.yml | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.environmentLinux.yaml b/.environmentLinux.yaml index 582ab4a..6e35ff9 100644 --- a/.environmentLinux.yaml +++ b/.environmentLinux.yaml @@ -10,3 +10,4 @@ dependencies: - python 3.8 - pip - numpy + - nose diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6c82a56..eb58be8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,6 +15,5 @@ jobs: python-version: 3.8 auto-activate-base: false - run: | - CFLAGS="$CFLAGS -g -Wall -O3 -Wsign-compare" - LIBS="$LDFLAGS -lcurl -lm -lz" - make test CC=$CC CFLAGS="$CFLAGS" LIBS="$LIBS" + pip install . + nosetests -sv From 54c776e34f035ec33663e25a9a8d9910eec6460f Mon Sep 17 00:00:00 2001 From: Devon Ryan Date: Sun, 7 Feb 2021 11:44:51 +0100 Subject: [PATCH 4/5] remove travis --- .travis.yml | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4d6f3b1..0000000 --- a/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -language: python -python: - - "3.5" - - "3.6" -install: - - pip install numpy && python ./setup.py install -matrix: - include: - - python: 3.7 - dist: xenial -script: nosetests -sv From 7dbec7780c8eecd81a3a3ffc3f7a40ad4bbd4ee4 Mon Sep 17 00:00:00 2001 From: Devon Ryan Date: Sun, 7 Feb 2021 13:42:22 +0100 Subject: [PATCH 5/5] Try autouploads to pypi on tags --- .github/workflows/pypi.yml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/pypi.yml diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml new file mode 100644 index 0000000..0675d09 --- /dev/null +++ b/.github/workflows/pypi.yml @@ -0,0 +1,37 @@ +name: pypi +on: [push] +jobs: + pypi: + name: upload to pypi + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Setup conda + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') + run: | + curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -o miniconda.sh + bash miniconda.sh -b -p $HOME/miniconda + export PATH="$HOME/miniconda/bin:$PATH" + hash -r + conda config --set always_yes yes --set changeps1 no + - name: create env + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') + run: | + export PATH=$HOME/miniconda/bin:$PATH + conda create -n foo -q --yes -c conda-forge -c bioconda python=3.7 twine numpy libcurl curl zlib + - name: sdist + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') + run: | + export PATH=$HOME/miniconda/bin:$PATH + source activate foo + rm -f dist/* + python setup.py sdist + - name: upload + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') + env: + TWINE_USERNAME: "__token__" + TWINE_PASSWORD: ${{ secrets.pypi_password }} + run: | + export PATH=$HOME/miniconda/bin:$PATH + source activate foo + twine upload dist/*