log.Printf("tag library %s load done", cmd.tagLibraryFile)
tilelib := tileLibrary{taglib: &taglib}
+ go func() {
+ for range time.Tick(10 * time.Second) {
+ log.Printf("tilelib.Len() == %d", tilelib.Len())
+ }
+ }()
tseqs, err := cmd.tileGVCFs(&tilelib, infiles)
if err != nil {
return 1
variant [][][blake2b.Size]byte
// count [][]int
// seq map[[blake2b.Size]byte][]byte
+ variants int
mtx sync.Mutex
}
return ret, scanner.Err()
}
+func (tilelib *tileLibrary) Len() int {
+ tilelib.mtx.Lock()
+ defer tilelib.mtx.Unlock()
+ return tilelib.variants
+}
+
// Return a tileLibRef for a tile with the given tag and sequence,
// adding the sequence to the library if needed.
func (tilelib *tileLibrary) getRef(tag tagID, seq []byte) tileLibRef {
// if tilelib.seq == nil {
// tilelib.seq = map[[blake2b.Size]byte][]byte{}
// }
- if len(tilelib.variant) <= int(tag) {
- tilelib.variant = append(tilelib.variant, make([][][blake2b.Size]byte, int(tag)-len(tilelib.variant)+1)...)
+ if tilelib.variant == nil {
+ tilelib.variant = make([][][blake2b.Size]byte, tilelib.taglib.Len())
}
hash, err := blake2b.New(32, nil)
if err != nil {
return tileLibRef{tag: tag, variant: tileVariantID(i + 1)}
}
}
+ tilelib.variants++
tilelib.variant[tag] = append(tilelib.variant[tag], seqhash)
// tilelib.seq[seqhash] = append([]byte(nil), seq...)
return tileLibRef{tag: tag, variant: tileVariantID(len(tilelib.variant[tag]))}