Log total variant/genome/ref counts.
authorTom Clegg <tom@tomclegg.ca>
Tue, 21 Sep 2021 13:59:03 +0000 (09:59 -0400)
committerTom Clegg <tom@tomclegg.ca>
Tue, 21 Sep 2021 13:59:03 +0000 (09:59 -0400)
refs #17966

Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

slice.go

index 50f219fb3cb6fba95d2b61817085a83f3ebf070b..10e5e01bc2fce55de83dfba0d7f0d5492f904bf3 100644 (file)
--- a/slice.go
+++ b/slice.go
@@ -16,6 +16,7 @@ import (
        "runtime"
        "strings"
        "sync"
        "runtime"
        "strings"
        "sync"
+       "sync/atomic"
 
        "git.arvados.org/arvados.git/sdk/go/arvados"
        "github.com/klauspost/pgzip"
 
        "git.arvados.org/arvados.git/sdk/go/arvados"
        "github.com/klauspost/pgzip"
@@ -105,6 +106,10 @@ func Slice(dstdir, srcdir string, tagsPerFile int) error {
                bufws      []*bufio.Writer
                gzws       []*pgzip.Writer
                encs       []*gob.Encoder
                bufws      []*bufio.Writer
                gzws       []*pgzip.Writer
                encs       []*gob.Encoder
+
+               countTileVariants int64
+               countGenomes      int64
+               countReferences   int64
        )
 
        throttle := throttle{Max: runtime.GOMAXPROCS(0)}
        )
 
        throttle := throttle{Max: runtime.GOMAXPROCS(0)}
@@ -145,6 +150,7 @@ func Slice(dstdir, srcdir string, tagsPerFile int) error {
                                if err := throttle.Err(); err != nil {
                                        return err
                                }
                                if err := throttle.Err(); err != nil {
                                        return err
                                }
+                               atomic.AddInt64(&countTileVariants, int64(len(ent.TileVariants)))
                                for _, tv := range ent.TileVariants {
                                        err := encs[int(tv.Tag)/tagsPerFile].Encode(LibraryEntry{
                                                TileVariants: []TileVariant{tv},
                                for _, tv := range ent.TileVariants {
                                        err := encs[int(tv.Tag)/tagsPerFile].Encode(LibraryEntry{
                                                TileVariants: []TileVariant{tv},
@@ -158,6 +164,7 @@ func Slice(dstdir, srcdir string, tagsPerFile int) error {
                                // genome, even if there are no
                                // variants in the relevant range.
                                // Easier for downstream code.
                                // genome, even if there are no
                                // variants in the relevant range.
                                // Easier for downstream code.
+                               atomic.AddInt64(&countGenomes, int64(len(ent.CompactGenomes)))
                                for _, cg := range ent.CompactGenomes {
                                        for i, enc := range encs {
                                                start := i * tagsPerFile
                                for _, cg := range ent.CompactGenomes {
                                        for i, enc := range encs {
                                                start := i * tagsPerFile
@@ -185,6 +192,7 @@ func Slice(dstdir, srcdir string, tagsPerFile int) error {
                                }
                                // Write all ref seqs to the first
                                // slice. Easier for downstream code.
                                }
                                // Write all ref seqs to the first
                                // slice. Easier for downstream code.
+                               atomic.AddInt64(&countReferences, int64(len(ent.CompactSequences)))
                                if len(ent.CompactSequences) > 0 {
                                        err := encs[0].Encode(LibraryEntry{CompactSequences: ent.CompactSequences})
                                        if err != nil {
                                if len(ent.CompactSequences) > 0 {
                                        err := encs[0].Encode(LibraryEntry{CompactSequences: ent.CompactSequences})
                                        if err != nil {
@@ -201,6 +209,7 @@ func Slice(dstdir, srcdir string, tagsPerFile int) error {
                closeOutFiles(fs, bufws, gzws, encs)
                return throttle.Err()
        }
                closeOutFiles(fs, bufws, gzws, encs)
                return throttle.Err()
        }
+       defer log.Printf("Total %d tile variants, %d genomes, %d reference sequences", countTileVariants, countGenomes, countReferences)
        return closeOutFiles(fs, bufws, gzws, encs)
 }
 
        return closeOutFiles(fs, bufws, gzws, encs)
 }