bufw := bufio.NewWriter(output)
tilelib := &tileLibrary{
- includeNoCalls: true,
+ retainNoCalls: true,
retainTileSequences: true,
}
- err = tilelib.LoadGob(context.Background(), input, nil)
+ err = tilelib.LoadGob(context.Background(), input, strings.HasSuffix(*inputFilename, ".gz"), nil)
if err != nil {
return 1
}
sort.Strings(refs)
log.Infof("len(refs) %d", len(refs))
- outch := make(chan string, 1)
+ outch := make(chan string, runtime.NumCPU()*2)
var outwg sync.WaitGroup
defer outwg.Wait()
outwg.Add(1)
nseqs += len(refcs)
}
- throttle := &throttle{Max: runtime.NumCPU() + nseqs + 1}
+ throttle := &throttle{Max: runtime.NumCPU()*2 + nseqs*2 + 1}
defer throttle.Wait()
for _, refname := range refs {
throttle.Acquire()
go func() {
defer throttle.Release()
- throttle.Report(cmd.annotateSequence(throttle, outch, tilelib, taglen, refname, seqname, refcs[seqname]))
+ throttle.Report(cmd.annotateSequence(throttle, outch, tilelib, taglen, refname, seqname, refcs[seqname], len(refs) > 1))
}()
}
}
return throttle.Err()
}
-func (cmd *annotatecmd) annotateSequence(throttle *throttle, outch chan<- string, tilelib *tileLibrary, taglen int, refname, seqname string, reftiles []tileLibRef) error {
+func (cmd *annotatecmd) annotateSequence(throttle *throttle, outch chan<- string, tilelib *tileLibrary, taglen int, refname, seqname string, reftiles []tileLibRef, refnamecol bool) error {
var refseq []byte
// tilestart[123] is the index into refseq
// where the tile for tag 123 was placed.
for variant := 1; variant <= len(tvs); variant++ {
variant, hash := tileVariantID(variant), tvs[variant-1]
tileseq := tilelib.TileVariantSequence(tileLibRef{Tag: tag, Variant: variant})
- if len(tileseq) < taglen {
+ if len(tileseq) == 0 {
+ continue
+ } else if len(tileseq) < taglen {
return fmt.Errorf("tilevar %d,%d has sequence len %d < taglen %d", tag, variant, len(tileseq), taglen)
}
var refpart []byte
} else {
varid = fmt.Sprintf("%d", variant)
}
- outch <- fmt.Sprintf("%d\t%s\t%s\t%s:g.%s\n", tag, varid, refname, seqname, diff.String())
+ refnamefield := ""
+ if refnamecol {
+ refnamefield = "\t" + refname
+ }
+ outch <- fmt.Sprintf("%d\t%s%s\t%s:g.%s\n", tag, varid, refnamefield, seqname, diff.String())
}
}()
}