19073: Remove dup tags (>1 ref placement) from tilestats bed file.
[lightning.git] / tilestats.go
index 733b0fda827b445143123ea2a2c2867afded1876..d870d7bb7d983c8885e721603e93671f898b8ad5 100644 (file)
@@ -140,9 +140,22 @@ func (cmd *tilingStats) RunCommand(prog string, args []string, stdin io.Reader,
                        seqnames = append(seqnames, seqname)
                }
                sort.Strings(seqnames)
+               // Mark duplicate tags (tags that place more than once
+               // on the reference)
+               duptag := map[tagID]bool{}
+               for _, seqname := range seqnames {
+                       for _, libref := range cseq.TileSequences[seqname] {
+                               if dup, seen := duptag[libref.Tag]; seen && !dup {
+                                       duptag[libref.Tag] = true
+                               }
+                       }
+               }
                for _, seqname := range seqnames {
                        pos := 0
                        for _, libref := range cseq.TileSequences[seqname] {
+                               if duptag[libref.Tag] {
+                                       continue
+                               }
                                tiledata := reftiledata[libref]
                                if len(tiledata) <= taglen {
                                        err = fmt.Errorf("bogus input data: ref tile libref %v has len %d < taglen %d", libref, len(tiledata), taglen)