From 52c08db40bdfc267f83dadc9df78d1f77a427ccd Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Wed, 21 Oct 2020 17:15:37 -0400 Subject: [PATCH] Handle N in ref. Arvados-DCO-1.1-Signed-off-by: Tom Clegg --- export.go | 8 +++++--- pipeline_test.go | 16 ++++++++++++---- testdata/ref.fasta | 2 +- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/export.go b/export.go index 256af21296..2c51ff3eb9 100644 --- a/export.go +++ b/export.go @@ -131,7 +131,9 @@ func (cmd *exporter) RunCommand(prog string, args []string, stdin io.Reader, std var mtx sync.Mutex var cgs []CompactGenome - var tilelib tileLibrary + tilelib := tileLibrary{ + includeNoCalls: true, + } err = tilelib.LoadGob(context.Background(), input, func(cg CompactGenome) { if *pick != "" && *pick != cg.Name { return @@ -389,8 +391,8 @@ func printVCF(out io.Writer, seqname string, varslice []hgvs.Variant) { alts[a] = i + 1 } fmt.Fprintf(out, "%s\t%d\t%s\t%s", seqname, varslice[0].Position, ref, strings.Join(altslice, ",")) - for i := 0; i < len(varslice)/2; i++ { - v1, v2 := varslice[i*2], varslice[i*2+1] + for i := 0; i < len(varslice); i += 2 { + v1, v2 := varslice[i], varslice[i+1] a1, a2 := alts[v1.New], alts[v2.New] if v1.Ref != ref { a1 = 0 diff --git a/pipeline_test.go b/pipeline_test.go index 821c0fc626..2b0f393312 100644 --- a/pipeline_test.go +++ b/pipeline_test.go @@ -49,8 +49,8 @@ func (s *pipelineSuite) TestImportMerge(c *check.C) { var wg sync.WaitGroup for i, infile := range []string{ - "testdata/pipeline1/", "testdata/ref.fasta", + "testdata/pipeline1/", } { i, infile := i, infile c.Logf("TestImportMerge: %s", infile) @@ -58,7 +58,13 @@ func (s *pipelineSuite) TestImportMerge(c *check.C) { wg.Add(1) go func() { defer wg.Done() - code := (&importer{}).RunCommand("lightning import", []string{"-local=true", "-o=" + libfile[i], "-skip-ooo=true", "-output-tiles", "-tag-library", "testdata/tags", infile}, bytes.NewReader(nil), &bytes.Buffer{}, os.Stderr) + args := []string{"-local=true", "-o=" + libfile[i], "-skip-ooo=true", "-output-tiles", "-tag-library", "testdata/tags"} + if i == 0 { + // ref only + args = append(args, "-include-no-calls") + } + args = append(args, infile) + code := (&importer{}).RunCommand("lightning import", args, bytes.NewReader(nil), &bytes.Buffer{}, os.Stderr) c.Check(code, check.Equals, 0) }() } @@ -82,7 +88,8 @@ func (s *pipelineSuite) TestImportMerge(c *check.C) { c.Check(code, check.Equals, 0) c.Check(hgvsout.Len() > 0, check.Equals, true) c.Logf("%s", hgvsout.String()) - c.Check(hgvsout.String(), check.Equals, `chr1:g.[41_42delinsAA];[41=] + c.Check(hgvsout.String(), check.Equals, `chr1:g.1_3delinsGGC +chr1:g.[41_42delinsAA];[41=] chr1:g.[161=];[161A>T] chr1:g.[178=];[178A>T] chr1:g.222_224del @@ -99,7 +106,8 @@ chr2:g.[1043=];[1043_1044delinsAA] c.Check(code, check.Equals, 0) c.Check(vcfout.Len() > 0, check.Equals, true) c.Logf("%s", vcfout.String()) - c.Check(vcfout.String(), check.Equals, `chr1 41 TT AA 1/0 + c.Check(vcfout.String(), check.Equals, `chr1 1 NNN GGC 1/1 +chr1 41 TT AA 1/0 chr1 161 A T 0/1 chr1 178 A T 0/1 chr1 221 TCCA T 1/1 diff --git a/testdata/ref.fasta b/testdata/ref.fasta index d35147afe0..8bd6142dfc 100644 --- a/testdata/ref.fasta +++ b/testdata/ref.fasta @@ -1,5 +1,5 @@ >chr1 -ggcgtctacctcgagaagccccgacctctgaataagatctttgaacatctcaagggattgtgtatcttgttgggtgtacgcgcgccagcccgcagcatta +nnngtctacctcgagaagccccgacctctgaataagatctttgaacatctcaagggattgtgtatcttgttgggtgtacgcgcgccagcccgcagcatta ggagaactgtgctccgccttcaga ccccttgggtaaaatgccgcgcaatatgttgattacacttgctgcccatctgaaaggtcgccttatcaatcctatgctgaatgccctctaaggagttcca acacatgctagcgcgtcggggtgg -- 2.30.2