Include tiles in one-hot matrix even if there is no ref tile.
[lightning.git] / slicenumpy.go
index 77877b3fcaaca0cf7b0b18c207c4675307ac2ffa..c6859f3653f506b4b4b3d2d76b205b1bdccf0bf3 100644 (file)
@@ -247,6 +247,9 @@ func (cmd *sliceNumpy) RunCommand(prog string, args []string, stdin io.Reader, s
        for seqname, cseq := range refseq {
                pos := 0
                for _, libref := range cseq {
+                       if libref.Tag > tagID(cmd.filter.MaxTag) {
+                               continue
+                       }
                        tiledata := reftiledata[libref]
                        if len(tiledata) == 0 {
                                err = fmt.Errorf("missing tiledata for tag %d variant %d in %s in ref", libref.Tag, libref.Variant, seqname)
@@ -477,16 +480,12 @@ func (cmd *sliceNumpy) RunCommand(prog string, args []string, stdin io.Reader, s
                        annow := bufio.NewWriterSize(annof, 1<<20)
                        outcol := 0
                        for tag := tagstart; tag < tagend; tag++ {
-                               rt, ok := reftile[tag]
-                               if !ok {
-                                       if mask == nil {
-                                               outcol++
-                                       }
-                                       // Excluded by specified
-                                       // regions, or reference does
-                                       // not use any variant of this
-                                       // tile. (TODO: log this?
-                                       // mention it in annotations?)
+                               rt := reftile[tag]
+                               if rt == nil && mask != nil {
+                                       // Excluded by specified regions
+                                       continue
+                               }
+                               if tag > tagID(cmd.filter.MaxTag) {
                                        continue
                                }
                                remap := variantRemap[tag-tagstart]
@@ -501,6 +500,12 @@ func (cmd *sliceNumpy) RunCommand(prog string, args []string, stdin io.Reader, s
                                        onehotChunk = append(onehotChunk, onehot...)
                                        onehotXref = append(onehotXref, xrefs...)
                                }
+                               if rt == nil {
+                                       // Reference does not use any
+                                       // variant of this tile
+                                       outcol++
+                                       continue
+                               }
                                fmt.Fprintf(annow, "%d,%d,%d,=,%s,%d,,,\n", tag, outcol, rt.variant, rt.seqname, rt.pos)
                                variants := seq[tag]
                                reftilestr := strings.ToUpper(string(rt.tiledata))