[med-svn] [Git][med-team/libbigwig][upstream] New upstream version 0.4.6+dfsg

Steffen Möller (@moeller) gitlab at salsa.debian.org
Tue Sep 7 16:34:08 BST 2021



Steffen Möller pushed to branch upstream at Debian Med / libbigwig


Commits:
cfeb025e by Steffen Moeller at 2021-09-07T16:56:47+02:00
New upstream version 0.4.6+dfsg
- - - - -


11 changed files:

- + .environmentLinux.yaml
- + .github/workflows/build.yml
- .travis.yml
- Makefile
- bigWig.h
- bigWigIO.h
- bwRead.c
- bwValues.c
- bwValues.h
- bwWrite.c
- test/test.py


Changes:

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


=====================================
.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 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: |
+          CFLAGS="$CFLAGS -g -Wall -O3 -Wsign-compare"
+          LIBS="$LDFLAGS -lcurl -lm -lz"
+          make test CC=$CC CFLAGS="$CFLAGS" LIBS="$LIBS"


=====================================
.travis.yml
=====================================
@@ -2,7 +2,10 @@ sudo: false
 language: c
 os:
   - linux
-  - osx
+#  - osx
+arch:
+  - amd64
+  - ppc64le
 script: make && make test
 compiler:
   - clang


=====================================
Makefile
=====================================
@@ -2,12 +2,28 @@ CC ?= gcc
 AR ?= ar
 RANLIB ?= ranlib
 CFLAGS ?= -g -Wall -O3 -Wsign-compare
-LIBS = -lcurl -lm -lz
+LIBS = -lm -lz
 EXTRA_CFLAGS_PIC = -fpic
 LDFLAGS =
 LDLIBS =
 INCLUDES = 
 
+# Create a simple test-program to check if gcc can compile with curl
+tmpfile:=$(shell mktemp --suffix=.c)
+$(file >$(tmpfile),#include <curl/curl.h>)
+$(file >>$(tmpfile),int main() { return 0; })
+HAVE_CURL:=$(shell $(CC) $(CFLAGS) $(EXTRA_CFLAGS_PIC) $(LIBS) -lcurl $(tmpfile) -o /dev/null >/dev/null 2>&1 && echo "YES")
+$(shell rm $(tmpfile))
+
+ifeq ($(HAVE_CURL),YES)
+	# If yes, add the library
+	LIBS += -lcurl
+else
+	# and if not, disable CURL specific code compilation
+	CFLAGS += -DNOCURL
+endif
+
+
 prefix = /usr/local
 includedir = $(prefix)/include
 libdir = $(exec_prefix)/lib


=====================================
bigWig.h
=====================================
@@ -1,3 +1,6 @@
+#ifndef LIBBIGWIG_H
+#define LIBBIGWIG_H
+
 #include "bigWigIO.h"
 #include "bwValues.h"
 #include <inttypes.h>
@@ -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


=====================================
bigWigIO.h
=====================================
@@ -1,9 +1,15 @@
+#ifndef LIBBIGWIG_IO_H
+#define LIBBIGWIG_IO_H
+
 #ifndef NOCURL
 #include <curl/curl.h>
 #else
 #include <stdio.h>
+#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


=====================================
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);


=====================================
bwValues.c
=====================================
@@ -1,6 +1,7 @@
 #include "bigWig.h"
 #include "bwCommon.h"
 #include <stdlib.h>
+#include <math.h>
 #include <string.h>
 #include <zlib.h>
 #include <errno.h>
