Fix some tests.
[lightning.git] / annotate.go
index b792119b20f84fd281639642a00d4d053a935d77..00f1cad1556147c2b2ba31f2e8e3b4483ad02e20 100644 (file)
@@ -1,3 +1,7 @@
+// Copyright (C) The Lightning Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
 package lightning
 
 import (
@@ -23,10 +27,11 @@ import (
 )
 
 type annotatecmd struct {
-       dropTiles   []bool
-       variantHash bool
-       maxTileSize int
-       tag2tagid   map[string]tagID
+       dropTiles        []bool
+       variantHash      bool
+       maxTileSize      int
+       tag2tagid        map[string]tagID
+       reportAnnotation func(tag tagID, outcol int, variant tileVariantID, refname string, seqname string, pdi hgvs.Variant)
 }
 
 func (cmd *annotatecmd) RunCommand(prog string, args []string, stdin io.Reader, stdout, stderr io.Writer) int {
@@ -52,6 +57,9 @@ func (cmd *annotatecmd) RunCommand(prog string, args []string, stdin io.Reader,
                return 0
        } else if err != nil {
                return 2
+       } else if flags.NArg() > 0 {
+               err = fmt.Errorf("errant command line arguments after parsed flags: %v", flags.Args())
+               return 2
        }
 
        if *pprof != "" {
@@ -113,7 +121,7 @@ func (cmd *annotatecmd) RunCommand(prog string, args []string, stdin io.Reader,
                retainNoCalls:       true,
                retainTileSequences: true,
        }
-       err = tilelib.LoadGob(context.Background(), input, strings.HasSuffix(*inputFilename, ".gz"), nil)
+       err = tilelib.LoadGob(context.Background(), input, strings.HasSuffix(*inputFilename, ".gz"))
        if err != nil {
                return 1
        }
@@ -242,13 +250,10 @@ func (cmd *annotatecmd) annotateSequence(throttle *throttle, outch chan<- string
                outcol := outcol
                refstart, ok := tilestart[tag]
                if !ok {
-                       // Tag didn't place on this
-                       // reference sequence. (It
-                       // might place on the same
-                       // chromosome in a genome
-                       // anyway, but we don't output
-                       // the annotations that would
-                       // result.)
+                       // Tag didn't place on this reference
+                       // sequence. (It might place on the same
+                       // chromosome in a genome anyway, but we don't
+                       // output the annotations that would result.)
                        // outch <- fmt.Sprintf("%d,%d,-1%s\n", tag, outcol, refnamefield)
                        continue
                }
@@ -299,6 +304,9 @@ func (cmd *annotatecmd) annotateSequence(throttle *throttle, outch chan<- string
                                                varid = fmt.Sprintf("%d", variant)
                                        }
                                        outch <- fmt.Sprintf("%d,%d,%s%s,%s:g.%s\n", tag, outcol, varid, refnamefield, seqname, diff.String())
+                                       if cmd.reportAnnotation != nil {
+                                               cmd.reportAnnotation(tag, outcol, variant, refname, seqname, diff)
+                                       }
                                }
                        }()
                }