[med-svn] [Git][med-team/pybigwig][upstream] New upstream version 0.3.18+dfsg

Andreas Tille (@tille) gitlab at salsa.debian.org
Thu Feb 17 15:35:15 GMT 2022



Andreas Tille pushed to branch upstream at Debian Med / pybigwig


Commits:
a6dedc88 by Andreas Tille at 2022-02-17T16:32:30+01:00
New upstream version 0.3.18+dfsg
- - - - -


9 changed files:

- + .environmentLinux.yaml
- + .github/workflows/build.yml
- + .github/workflows/pypi.yml
- − .travis.yml
- README.md
- pyBigWig.c
- pyBigWig.h
- pyBigWigTest/test.py
- setup.py


Changes:

=====================================
.environmentLinux.yaml
=====================================
@@ -0,0 +1,13 @@
+name: foo
+channels:
+  - conda-forge
+  - bioconda
+  - default
+dependencies:
+  - gcc_linux-64
+  - curl
+  - zlib
+  - python 3.8
+  - pip
+  - numpy
+  - nose


=====================================
.github/workflows/build.yml
=====================================
@@ -0,0 +1,19 @@
+on: pull_request
+jobs:
+  testLinux:
+    name: TestLinux
+    runs-on: "ubuntu-latest"
+    defaults:
+      run:
+        shell: bash -l {0}
+    steps:
+      - uses: actions/checkout at v2
+      - uses: conda-incubator/setup-miniconda at v2
+        with:
+          activate-environment: foo
+          environment-file: .environmentLinux.yaml
+          python-version: 3.8
+          auto-activate-base: false
+      - run: |
+          pip install .
+          nosetests -sv


