From 129f23a9792303778d5e4d7447bfaf9f19e2d2ee Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Tue, 30 Nov 2021 16:17:09 -0500 Subject: [PATCH] Fix handling of TAG->CA (spell as T>C, =A, delG). fixes #18496 Arvados-DCO-1.1-Signed-off-by: Tom Clegg --- hgvs/diff.go | 8 ++++---- hgvs/diff_test.go | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/hgvs/diff.go b/hgvs/diff.go index 57025e3588..e25e13b920 100644 --- a/hgvs/diff.go +++ b/hgvs/diff.go @@ -148,8 +148,8 @@ func cleanup(in []diffmatchpatch.Diff) (out []diffmatchpatch.Diff) { if i < len(in)-1 && d.Type == diffmatchpatch.DiffDelete && in[i+1].Type == diffmatchpatch.DiffInsert && - len(d.Text) > 2 && - len(in[i+1].Text) > 2 && + len(d.Text) >= 2 && + len(in[i+1].Text) >= 2 && d.Text[1] == in[i+1].Text[1] { eqend := 2 for ; eqend < len(d.Text) && eqend < len(in[i+1].Text) && d.Text[eqend] == in[i+1].Text[eqend]; eqend++ { @@ -167,8 +167,8 @@ func cleanup(in []diffmatchpatch.Diff) (out []diffmatchpatch.Diff) { if i < len(in)-1 && d.Type == diffmatchpatch.DiffDelete && in[i+1].Type == diffmatchpatch.DiffInsert && - len(d.Text) > 2 && - len(in[i+1].Text) > 2 && + len(d.Text) >= 2 && + len(in[i+1].Text) >= 2 && d.Text[len(d.Text)-2] == in[i+1].Text[len(in[i+1].Text)-2] { // eqstart will be the number of equal chars // before the terminal snp, plus 1 for the snp diff --git a/hgvs/diff_test.go b/hgvs/diff_test.go index 1032f4e3d2..8a0d0c8c94 100644 --- a/hgvs/diff_test.go +++ b/hgvs/diff_test.go @@ -128,6 +128,11 @@ func (s *diffSuite) TestDiff(c *check.C) { b: "tcaAaCCggTc", expect: []string{"4G>A", "6delinsCC", "9A>T"}, }, + { + a: "tcatagagac", + b: "tcacaagac", + expect: []string{"4T>C", "6del"}, + }, } { c.Log(trial) var vars []string -- 2.30.2