X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fanalysis%2FAlignSeqTest.java;h=bd827f96d7b5d70dd314b2d0f656c4740a790451;hb=b2a2c2070f14d18d67b07b030d70073a21b7a4e3;hp=4cb5329d027e05281f30f1a7e6bae94f2c070c40;hpb=5f4e1e4c330b045e9c8bce28ee132a0fca3834d8;p=jalview.git diff --git a/test/jalview/analysis/AlignSeqTest.java b/test/jalview/analysis/AlignSeqTest.java index 4cb5329..bd827f9 100644 --- a/test/jalview/analysis/AlignSeqTest.java +++ b/test/jalview/analysis/AlignSeqTest.java @@ -20,9 +20,11 @@ */ package jalview.analysis; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNull; +import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals; +import jalview.datamodel.Sequence; import jalview.gui.JvOptionPane; import org.testng.annotations.BeforeClass; @@ -45,10 +47,33 @@ public class AlignSeqTest assertNull(AlignSeq.extractGaps(null, "ACG")); assertNull(AlignSeq.extractGaps("-. ", null)); - assertEquals(" AC-G.T", AlignSeq.extractGaps("", " AC-G.T")); - assertEquals("AC-G.T", AlignSeq.extractGaps(" ", " AC-G.T")); - assertEquals("ACG.T", AlignSeq.extractGaps(" -", " AC-G.T")); - assertEquals("ACGT", AlignSeq.extractGaps(" -.", " AC-G.T .")); - assertEquals(" ACG.T", AlignSeq.extractGaps("-", " AC-G.T")); + assertEquals(AlignSeq.extractGaps("", " AC-G.T"), " AC-G.T"); + assertEquals(AlignSeq.extractGaps(" ", " AC-G.T"), "AC-G.T"); + assertEquals(AlignSeq.extractGaps(" -", " AC-G.T"), "ACG.T"); + assertEquals(AlignSeq.extractGaps(" -.", " AC-G.T ."), "ACGT"); + assertEquals(AlignSeq.extractGaps("-", " AC-G.T"), " ACG.T"); + assertEquals(AlignSeq.extractGaps("-. ", " -. .-"), ""); + } + + @Test(groups = { "Functional" }) + public void testIndexEncode_nucleotide() + { + AlignSeq as = new AlignSeq(new Sequence("s1", "TTAG"), new Sequence( + "s2", "ACGT"), AlignSeq.DNA); + int[] expected = new int[] { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, + 7, 7, 8, 8, 9, 9, -1, -1, 10, -1 }; + String s = "aAcCgGtTuUiIxXrRyYnN .-?"; + assertArrayEquals(expected, as.indexEncode(s)); + } + + @Test(groups = { "Functional" }) + public void testIndexEncode_peptide() + { + AlignSeq as = new AlignSeq(new Sequence("s1", "PFY"), new Sequence( + "s2", "RQW"), AlignSeq.PEP); + int[] expected = new int[] { 0, 0, 1, 1, 2, 2, 21, 21, 22, 22, -1, 23, + -1, -1, -1 }; + String s = "aArRnNzZxX *.-?"; + assertArrayEquals(expected, as.indexEncode(s)); } }