Test numpy annotations.
authorTom Clegg <tom@tomclegg.ca>
Mon, 15 Mar 2021 14:50:10 +0000 (10:50 -0400)
committerTom Clegg <tom@tomclegg.ca>
Mon, 15 Mar 2021 14:50:10 +0000 (10:50 -0400)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

exportnumpy.go
exportnumpy_test.go
testdata/tinyref.fasta [moved from testdata/ref with 100% similarity]

index a323ba970b271b182c26c7f8b17ddb4aa60dbe55..69701bae52247b918d359282c1ed6c25684c0366 100644 (file)
@@ -148,9 +148,9 @@ func (cmd *exportNumpy) RunCommand(prog string, args []string, stdin io.Reader,
                }
        }
 
-       log.Info("building numpy array")
-       names := cgnames(tilelib)
+       log.Info("building lowqual map")
        lowqual := lowqual(tilelib)
+       names := cgnames(tilelib)
 
        if *labelsFilename != "" {
                log.Infof("writing labels to %s", *labelsFilename)
@@ -177,6 +177,7 @@ func (cmd *exportNumpy) RunCommand(prog string, args []string, stdin io.Reader,
 
        chunksize := (len(tilelib.variant) + *chunks - 1) / *chunks
        for chunk := 0; chunk < *chunks; chunk++ {
+               log.Infof("preparing chunk %d of %d", chunk+1, *chunks+1)
                tagstart := chunk * chunksize
                tagend := tagstart + chunksize
                if tagend > len(tilelib.variant) {
index 9dd71da82b833014ef826cbad6c9e0db05988e87..fe593a23a9e6d70a9ebe93e23af1453003c5c5ad 100644 (file)
@@ -2,6 +2,7 @@ package lightning
 
 import (
        "bytes"
+       "io/ioutil"
        "os"
 
        "github.com/kshedden/gonpy"
@@ -13,11 +14,13 @@ type exportSuite struct{}
 var _ = check.Suite(&exportSuite{})
 
 func (s *exportSuite) TestFastaToNumpy(c *check.C) {
+       tmpdir := c.MkDir()
+
        var buffer bytes.Buffer
-       exited := (&importer{}).RunCommand("import", []string{"-local=true", "-tag-library", "testdata/tags", "-ref", "testdata/ref", "-output-tiles", "testdata/a.1.fasta"}, &bytes.Buffer{}, &buffer, os.Stderr)
+       exited := (&importer{}).RunCommand("import", []string{"-local=true", "-tag-library", "testdata/tags", "-output-tiles", "-save-incomplete-tiles", "testdata/a.1.fasta", "testdata/tinyref.fasta"}, &bytes.Buffer{}, &buffer, os.Stderr)
        c.Assert(exited, check.Equals, 0)
        var output bytes.Buffer
-       exited = (&exportNumpy{}).RunCommand("export-numpy", []string{"-local=true"}, &buffer, &output, os.Stderr)
+       exited = (&exportNumpy{}).RunCommand("export-numpy", []string{"-local=true", "-output-annotations", tmpdir + "/annotations.csv"}, &buffer, &output, os.Stderr)
        c.Check(exited, check.Equals, 0)
        npy, err := gonpy.NewReader(&output)
        c.Assert(err, check.IsNil)
@@ -33,6 +36,10 @@ func (s *exportSuite) TestFastaToNumpy(c *check.C) {
        for i := 4; i < 9; i += 2 {
                c.Check(variants[i], check.Equals, int16(1), check.Commentf("i=%d, v=%v", i, variants))
        }
+       annotations, err := ioutil.ReadFile(tmpdir + "/annotations.csv")
+       c.Check(err, check.IsNil)
+       c.Check(string(annotations), check.Matches, `(?ms).*1,2,chr1:g.84_85insACTGCGATCTGA\n.*`)
+       c.Check(string(annotations), check.Matches, `(?ms).*1,1,chr1:g.87_96delinsGCATCTGCA\n.*`)
 }
 
 func sortUints(variants []int16) {
similarity index 100%
rename from testdata/ref
rename to testdata/tinyref.fasta