Fix handling of TAG->CA (spell as T>C, =A, delG).
authorTom Clegg <tom@curii.com>
Tue, 30 Nov 2021 21:17:09 +0000 (16:17 -0500)
committerTom Clegg <tom@curii.com>
Tue, 30 Nov 2021 21:17:09 +0000 (16:17 -0500)
fixes #18496

Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

hgvs/diff.go
hgvs/diff_test.go

index 57025e358862a79407f58dff30b84ed046bd0ea0..e25e13b9200cdd4fd687271213b84b0d25f4743c 100644 (file)
@@ -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
index 1032f4e3d2dbbc5cf24d6aa35c7ce97f653c85f8..8a0d0c8c941711f0c4c74972fbd2b36316de1b48 100644 (file)
@@ -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