[med-svn] [Git][med-team/nim-hts][master] 5 commits: Fix watch file

Andreas Tille (@tille) gitlab at salsa.debian.org
Sun Dec 1 09:06:37 GMT 2024



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


Commits:
e73871a9 by Andreas Tille at 2024-12-01T09:58:11+01:00
Fix watch file

- - - - -
f3314077 by Andreas Tille at 2024-12-01T09:58:39+01:00
New upstream version 0.3.25+ds
- - - - -
f9142572 by Andreas Tille at 2024-12-01T09:58:39+01:00
New upstream version

- - - - -
dfeb8430 by Andreas Tille at 2024-12-01T09:58:40+01:00
Update upstream source from tag 'upstream/0.3.25+ds'

Update to upstream version '0.3.25+ds'
with Debian dir cad488e427bb6ae3fbd3b8d3b5352a5b657cbf05
- - - - -
54a9bc41 by Andreas Tille at 2024-12-01T09:58:40+01:00
Standards-Version: 4.7.0 (routine-update)

- - - - -


17 changed files:

- .travis.yml
- CHANGES.md
- Dockerfile
- README.md
- debian/changelog
- debian/control
- debian/watch
- docker/docker.nim.cfg
- docker/nsb.nim
- hts.nimble
- scripts/install.sh
- src/hts/bam.nim
- src/hts/bgzf/bgzi.nim
- src/hts/private/hts_concat.h
- src/hts/private/hts_concat.nim
- src/hts/vcf.nim
- tests/vcftest.nim


Changes:

=====================================
.travis.yml
=====================================
@@ -1,4 +1,5 @@
 language: c
+dist: bionic
 env:
   - BRANCH=devel
 


=====================================
CHANGES.md
=====================================
@@ -1,3 +1,7 @@
+v0.3.19
+=======
++ [vcf] allow using `vcf.set_samples(@["^"])` to remove all samples
+
 v0.3.18
 =======
 + [vcf] fix for #77 for to avoid double-free of header when it's re-used.


=====================================
Dockerfile
=====================================
@@ -1,29 +1,27 @@
 FROM alpine:3.11.5
 #FROM alpine:20190925
 
+ARG nim_version=1.6.6
+
+
 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 curl-dev clang-static nghttp2-static
+RUN apk update && apk upgrade && 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 curl-dev clang-static nghttp2-static  zlib-static cmake
 
 RUN mkdir -p /usr/local/include && \
