[med-svn] [Git][med-team/nim-hts][master] 7 commits: Fix watchfile to detect new versions on github

Andreas Tille (@tille) gitlab at salsa.debian.org
Tue Oct 12 06:52:40 BST 2021



Andreas Tille pushed to branch master at Debian Med / nim-hts


Commits:
350fe2df by Andreas Tille at 2021-10-12T07:43:27+02:00
Fix watchfile to detect new versions on github

- - - - -
6f357a96 by Andreas Tille at 2021-10-12T07:43:30+02:00
New upstream version 0.3.18+ds
- - - - -
24642194 by Andreas Tille at 2021-10-12T07:43:30+02:00
routine-update: New upstream version

- - - - -
69939d33 by Andreas Tille at 2021-10-12T07:43:31+02:00
Update upstream source from tag 'upstream/0.3.18+ds'

Update to upstream version '0.3.18+ds'
with Debian dir 48f8d56500a4dc1598faddbc24c311b79863055a
- - - - -
0a8d3003 by Andreas Tille at 2021-10-12T07:43:31+02:00
routine-update: Standards-Version: 4.6.0

- - - - -
5f49d6f3 by Andreas Tille at 2021-10-12T07:43:38+02:00
Apply multi-arch hints.
+ nim-hts-examples: Add Multi-Arch: foreign.

Changes-By: apply-multiarch-hints

- - - - -
b7b62b80 by Andreas Tille at 2021-10-12T07:44:35+02:00
routine-update: Ready to upload to unstable

- - - - -


15 changed files:

- CHANGES.md
- Dockerfile
- README.md
- debian/changelog
- debian/control
- debian/watch
- docker/docker.nim.cfg
- hts.nimble
- src/hts/bam.nim
- src/hts/private/hts_concat.h
- src/hts/private/hts_concat.nim
- src/hts/vcf.nim
- tests/test_readme.nim
- + tests/test_same_header.vcf.gz
- tests/vcftest.nim


Changes:

=====================================
CHANGES.md
=====================================
@@ -1,3 +1,20 @@
+v0.3.18
+=======
++ [vcf] fix for #77 for to avoid double-free of header when it's re-used.
+
+v0.3.17
+=======
++ turn quits into exceptions
+
+v0.3.16
+=======
++ expose VCF.fname
++ change rendering of unknown alleles to fix './.'
+
+v0.3.15
+=======
++ vcf: expose a couple more functions from htslib
+
 v0.3.14
 =======
 + add close method to fai for consistency (continues to also occur automatically upon garbage collection) #70


=====================================
Dockerfile
=====================================
@@ -4,7 +4,7 @@ FROM alpine:3.11.5
 ENV CFLAGS="-fPIC -O3"
 
 RUN apk add wget git xz bzip2-static musl m4 autoconf tar xz-dev bzip2-dev build-base libpthread-stubs libzip-dev gfortran \
-	    openssl-libs-static openblas-static pcre-dev curl llvm-dev curl-static bash
+    openssl-libs-static openblas-static pcre-dev curl llvm-dev curl-static bash curl-dev clang-static nghttp2-static
 
 RUN mkdir -p /usr/local/include && \
     git clone --depth 1 https://github.com/ebiggers/libdeflate.git && \
@@ -15,8 +15,9 @@ RUN mkdir -p /usr/local/include && \
     cd .. && \
     rm -rf cloudflare-zlib
 
+
 RUN cd / && \
-    git clone -b v1.2.6 git://github.com/nim-lang/nim nim && \
+    git clone -b v1.4.8 git://github.com/nim-lang/nim nim && \
     cd nim &&  \
     sh ./build_all.sh && \
     rm -rf csources && \
@@ -37,14 +38,14 @@ RUN apk add cmake openssl-dev && \
 ENV PATH=:/root/.nimble/bin:/nim/bin/:$PATH	
 
 RUN \
-    git clone https://github.com/samtools/htslib && \
-    cd htslib && git checkout 1.11 && autoheader && autoconf && \
-    ./configure --disable-s3 --disable-libcurl --with-libdeflate && \
+    git clone -b 1.13 --recursive https://github.com/samtools/htslib && \
+    cd htslib && autoheader && autoconf && \
+    ./configure --enable-s3 --enable-libcurl --with-libdeflate && \
     make -j4 CFLAGS="-fPIC -O3" install && \
     cd ../ && \
-    git clone https://github.com/samtools/bcftools && \
-    cd bcftools && git checkout 1.10.2 && autoheader && autoconf && \
-    ./configure --disable-s3 --disable-libcurl --with-libdeflate && \
+    git clone -b 1.13 --recursive https://github.com/samtools/bcftools && \
+    cd bcftools && autoheader && autoconf && \
+    ./configure --enable-s3 --enable-libcurl --with-libdeflate && \
     make -j4 CFLAGS="-fPIC -O3" install && \
     cd ../ && rm -rf htslib bcftools
 
