From 90c007db869ee1a0e0bf662b19eabfb1187ff44e Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Wed, 7 Oct 2020 09:22:50 -0400 Subject: [PATCH] When writing library, write tags too. Arvados-DCO-1.1-Signed-off-by: Tom Clegg --- import.go | 1 + taglib.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/import.go b/import.go index e24b25dfac..30e86a153f 100644 --- a/import.go +++ b/import.go @@ -156,6 +156,7 @@ func (cmd *importer) RunCommand(prog string, args []string, stdin io.Reader, std tilelib := &tileLibrary{taglib: taglib, includeNoCalls: cmd.includeNoCalls, skipOOO: cmd.skipOOO} if cmd.outputTiles { + cmd.encoder.Encode(LibraryEntry{TagSet: taglib.Tags()}) tilelib.encoder = cmd.encoder } go func() { diff --git a/taglib.go b/taglib.go index 3dc45b80c0..f92a91f375 100644 --- a/taglib.go +++ b/taglib.go @@ -117,3 +117,17 @@ func (taglib *tagLibrary) setTags(tags [][]byte) error { } return nil } + +func (taglib *tagLibrary) Tags() [][]byte { + out := make([][]byte, len(taglib.tagmap)) + untwobit := []byte{'a', 'c', 'g', 't'} + for key, info := range taglib.tagmap { + seq := make([]byte, taglib.keylen) + for i := len(seq) - 1; i >= 0; i-- { + seq[i] = untwobit[int(key)&3] + key = key >> 2 + } + out[int(info.id)] = seq + } + return out +} -- 2.30.2