-    git clone --depth 1 https://github.com/ebiggers/libdeflate.git && \
-    cd libdeflate && make -j4 CFLAGS="-fPIC -O3" install && \
-    cd .. && rm -rf libdeflate && \
-    git clone https://github.com/cloudflare/zlib cloudflare-zlib && \
-    cd cloudflare-zlib && ./configure && make install && \
-    cd .. && \
-    rm -rf cloudflare-zlib
-
+    git clone -b v1.18 --depth 1 https://github.com/ebiggers/libdeflate.git && \
+    cd libdeflate && cmake -B build && cmake --build build && cmake --install build  && \
+    ln -s /usr/local/lib64/* /usr/local/lib && \
+    cd .. && rm -rf libdeflate
 
 RUN cd / && \
-    git clone -b v1.4.8 git://github.com/nim-lang/nim nim && \
-    cd nim &&  \
-    sh ./build_all.sh && \
-    rm -rf csources && \
-    echo 'PATH=/nim/bin:$PATH' >> ~/.bashrc && \
-    echo 'PATH=/nim/bin:$PATH' >> ~/.bash_profile && \
-    echo 'PATH=/nim/bin:$PATH' >> /etc/environment 
+    wget -q https://nim-lang.org/download/nim-${nim_version}-linux_x64.tar.xz && \
+    tar xf nim-${nim_version}-linux_x64.tar.xz && \
+    echo 'PATH=/nim-${nim_version}/bin:$PATH' >> ~/.bashrc && \
+    echo 'PATH=/nim-${nim_version}/bin:$PATH' >> ~/.bash_profile && \
+    echo 'PATH=/nim-${nim_version}/bin:$PATH' >> /etc/environment  && \
+    rm -f nim-${nim_version}-linux_x64.tar.xz
 
 RUN apk add cmake openssl-dev && \
 	wget https://libzip.org/download/libzip-1.6.1.tar.gz && \
@@ -35,43 +33,38 @@ RUN apk add cmake openssl-dev && \
 	cd ../../ && rm -rf libzip-1.6.1*
 
 
-ENV PATH=:/root/.nimble/bin:/nim/bin/:$PATH	
+ENV PATH=:/root/.nimble/bin:/nim-${nim_version}/bin/:$PATH	
 
 RUN \
-    git clone -b 1.13 --recursive https://github.com/samtools/htslib && \
+    git clone --depth 1 -b 1.18 --recursive https://github.com/samtools/htslib && \
     cd htslib && autoheader && autoconf && \
-    ./configure --enable-s3 --enable-libcurl --with-libdeflate && \
+    ./configure --enable-s3 --enable-gcs --enable-libcurl --with-libdeflate && \
     make -j4 CFLAGS="-fPIC -O3" install && \
     cd ../ && \
-    git clone -b 1.13 --recursive https://github.com/samtools/bcftools && \
+    git clone --depth 1 -b 1.18 --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
 
-
-RUN sh -c 'curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -q -y'
-#	    && apk add clang-libs
-
-ENV PATH=$PATH:~/.cargo/bin/
 ENV RUSTFLAGS=-Ctarget-feature=-crt-static
 
-#&& git apply < /tmp/d4.patch \
-RUN ~/.cargo/bin/rustup target add x86_64-unknown-linux-musl \
+RUN sh -c 'curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -q -y' \
+    && ~/.cargo/bin/rustup target add x86_64-unknown-linux-musl \
 	&& git clone https://github.com/38/d4-format \
 	&& cd d4-format \
-        && ln -s /usr/bin/gcc /usr/bin/musl-gcc \
-	&& ~/.cargo/bin/cargo build --all --target x86_64-unknown-linux-musl --release
-
-RUN install -m 644 d4-format/target/x86_64-unknown-linux-musl/release/libd4binding.a /usr/lib && \
-	install -m 644 d4-format/d4binding/include/d4.h /usr/include
-
-
+    && ln -s /usr/bin/gcc /usr/bin/musl-gcc \
+    && ~/.cargo/bin/cargo build --package=d4binding --release && cd .. \
+    && install -m 644 d4-format/target/release/libd4binding.a /usr/lib \
+	&& install -m 644 d4-format/d4binding/include/d4.h /usr/include  \
+    && rm -rf d4-format/target/  \
+    && rm -rf /root/.rustup/  \
+    && rm -rf ~/.cargo 
+    
 ADD . /src/
-RUN cat /src/docker/docker.nim.cfg >> /nim/config/nim.cfg && \
-    source ~/.bashrc && cd /src/ && nimble install -y && \
+RUN cat /src/docker/docker.nim.cfg >> /nim-${nim_version}/config/nim.cfg && \
+    cd /src/ && nimble install -y && \
     nimble install -y c2nim docopt && \
     nimble install -y websocket@#head && \
     nim c -o:/usr/local/bin/nsb /src/docker/nsb.nim && \
     rm -rf /src/
-


=====================================
README.md
=====================================
@@ -104,6 +104,11 @@ for rec in v.query("1:15600-18250"):
   doAssert rec.info.set("VQSLOD", val) == Status.OK
   doAssert wtr.write_variant(rec)
 
+# Generate index files - .vcf.gz (tbi + csi ) & .bcf (csi)
+var fnameInNew = "tests/test.bcf"
+var fnameIndexCsi = "tests/test00.bcf.csi"
+bcfBuildIndex(fnameInNew, fnameIndexCsi, true) # `true` for csi and `false` for tbi
+
 ```
 
 ## TSV files


=====================================
debian/changelog
=====================================
@@ -1,3 +1,12 @@
+nim-hts (0.3.25+ds-1) UNRELEASED; urgency=medium
+
+  * Team upload.
+  * Fix watch file
+  * New upstream version
+  * Standards-Version: 4.7.0 (routine-update)
+
+ -- Andreas Tille <tille at debian.org>  Sun, 01 Dec 2024 09:58:39 +0100
+
 nim-hts (0.3.18+ds-1) unstable; urgency=medium
 
   * Team upload.


=====================================
debian/control
=====================================
@@ -11,7 +11,7 @@ Build-Depends: debhelper-compat (= 13),
                samtools,
                tabix,
                bcftools
-Standards-Version: 4.6.0
+Standards-Version: 4.7.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


=====================================
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 .*/v?@ANY_VERSION@\.tar\.gz
+https://github.com/brentp/hts-nim/tags .*/v?@ANY_VERSION@\.tar\.gz


