Omit refname field in annotation if only one ref exists.
authorTom Clegg <tom@tomclegg.ca>
Mon, 2 Nov 2020 19:02:10 +0000 (14:02 -0500)
committerTom Clegg <tom@tomclegg.ca>
Mon, 2 Nov 2020 19:02:10 +0000 (14:02 -0500)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@tomclegg.ca>

annotate.go
pipeline_test.go

index b0247165eafffcde4c6d1bbcaa07bfd9f52c42af..7787ae231838430840d6ae4ef5631ac08750f9b6 100644 (file)
@@ -185,7 +185,7 @@ func (cmd *annotatecmd) exportTileDiffs(outw io.Writer, tilelib *tileLibrary) er
                        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))
                        }()
                }
        }
@@ -193,7 +193,7 @@ func (cmd *annotatecmd) exportTileDiffs(outw io.Writer, tilelib *tileLibrary) er
        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.
@@ -273,7 +273,11 @@ func (cmd *annotatecmd) annotateSequence(throttle *throttle, outch chan<- string
                                        } 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())
                                }
                        }()
                }
index 49dc39ddacf386cf89afa68591b8fa7d2153bbea..ef7af393ebaa60d2c71618d9ebf419444e24d724 100644 (file)
@@ -143,21 +143,21 @@ chr2 472 572 7 1000 . 496 572
        c.Check(annotateout.Len() > 0, check.Equals, true)
        sorted := sortLines(annotateout.String())
        c.Logf("%s", sorted)
-       c.Check(sorted, check.Equals, sortLines(`0      8d4fe9a63921b   testdata/ref.fasta      chr1:g.161A>T
-0      8d4fe9a63921b   testdata/ref.fasta      chr1:g.178A>T
-0      8d4fe9a63921b   testdata/ref.fasta      chr1:g.1_3delinsGGC
-0      8d4fe9a63921b   testdata/ref.fasta      chr1:g.222_224del
-0      ba4263ca4199c   testdata/ref.fasta      chr1:g.1_3delinsGGC
-0      ba4263ca4199c   testdata/ref.fasta      chr1:g.222_224del
-0      ba4263ca4199c   testdata/ref.fasta      chr1:g.41_42delinsAA
-1      139890345dbb8   testdata/ref.fasta      chr1:g.302_305delinsAAAA
-4      cbfca15d241d3   testdata/ref.fasta      chr2:g.125_127delinsAAA
-4      cbfca15d241d3   testdata/ref.fasta      chr2:g.1_3delinsAAA
-4      f5fafe9450b02   testdata/ref.fasta      chr2:g.241_245delinsAAAAA
-4      f5fafe9450b02   testdata/ref.fasta      chr2:g.291C>A
-4      fe9a71a42adb4   testdata/ref.fasta      chr2:g.125_127delinsAAA
-6      e36dce85efbef   testdata/ref.fasta      chr2:g.471_472delinsAA
-6      f81388b184f4a   testdata/ref.fasta      chr2:g.470_472del
+       c.Check(sorted, check.Equals, sortLines(`0      8d4fe9a63921b   chr1:g.161A>T
+0      8d4fe9a63921b   chr1:g.178A>T
+0      8d4fe9a63921b   chr1:g.1_3delinsGGC
+0      8d4fe9a63921b   chr1:g.222_224del
+0      ba4263ca4199c   chr1:g.1_3delinsGGC
+0      ba4263ca4199c   chr1:g.222_224del
+0      ba4263ca4199c   chr1:g.41_42delinsAA
+1      139890345dbb8   chr1:g.302_305delinsAAAA
+4      cbfca15d241d3   chr2:g.125_127delinsAAA
+4      cbfca15d241d3   chr2:g.1_3delinsAAA
+4      f5fafe9450b02   chr2:g.241_245delinsAAAAA
+4      f5fafe9450b02   chr2:g.291C>A
+4      fe9a71a42adb4   chr2:g.125_127delinsAAA
+6      e36dce85efbef   chr2:g.471_472delinsAA
+6      f81388b184f4a   chr2:g.470_472del
 `))
 }