@@ -719,9 +720,9 @@ bwOverlappingIntervals_t *bwGetValues(bigWigFile_t *fp, char *chrom, uint32_t st
     if(!output) goto error;
     if(includeNA) {
         output->l = end-start;
-        output->value = malloc((end-start)*sizeof(float));
+        output->value = malloc(output->l*sizeof(float));
         if(!output->value) goto error;
-        for(i=0; i<end-start; i++) output->value[i] = strtod("NaN", NULL);
+        for(i=0; i<output->l; i++) output->value[i] = NAN;
         for(i=0; i<intermediate->l; i++) {
             for(j=intermediate->start[i]; j<intermediate->end[i]; j++) {
                 if(j < start || j >= end) continue;


=====================================
bwValues.h
=====================================
@@ -1,3 +1,6 @@
+#ifndef LIBBIGWIG_VALUES_H
+#define LIBBIGWIG_VALUES_H
+
 #include <inttypes.h>
 /*! \file bwValues.h
  *
@@ -70,3 +73,5 @@ typedef struct {
     uint8_t type; /**<The block type: 1, bedGraph; 2, variable step; 3, fixed step.*/
     uint16_t nItems; /**<The number of values in a given block.*/
 } bwDataHeader_t;
+
+#endif // LIBBIGWIG_VALUES_H


=====================================
bwWrite.c
=====================================
@@ -1019,7 +1019,7 @@ error:
 
 //Get all of the intervals and add them to the appropriate zoomBuffer
 int constructZoomLevels(bigWigFile_t *fp) {
-    bwOverlappingIntervals_t *intervals = NULL;
+    bwOverlapIterator_t *it = NULL;
     double *sum = NULL, *sumsq = NULL;
     uint32_t i, j, k;
 
@@ -1028,15 +1028,19 @@ int constructZoomLevels(bigWigFile_t *fp) {
     if(!sum || !sumsq) goto error;
 
     for(i=0; i<fp->cl->nKeys; i++) {
-        intervals = bwGetOverlappingIntervals(fp, fp->cl->chrom[i], 0, fp->cl->len[i]);
-        if(!intervals) goto error;
-        for(j=0; j<intervals->l; j++) {
-            for(k=0; k<fp->hdr->nLevels; k++) {
-                if(addIntervalValue(fp, &(fp->writeBuffer->nNodes[k]), sum+k, sumsq+k, fp->writeBuffer->lastZoomBuffer[k], fp->hdr->bufSize/32, fp->hdr->zoomHdrs->level[k], i, intervals->start[j], intervals->end[j], intervals->value[j])) goto error;
-                while(fp->writeBuffer->lastZoomBuffer[k]->next) fp->writeBuffer->lastZoomBuffer[k] = fp->writeBuffer->lastZoomBuffer[k]->next;
-            }
-        }
-        bwDestroyOverlappingIntervals(intervals);
+        it = bwOverlappingIntervalsIterator(fp, fp->cl->chrom[i], 0, fp->cl->len[i], 100000);
+        if(!it) goto error;
+	while(it->data != NULL){
+	  for(j=0;j<it->intervals->l;j++){
+		for(k=0;k<fp->hdr->nLevels;k++){
+			if(addIntervalValue(fp, &(fp->writeBuffer->nNodes[k]), sum+k, sumsq+k, fp->writeBuffer->lastZoomBuffer[k], fp->hdr->bufSize/32, fp->hdr->zoomHdrs->level[k], i, it->intervals->start[j], it->intervals->end[j], it->intervals->value[j])) goto error;
+			while(fp->writeBuffer->lastZoomBuffer[k]->next) fp->writeBuffer->lastZoomBuffer[k] = fp->writeBuffer->lastZoomBuffer[k]->next;
+		}
+	  }
+	  it = bwIteratorNext(it);
+	}
+	bwIteratorDestroy(it);
+
     }
 
     //Make an index for each zoom level
@@ -1046,13 +1050,14 @@ int constructZoomLevels(bigWigFile_t *fp) {
         fp->hdr->zoomHdrs->idx[i]->blockSize = fp->writeBuffer->blockSize;
     }
 
+
     free(sum);
     free(sumsq);
 
     return 0;
 
 error:
-    if(intervals) bwDestroyOverlappingIntervals(intervals);
+    if(it) bwIteratorDestroy(it);
     if(sum) free(sum);
     if(sumsq) free(sumsq);
     return 1;


=====================================
test/test.py
=====================================
@@ -72,3 +72,4 @@ except:
     p2 = Popen(["md5"], stdin=p1.stdout, stdout=PIPE)
 md5sum = p2.communicate()[0].strip().split()[0]
 assert(md5sum == "33ef99571bdaa8c9130149e99332b17b")
+print("success")



View it on GitLab: https://salsa.debian.org/med-team/libbigwig/-/commit/cfeb025eb136eae9cdd7ac8dba70524fe96a5778

-- 
View it on GitLab: https://salsa.debian.org/med-team/libbigwig/-/commit/cfeb025eb136eae9cdd7ac8dba70524fe96a5778
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/20210907/1bcb50bd/attachment-0001.htm>


More information about the debian-med-commit mailing list