=====================================
docker/docker.nim.cfg
=====================================
@@ -6,10 +6,10 @@
 #  define:"blas=openblas"
   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/lib/libcurl.a"
   passl:"/usr/local/lib/libdeflate.a"
-  passl:"/usr/local/lib/libz.a"
+  passl:"/lib/libz.a"
   passl:"/usr/local/lib64/libzip.a"
   passl:"/usr/lib/libbz2.a"
   passl:"/usr/lib/liblzma.a"


=====================================
docker/nsb.nim
=====================================
@@ -46,7 +46,7 @@ if $args["--nimble-file"] != "nil":
   var (dir, _, _) = splitFile(expandFileName($args["--nimble-file"]))
   dir.setCurrentDir
 
-  if execCmd(&"""sh -c "export PATH={path}; /nim/bin/nimble install -d -y " """) != 0:
+  if execCmd(&"""sh -c "export PATH={path}; nimble install -d -y " """) != 0:
     quit "coudn't run nimble install"
 
 
@@ -54,7 +54,7 @@ var (dir, name, _) = splitFile(source)
 dir.setCurrentDir
 
 removeFile("xx_exe_out")
-var cmd = &"""/nim/bin/nim c -d:nsb_static {join(@(args["<nim_compiler_args>"]), " ")} -o:xx_exe_out {name}"""
+var cmd = &"""nim c -d:nsb_static {join(@(args["<nim_compiler_args>"]), " ")} -o:xx_exe_out {name}"""
 if execCmd(&"""sh -c "{cmd}" """) != 0:
   quit "error compiling code"
 


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


=====================================
scripts/install.sh
=====================================
@@ -10,7 +10,7 @@ sudo apt-get -qy install bwa make build-essential cmake libncurses-dev ncurses-d
 
 cd
 
-git clone -b $BRANCH --depth 5 git://github.com/nim-lang/nim nim-$BRANCH/
+git clone -b $BRANCH --depth 5 https://github.com/nim-lang/nim nim-$BRANCH/
 cd nim-$BRANCH
 sh build_all.sh
 