=====================================
.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 at 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/*


=====================================
.travis.yml deleted
=====================================
@@ -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


=====================================
README.md
=====================================
@@ -7,6 +7,7 @@ Table of Contents
 =================
 
   * [Installation](#installation)
+    * [Requirements](#requirements)
   * [Usage](#usage)
     * [Load the extension](#load-the-extension)
     * [Open a bigWig or bigBed file](#open-a-bigwig-or-bigbed-file)
@@ -34,9 +35,16 @@ You can install this extension directly from github with:
 
 or with conda
 
-    conda install pybigwig -c bioconda
+    conda install pybigwig -c conda-forge -c bioconda
 
-Note that libcurl (and the `curl-config` command) are required for installation. This is typically already installed on many Linux and OSX systems (if you install with conda then this will happen automatically).
+## Requirements
+
+The follow non-python requirements must be installed:
+
+ - libcurl (and the `curl-config` config)
+ - zlib
+
+The headers and libraries for these are required.
 
 # Usage
 Basic usage is as follows:


=====================================
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;
 }
 
@@ -378,9 +379,10 @@ static PyObject *pyBwGetStats(pyBigWigFile_t *self, PyObject *args, PyObject *kw
     double *val;
     uint32_t start, end = -1, tid;
     unsigned long startl = 0, endl = -1;
-    static char *kwd_list[] = {"chrom", "start", "end", "type", "nBins", "exact", NULL};
+    static char *kwd_list[] = {"chrom", "start", "end", "type", "nBins", "exact", "numpy", NULL};
     char *chrom, *type = "mean";
     PyObject *ret, *exact = Py_False, *starto = NULL, *endo = NULL;
+    PyObject *outputNumpy = Py_False;
     int i, nBins = 1;
     errno = 0; //In the off-chance that something elsewhere got an error and didn't clear it...
 
@@ -399,7 +401,7 @@ static PyObject *pyBwGetStats(pyBigWigFile_t *self, PyObject *args, PyObject *kw
         return NULL;
     }
 
-    if(!PyArg_ParseTupleAndKeywords(args, kwds, "s|OOsiO", kwd_list, &chrom, &starto, &endo, &type, &nBins, &exact)) {
+    if(!PyArg_ParseTupleAndKeywords(args, kwds, "s|OOsiOO", kwd_list, &chrom, &starto, &endo, &type, &nBins, &exact, &outputNumpy)) {
         PyErr_SetString(PyExc_RuntimeError, "You must supply at least a chromosome!");
         return NULL;
     }
@@ -464,11 +466,26 @@ static PyObject *pyBwGetStats(pyBigWigFile_t *self, PyObject *args, PyObject *kw
 
     //Return a list of None if there are no entries at all
     if(!hasEntries(bw)) {
-        ret = PyList_New(nBins);
-        for(i=0; i<nBins; i++) {
-            Py_INCREF(Py_None);
-            PyList_SetItem(ret, i, Py_None);
+#ifdef WITHNUMPY
+        if(outputNumpy == Py_True) {
+            val = malloc(sizeof(double)*nBins);
+            for(i=0; i<nBins; i++) {
+                val[i] = NPY_NAN;
+            }
+            npy_intp len = nBins;
+            ret = PyArray_SimpleNewFromData(1, &len, NPY_FLOAT64, (void *) val);
+            //This will break if numpy ever stops using malloc!
+            PyArray_ENABLEFLAGS((PyArrayObject*) ret, NPY_ARRAY_OWNDATA);
+        } else {
+#endif
+            ret = PyList_New(nBins);
+            for(i=0; i<nBins; i++) {
+                Py_INCREF(Py_None);
+                PyList_SetItem(ret, i, Py_None);
+            }
+#ifdef WITHNUMPY
         }
+#endif
         return ret;
     }
 
@@ -484,17 +501,27 @@ static PyObject *pyBwGetStats(pyBigWigFile_t *self, PyObject *args, PyObject *kw
         return NULL;
     }
 
-    ret = PyList_New(nBins);
-    for(i=0; i<nBins; i++) {
-        if(isnan(val[i])) {
-            Py_INCREF(Py_None);
-            PyList_SetItem(ret, i, Py_None);
-        } else {
-            PyList_SetItem(ret, i, PyFloat_FromDouble(val[i]));
+#ifdef WITHNUMPY
+    if(outputNumpy == Py_True) {
+        npy_intp len = nBins;
+        ret = PyArray_SimpleNewFromData(1, &len, NPY_FLOAT64, (void *) val);
+        //This will break if numpy ever stops using malloc!
+        PyArray_ENABLEFLAGS((PyArrayObject*) ret, NPY_ARRAY_OWNDATA);
+    } else {
+#endif
+        ret = PyList_New(nBins);
+        for(i=0; i<nBins; i++) {
+            if(isnan(val[i])) {
+                Py_INCREF(Py_None);
+                PyList_SetItem(ret, i, Py_None);
+            } else {
+                PyList_SetItem(ret, i, PyFloat_FromDouble(val[i]));
+            }
         }
+        free(val);
+#ifdef WITHNUMPY
     }
-    free(val);
-
+#endif
     return ret;
 }
 


=====================================
pyBigWig.h
=====================================
@@ -2,7 +2,7 @@
 #include <structmember.h>
 #include "bigWig.h"
 
-#define pyBigWigVersion "0.3.17"
+#define pyBigWigVersion "0.3.18"
 
 typedef struct {
     PyObject_HEAD


=====================================
pyBigWigTest/test.py
=====================================
@@ -308,3 +308,23 @@ class TestNumpy():
 
         bw.close()
         os.remove("/tmp/delete.bw")
+
+    def testNumpyValues(self):
+        if pyBigWig.numpy == 0:
+            return 0
+        import numpy as np
+
+        fname = "http://raw.githubusercontent.com/dpryan79/pyBigWig/master/pyBigWigTest/test.bw"
+        bw = pyBigWig.open(fname, "r")
+
+        assert np.allclose(
+            bw.values("1", 0, 20, numpy=True),
+            np.array(bw.values("1", 0, 20), dtype=np.float32),
+            equal_nan=True
+        )
+
+        assert np.allclose(
+            bw.stats("1", 0, 20, "mean", 5, numpy=True),
+            np.array(bw.stats("1", 0, 20, "mean", 5), dtype=np.float64),
+            equal_nan=True
+        )


=====================================
setup.py
=====================================
@@ -62,7 +62,7 @@ module1 = Extension('pyBigWig',
                     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 at ie-freiburg.mpg.de",



View it on GitLab: https://salsa.debian.org/med-team/pybigwig/-/commit/a6dedc88e646bdc5745ed4d560484a718877ab5e

-- 
View it on GitLab: https://salsa.debian.org/med-team/pybigwig/-/commit/a6dedc88e646bdc5745ed4d560484a718877ab5e
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20220217/9d9bf26a/attachment-0001.htm>


More information about the debian-med-commit mailing list