[med-svn] [Git][med-team/nim-hts][master] Finalize Autopkgtests

Nilesh Patra gitlab at salsa.debian.org
Sun Nov 1 07:25:12 GMT 2020



Nilesh Patra pushed to branch master at Debian Med / nim-hts


Commits:
b414d086 by Nilesh Patra at 2020-11-01T12:53:13+05:30
Finalize Autopkgtests

- - - - -


6 changed files:

- debian/control
- debian/nim-hts-examples.install
- + debian/tests/control
- + debian/tests/run-unit-test
- + debian/tests/test1.nim
- + debian/tests/test2.nim


Changes:

=====================================
debian/control
=====================================
@@ -19,7 +19,7 @@ Rules-Requires-Root: no
 Package: nim-hts-dev
 Architecture: all
 Depends: ${misc:Depends}, nim
-Recommends: libhts3
+Recommends: libhts3, libhts-dev
 Suggests: nim-hts-examples
 Description: wrapper for hts C library
  The hts library is well accepted for the handling of millions of


=====================================
debian/nim-hts-examples.install
=====================================
@@ -2,7 +2,7 @@ tests/*.nim			usr/share/doc/hts-nim-examples
 tests/*.sam			usr/share/doc/hts-nim-examples
 tests/test_files		usr/share/doc/hts-nim-examples
 tests/*.vcf			usr/share/doc/hts-nim-examples
-tests/*.bcf			usr/share/doc/hts-nim-examples
+tests/*.bcf*			usr/share/doc/hts-nim-examples
 tests/*.bam*			usr/share/doc/hts-nim-examples
 tests/*.fa*			usr/share/doc/hts-nim-examples
 debian/missing-sources/*	usr/share/doc/hts-nim-examples


=====================================
debian/tests/control
=====================================
@@ -0,0 +1,3 @@
+Tests: run-unit-test
+Depends: @, libhts3, libhts-dev
+Restrictions: allow-stderr


=====================================
debian/tests/run-unit-test
=====================================
@@ -0,0 +1,29 @@
+#!/bin/bash
+set -e
+
+pkg="nim-hts-dev"
+
+if [ "$AUTOPKGTEST_TMP" = "" ] ; then
+  AUTOPKGTEST_TMP=`mktemp -d /tmp/${pkg}-test.XXXXXX`
+  trap "rm -rf $AUTOPKGTEST_TMP" 0 INT QUIT ABRT PIPE TERM
+fi
+
+cp -a /usr/share/doc/hts-nim-examples/* $AUTOPKGTEST_TMP
+
+cd $AUTOPKGTEST_TMP
+gunzip -r *
+
+echo "TEST 1"
+nim -p:/usr/share/nimble/hts -p:/usr/lib/x86_64-linux-gnu/ c test1.nim
+./test1
+rm -f ./test1
+echo "======================================="
+echo "PASS"
+
+echo "TEST 2"
+nim -p:/usr/share/nimble/hts/ c test2.nim
+./test2
+rm -f ./test2
+echo "======================================="
+echo "PASS"
+


=====================================
debian/tests/test1.nim
=====================================
@@ -0,0 +1,24 @@
+import hts
+
+# open a bam/cram and look for the index.
+var b:Bam
+open(b, "HG02002.bam", index=true, fai="aa.fa")
+
+for record in b:
+  if record.mapping_quality > 10u:
+    echo record.chrom, record.start, record.stop
+
+# regional queries:
+for record in b.query("6", 30816675, 32816675):
+  if record.flag.proper_pair and record.flag.reverse:
+    # cigar is an iterable of operations:
+    for op in record.cigar:
+      # $op gives the string repr of the operation, e.g. '151M'
+      echo $op, " ", op.consumes.reference, " ", op.consumes.query
+
+    # tags are pulled by type `ta`
+    var mismatches = tag[int](record, "NM")
+    if not mismatches.isNone and mismatches.get < 3:
+      var rg = tag[string](record, "RG")
+      if not rg.isNone: echo rg.get
+


=====================================
debian/tests/test2.nim
=====================================
@@ -0,0 +1,38 @@
+import hts
+
+var tsamples = @["101976-101976", "100920-100920", "100231-100231", "100232-100232", "100919-100919"]
+# VCF and BCF supported
+var v:VCF
+doAssert(open(v, "test.bcf", samples=tsamples))
+
+var afs = new_seq[float32](5) # size doesn't matter. this will be re-sized as needed
+var acs = new_seq[int32](5) # size doesn't matter. this will be re-sized as needed
+var csq = new_string_of_cap(20)
+for rec in v:
+  echo rec, " qual:", rec.QUAL, " filter:", rec.FILTER
+  var info = rec.info
+  # accessing stuff from the INFO field is meant to be as fast as possible, allowing
+  # the user to re-use memory as needed.
+  doAssert info.get("CSQ", csq) == Status.OK # string
+  doAssert info.get("AC", acs) == Status.OK # ints
+  doAssert info.get("AF", afs) == Status.OK # floats
+  echo acs, afs, csq, info.has_flag("IN_EXAC")
+
+  # accessing format fields is similar
+  var dps = new_seq[int32](len(v.samples))
+  doAssert rec.format.get("DP", dps) == Status.OK
+
+# open a VCF for writing
+var wtr:VCF
+doAssert(open(wtr, "outv.vcf", mode="w"))
+wtr.header = v.header
+doAssert(wtr.write_header())
+
+# regional queries look for index. works for VCF and BCF
+for rec in v.query("1:15600-18250"):
+  echo rec.CHROM, ":", $rec.POS
+  # adjust some values in the INFO
+  var val = 22.3
+  doAssert rec.info.set("VQSLOD", val) == Status.OK
+  doAssert wtr.write_variant(rec)
+



View it on GitLab: https://salsa.debian.org/med-team/nim-hts/-/commit/b414d086386c00963314dc6aac91e5b7a7f50326

-- 
View it on GitLab: https://salsa.debian.org/med-team/nim-hts/-/commit/b414d086386c00963314dc6aac91e5b7a7f50326
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/20201101/0854978b/attachment-0001.html>


More information about the debian-med-commit mailing list