=====================================
src/hts/bam.nim
=====================================
@@ -401,8 +401,14 @@ proc open*(bam: var Bam, path: cstring, threads: int=0, mode:string="r", fai: cs
   bam.hdr = hdr
   bam.rec = rec
 
-  if index:
-    var idx = sam_index_load(bam.hts, path)
+  if index or ("##idx##" in $path):
+
+    var idx = if "##idx##" in $path:
+      let spl = ($path).split("##idx##")
+      doAssert spl.len == 2, "mosdepth: expected ##idx## to separate bam from index path"
+      sam_index_load2(bam.hts, spl[0], spl[1])
+    else:
+      sam_index_load(bam.hts, path)
     if idx != nil:
         bam.idx = idx
     else:


=====================================
src/hts/bgzf/bgzi.nim
=====================================
@@ -68,7 +68,8 @@ iterator query*(bi: BGZI, chrom: string, start:int64, stop:int64): string {.inli
 
   var kstr = kstring_t(s:nil, m:0, l:0)
   var outstr = newStringOfCap(10000)
-  shallow(outstr)
+  when not defined(gcArc) and not defined(gcOrc):
+    shallow(outstr)
 
   while hts_itr_next(bi.bgz.cptr, itr, kstr.addr, bi.csi.tbx.addr) > 0:
     fastSubStr(outstr, kstr.s, 0, int(kstr.l))


=====================================
src/hts/private/hts_concat.h
=====================================
@@ -708,3 +708,22 @@ int bcf_get_info_values(const bcf_hdr_t *hdr, bcf1_t *line, const char *tag, voi
 *  @param str_class: the class of BCF_HL_STR line (e.g. "ALT" or "SAMPLE"), otherwise NULL
 */
 bcf_hrec_t *bcf_hdr_get_hrec(const bcf_hdr_t *hdr, int type, const char *key, const char *value, const char *str_class);
+
+/**
+*  bcf_index_build3() - Generate and save an index to a specific file
+*  @fn:         Input VCF/BCF filename
+*  @fnidx:      Output filename, or NULL to add .csi/.tbi to @fn
+*  @min_shift:  Positive to generate CSI, or 0 to generate TBI
+*  @n_threads:  Number of VCF/BCF decoder threads
+*
+*  Returns 0 if successful, or negative if an error occurred.
+*
+*  List of error codes:
+*      -1 .. indexing failed
+*      -2 .. opening @fn failed
+*      -3 .. format not indexable
+*      -4 .. failed to create and/or save the index
+*/
+
+int bcf_index_build3(const char *fn, const char *fnidx, int min_shift, int n_threads);
+


=====================================
src/hts/private/hts_concat.nim
=====================================
@@ -1,4 +1,3 @@
- {.deadCodeElim: on.}
 when defined(windows):
   const
     libname* = "libhts.dll"
@@ -844,3 +843,22 @@ proc bcf_get_info_values*(hdr: ptr bcf_hdr_t; line: ptr bcf1_t; tag: cstring;
 proc bcf_hdr_get_hrec*(hdr: ptr bcf_hdr_t; `type`: cint; key: cstring; value: cstring;
                       str_class: cstring): ptr bcf_hrec_t {.cdecl,
     importc: "bcf_hdr_get_hrec", dynlib: libname.}
+
+##
+##  bcf_index_build3() - Generate and save an index to a specific file
+##  @fn:         Input VCF/BCF filename
+##  @fnidx:      Output filename, or NULL to add .csi/.tbi to @fn
+##  @min_shift:  Positive to generate CSI, or 0 to generate TBI
+##  @n_threads:  Number of VCF/BCF decoder threads
+##
+##  Returns 0 if successful, or negative if an error occurred.
+##
+##  List of error codes:
+##      -1 .. indexing failed
+##      -2 .. opening @fn failed
+##      -3 .. format not indexable
+##      -4 .. failed to create and/or save the index
+##
+
+proc bcf_index_build3*(fn: cstring, fnidx: cstring, min_shift: cint, n_threads: cint): cint {.cdecl,
+    importc: "bcf_index_build3", dynlib: libname.}


=====================================
src/hts/vcf.nim
=====================================
@@ -89,11 +89,14 @@ proc n_samples*(v:VCF): int {.inline.} =
 
 proc set_samples*(v:VCF, samples:seq[string]) =
   ## set the samples that will be decoded
+  ## use v.set_samples(@["^"]) to exclude all samples.
   var isamples = samples
   if isamples.len == 0:
     isamples = @["-"]
-  var sample_str = join(isamples, ",")
-  var ret = bcf_hdr_set_samples(v.header.hdr, sample_str.cstring, 0)
+  var sample_str = join(isamples, ",").cstring 
+  if isamples.len == 1 and (samples.len == 0 or samples[0] == "^"):
+    sample_str = nil
+  var ret = bcf_hdr_set_samples(v.header.hdr, sample_str, 0)
   doAssert ret >= 0, ("[hts-nim/vcf]: error setting samples in " & v.fname)
   doAssert bcf_hdr_sync(v.header.hdr) == 0, "[hts/nim-vcf] error in vcf.set_samples"
 
@@ -935,6 +938,22 @@ proc `$`*(v:Variant): string =
   return format("Variant($#:$# $#/$#)" % [$v.CHROM, $v.POS, $v.REF, join(v.ALT, ",")])
 
 
+proc bcfBuildIndex*(fnameIn, fnameOut: string; csi: bool = true, threads: int = 1) = 
+  ##  Uses bcf_index_build3() - Generate and save an index to a specific file
+  ##  fnameIn: Input VCF/BCF filename
+  ##  fnameOut: Output filename
+  ##  csi: `true` to generate CSI, or `false` to generate TBI, Note: bcf can't make csi index
+  ##  threads: Number of VCF/BCF decoder threads
+  let errorCode = bcf_index_build3(fnameIn.cstring, fnameOut.cstring, cast[int](csi).cint, threads.cint).int
+  let errorMsg = case errorCode:
+  of -1: "indexing failed"
+  of -2: "opening @fn failed"
+  of -3: "format not indexable"
+  of -4: "failed to create and/or save the index"
+  else: ""
+  if errorMsg != "":
+    raise newException(ValueError, errorMsg)
+
 when isMainModule:
 
   var tsamples = @["101976-101976", "100920-100920", "100231-100231", "100232-100232", "100919-100919"]


=====================================
tests/vcftest.nim
=====================================
@@ -444,6 +444,7 @@ suite "bug suite":
         doAssert 0 == write_linked_blocks(ivcf,ovcf)
         ivcf.close()
         ovcf.close()
+        removeFile(outFile)
 
 
 import times
@@ -471,3 +472,52 @@ suite "speed tests":
           doAssert gts[0][0].value > -2
       v.close()
     echo n, " in .. ", cpuTime() - t, " seconds "
+
+
+suite "vcf indexing suite":
+
+  proc checkIndexWorks(fnameIn: string): bool =
+    var v:VCF
+    doAssert(open(v, fnameIn))
+    for rec in v.query("1:15600-18250"):
+      result = rec.POS >= 0
+      break
+
+  test "index vcf.gz":
+    # Setup
+    var fnameIn = "tests/test.vcf.gz"
+    var fnameInNew = "tests/test00.vcf.gz"
+    var fnameIndexCsi = "tests/test00.vcf.gz.csi"
+    var fnameIndexTbi = "tests/test00.vcf.gz.tbi"
+    copyFile(fnameIn, fnameInNew)
+
+    bcfBuildIndex(fnameInNew, fnameIndexCsi, true, 0)
+    check checkIndexWorks(fnameInNew)
+    removeFile(fnameIndexCsi)
+
+    bcfBuildIndex(fnameInNew, fnameIndexTbi, false, 0)
+    check checkIndexWorks(fnameInNew)
+    removeFile(fnameIndexTbi)
+
+    # Teardown
+    removeFile(fnameInNew)
+
+  test "index bcf":
+    # Setup
+    var fnameIn = "tests/test.bcf"
+    var fnameInNew = "tests/test00.bcf"
+    var fnameIndexCsi = "tests/test00.bcf.csi"
+    var fnameIndexTbi = "tests/test00.bcf.tbi"
+    copyFile(fnameIn, fnameInNew)
+
+    bcfBuildIndex(fnameInNew, fnameIndexCsi, true, 0)
+    check checkIndexWorks(fnameInNew)
+    removeFile(fnameIndexCsi)
+
+    # Can't make tbi for bcf
+    expect ValueError:
+      bcfBuildIndex(fnameInNew, fnameIndexTbi, false, 0)
+      removeFile(fnameIndexTbi)
+
+    # Teardown
+    removeFile(fnameInNew)
\ No newline at end of file



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

-- 
View it on GitLab: https://salsa.debian.org/med-team/nim-hts/-/compare/b7b62b80f68aa77984216554ec76b92e77abd4d4...54a9bc41e0dfa740d267d126f84a433024a7230a
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/20241201/6a90cd4e/attachment-0001.htm>


More information about the debian-med-commit mailing list