@@ -52,10 +53,8 @@ RUN \
 RUN sh -c 'curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -q -y'
 #	    && apk add clang-libs
 
-ENV HTSLIB=system
 ENV PATH=$PATH:~/.cargo/bin/
-
-#COPY docker/d4.patch /tmp/
+ENV RUSTFLAGS=-Ctarget-feature=-crt-static
 
 #&& git apply < /tmp/d4.patch \
 RUN ~/.cargo/bin/rustup target add x86_64-unknown-linux-musl \


=====================================
README.md
=====================================
@@ -176,3 +176,19 @@ At this time, libcurl is not supported so only binaries built using this method
 
 The docker images does use [libdeflate](https://github.com/ebiggers/libdeflate) by default. That provides,
 for example, a 20% speed improvement when used to build [mosdepth](https://github.com/brentp/mosdepth).
+
+### Static binary with singularity
+
+The default static build setup uses docker on linux. This is not possible on some clusters. To build a project using singularity, use something like this:
+
+```
+singularity run \
+	    --bind $(pwd):/load \
+	    --bind /scratch \
+	    --bind /uufs \
+            'docker://brentp/musl-hts-nim:latest' /usr/local/bin/nsb -n slivar.nimble -s src/slivar.nim -- -d:danger -d:release
+```
+where the first `bind` is required as-is. The other binds can be modified to adjust which paths on the machine need to be available to access all 
+local source files. This command will create a `slivar` executable in `pwd`.
+Then, replace `slivar.nimble` with your nimble file and `src/slivar.nim` with your main source file.
+It's also sometimes useful to replace `-d:danger -d:release` with `-d:debug` to get a debug build.


=====================================
debian/changelog
=====================================
@@ -1,3 +1,18 @@
+nim-hts (0.3.18+ds-1) unstable; urgency=medium
+
+  * Team upload.
+  * New upstream version
+  * Standards-Version: 4.6.0 (routine-update)
+
+ -- Andreas Tille <tille at debian.org>  Tue, 12 Oct 2021 07:43:40 +0200
+
+nim-hts (0.3.14+ds-3) UNRELEASED; urgency=medium
+
+  * Team upload.
+  * Fix watchfile to detect new versions on github
+
+ -- Andreas Tille <tille at debian.org>  Tue, 12 Oct 2021 07:43:27 +0200
+
 nim-hts (0.3.14+ds-2) unstable; urgency=medium
 
   * d/p/fix-version-comparision.patch: Fix version comparison


=====================================
debian/control
=====================================
@@ -11,7 +11,7 @@ Build-Depends: debhelper-compat (= 13),
                samtools,
                tabix,
                bcftools
-Standards-Version: 4.5.1
+Standards-Version: 4.6.0
 Homepage: https://github.com/brentp/hts-nim
 Vcs-Browser: https://salsa.debian.org/med-team/nim-hts
 Vcs-Git: https://salsa.debian.org/med-team/nim-hts.git
@@ -31,6 +31,7 @@ Package: nim-hts-examples
 Architecture: all
 Depends: ${misc:Depends}
 Enhances: nim-hts-dev
+Multi-Arch: foreign
 Description: examples for nim-hts: wrapper for hts C library
  The hts library is well accepted for the handling of millions of
  DNA sequences from what once was the high-throughput sequencing machines


=====================================
debian/watch
=====================================
@@ -1,4 +1,4 @@
 version=4
 
 opts="filenamemangle=s%(?:.*?)?v?(\d[\d.]*)\.tar\.gz%@PACKAGE at -$1.tar.gz%,repacksuffix=+ds,dversionmangle=auto" \
-https://github.com/brentp/hts-nim/releases .*/archive/v?@ANY_VERSION@\.tar\.gz
+https://github.com/brentp/hts-nim/releases .*/v?@ANY_VERSION@\.tar\.gz


=====================================
docker/docker.nim.cfg
=====================================
@@ -4,8 +4,9 @@
   passC:"-static"
 #define:"lapack=openblas"
 #  define:"blas=openblas"
-  passl:"-static -no-pie -fno-pie"
+  passl:"-static -no-pie -fno-pie -Wl,--start-group"
   passl:"/usr/lib/libm.a"
+  passl:"/usr/lib/libcurl.a"
   passl:"/usr/local/lib/libhts.a"
   passl:"/usr/local/lib/libdeflate.a"
   passl:"/usr/local/lib/libz.a"
@@ -24,10 +25,8 @@
   passl:"/usr/lib/libc.a"
   passl:"/usr/lib/librt.a"
   passl:"/usr/lib/libpcre.a"
-  passl:"/usr/lib/libd4binding.a"
 
-#  passl:"/usr/local/lib/libnghttp2.a"
-#  passl:"/usr/lib/libcurl.a"
+  passl:"/usr/lib/libnghttp2.a"
 
 #  passl:"/usr/local/lib/libnghttp2.a"
 #  passl:"/usr/lib/libcurl.a"


=====================================
hts.nimble
=====================================
@@ -1,6 +1,6 @@
 # Package
 
-version       = "0.3.14"
+version       = "0.3.18"
 author        = "Brent Pedersen"
 description   = "hts (bam/sam) for nim"
 license       = "MIT"


=====================================
src/hts/bam.nim
=====================================
@@ -169,14 +169,14 @@ proc mate_chrom*(r: Record): string {.inline.} =
     return ""
   return $r.hdr.hdr.target_name[tid]
 
-proc mate_tid*(r: Record): int {.inline.} =
-  ## `mate_tid` returns the tid of the mate or -1 if not mapped.
-  result = r.b.core.mtid
-
 proc tid*(r: Record): int {.inline.} =
   ## `tid` returns the tid of the alignment or -1 if not mapped.
   result = r.b.core.tid
 
+proc mate_tid*(r: Record): int {.inline.} =
+  ## `mate_tid` returns the tid of the mate or -1 if not mapped.
+  result = r.b.core.mtid
+
 proc start*(r: Record): int64 {.inline.} =
   ## `start` returns 0-based start position.
   return r.b.core.pos


=====================================
src/hts/private/hts_concat.h
=====================================
@@ -607,6 +607,7 @@ int bcf_hdr_printf(bcf_hdr_t *h, const char *format, ...);
 void bcf_hdr_remove(bcf_hdr_t *h, int type, const char *key);
 
 int bcf_hdr_add_sample(bcf_hdr_t *hdr, const char *sample);
+bcf_hdr_t *bcf_hdr_merge(bcf_hdr_t *dst, const bcf_hdr_t *src);
 
 
 


=====================================
src/hts/private/hts_concat.nim
=====================================
@@ -8,10 +8,6 @@ elif defined(macosx):
 else:
   const
     libname* = "libhts.so"
-
-when (NimMajor, NimMinor) < (1, 1):
-  type
-    csize_t* = csize
 ##
 ## enum hts_fmt_option {
 ##     // CRAM specific
@@ -719,6 +715,8 @@ proc bcf_hdr_remove*(h: ptr bcf_hdr_t; `type`: cint; key: cstring) {.cdecl,
     importc: "bcf_hdr_remove", dynlib: libname.}
 proc bcf_hdr_add_sample*(hdr: ptr bcf_hdr_t; sample: cstring): cint {.cdecl,
     importc: "bcf_hdr_add_sample", dynlib: libname.}
+proc bcf_hdr_merge*(dst: ptr bcf_hdr_t; src: ptr bcf_hdr_t): ptr bcf_hdr_t {.cdecl,
+    importc: "bcf_hdr_merge", dynlib: libname.}
 template bcf_hdr_nsamples*(hdr: untyped): untyped =
   (hdr).n[BCF_DT_SAMPLE]
 


=====================================
src/hts/vcf.nim
=====================================
@@ -22,7 +22,7 @@ type
     c: ptr bcf1_t
     bidx: ptr hts_idx_t
     tidx: ptr tbx_t
-    fname: string
+    fname*: string
 
   Variant* = ref object
     ## Variant is a single line from a VCF
@@ -187,7 +187,9 @@ proc remove_format*(h:Header, ID:string): Status =
   return Status(bcf_hdr_sync(h.hdr))
 
 proc destroy_vcf(v:VCF) =
-  bcf_hdr_destroy(v.header.hdr)
+  if v.header != nil and v.header.hdr != nil:
+    bcf_hdr_destroy(v.header.hdr)
+    v.header.hdr = nil
   if v.tidx != nil:
     tbx_destroy(v.tidx)
   if v.bidx != nil:
@@ -196,7 +198,8 @@ proc destroy_vcf(v:VCF) =
     bcf_destroy(v.c)
   if v.fname != "-" and v.fname != "/dev/stdin":
     if v.hts != nil:
-      discard hts_close(v.hts)
+      if hts_close(v.hts) != 0:
+        stderr.write_line "[hts-nim] underlying error closing vcf file"
       v.hts = nil
   else:
     flushFile(stdout)
@@ -576,7 +579,7 @@ iterator items*(v:VCF): Variant =
   if v.c.errcode > 1:
     stderr.write_line "hts-nim/vcf bcf_read error:" & $v.c.errcode
     stderr.write_line "last read variant:", variant.tostring()
-    quit(2)
+    raise newException(IOError, "Error reading variant")
 
 
 type Contig* = object
@@ -639,7 +642,7 @@ iterator vquery(v:VCF, region:string): Variant =
     v.tidx = tbx_index_load(v.fname)
   if v.tidx == nil:
     stderr.write_line("hts-nim/vcf no index found for " & v.fname)
-    quit(2)
+    raise newException(IOError, "No Index found for " & v.fname)
 
   var
     read_func:ptr hts_readrec_func = cast[ptr hts_readrec_func](tbx_readrec)
@@ -695,7 +698,7 @@ iterator query*(v:VCF, region: string): Variant =
 
       if v.bidx == nil:
         stderr.write_line("hts-nim/vcf no index found for " & v.fname)
-        quit(2)
+        raise newException(IOError, "No Index found for " & v.fname)
       var
         start: int64
         stop: int64
@@ -723,7 +726,7 @@ iterator query*(v:VCF, region: string): Variant =
       hts_itr_destroy(itr)
       if ret > 0:
         stderr.write_line "hts-nim/vcf: error parsing "
-        quit(2)
+        raise newException(IOError, "error parsing vcf")
 
     if v.c.errcode != 0:
       stderr.write_line "hts-nim/vcf bcf_read error:" & $v.c.errcode
@@ -859,7 +862,7 @@ proc `$`*(a:Allele): string {.inline.} =
   ## string representation of a single allele.
   if a.value < 0:
     # set end to / so it is removed in '$'
-    result = if int32(a) == 0: "." else: "$"
+    result = if int32(a) == 0: "./" else: "$"
   else:
     result = intToStr(a.value) & (if a.phased: '|' else: '/')
 


=====================================
tests/test_readme.nim
=====================================
@@ -10,7 +10,7 @@ randomize()
 
 proc getRandomNimname(length: int = 8): string =
   result = "test_"
-  for _ in ..length:
+  for _ in 0..length:
     result.add(sample(IdentChars))
   result.add(".nim")
 


=====================================
tests/test_same_header.vcf.gz
=====================================
Binary files /dev/null and b/tests/test_same_header.vcf.gz differ


=====================================
tests/vcftest.nim
=====================================
@@ -285,7 +285,7 @@ suite "vcf suite":
     global_variant.ID = "rs0123456789"
 
     check global_variant.ID == "rs0123456789"
-    check global_variant.tostring.split('\t')[..2] == @["1", "10172", "rs0123456789"]
+    check global_variant.tostring.split('\t')[0..2] == @["1", "10172", "rs0123456789"]
 
   test "new from string":
     var v:VCF
@@ -400,6 +400,22 @@ suite "vcf alleles":
       v.ALT = @["A", "T"]
       check v.ALT == @["A", "T"]
 
+proc write_linked_blocks(ivcf:var VCF, ovcf:var VCF):int = 
+  var current_line: string
+  var v_off = 1
+  var currentBlock = 0
+  doAssert Status.OK == ivcf.header.add_string("""##sgcocaller_v0.1=phaseBlocks""")
+  ovcf.header = ivcf.header
+  doAssert ovcf.write_header()
+  var gt_string:seq[int32]
+  var block_pos_i = 0
+  for v in ivcf.query("*"):
+    gt_string = @[int32(2),int32(5)]
+    if v.format().set("GT",gt_string) != Status.OK:
+      quit "set GT failed"
+    if not ovcf.write_variant(v) :
+      quit "write vcf failed for " & $voff
+  return 0
 
 suite "bug suite":
     test "csq reader":
@@ -411,6 +427,25 @@ suite "bug suite":
             var st = variant.info.get("CSQ", anno)
             check st in {Status.OK, Status.NotFound}
 
+    test "re-use same header issue 77":
+      let threads = 1
+      var chrs = @["chr1", "chr1"]
+
+      var ivcf,ovcf: VCF
+      var inFile,outFile:string
+
+      for chrName in chrs:
+        inFile  = "tests/test_same_header.vcf.gz"
+        outFile = "__x.vcf.gz"
+        if not open(ivcf, inFile, threads=threads):
+            quit "couldn't open input vcf file"
+        if not open(ovcf, outFile, threads=threads, mode ="w"):
+          quit "couldn't open output vcf file"
+        doAssert 0 == write_linked_blocks(ivcf,ovcf)
+        ivcf.close()
+        ovcf.close()
+
+
 import times
 
 suite "speed tests":



View it on GitLab: https://salsa.debian.org/med-team/nim-hts/-/compare/ec5566514f2546ea1d403096282ca526f5e89915...b7b62b80f68aa77984216554ec76b92e77abd4d4

-- 
View it on GitLab: https://salsa.debian.org/med-team/nim-hts/-/compare/ec5566514f2546ea1d403096282ca526f5e89915...b7b62b80f68aa77984216554ec76b92e77abd4d4
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/20211012/300dfa0b/attachment-0001.htm>


More information about the debian-med-commit mailing list