+ @Test(groups = { "Functional" })
+ public void testExtractCdnaProfile()
+ {
+ /*
+ * 200 sequences of which 30 gapped (170 ungapped)
+ * max count 70 for modal residue 'G'
+ */
+ Hashtable profile = new Hashtable();
+
+ /*
+ * cdna profile is {seqCount, ungappedCount, codonCount1, ...codonCount64}
+ * where 1..64 positions correspond to encoded codons
+ * see CodingUtils.encodeCodon()
+ */
+ int[] codonCounts = new int[66];
+ char[] codon1 = new char[] { 'G', 'C', 'A' };
+ char[] codon2 = new char[] { 'c', 'C', 'A' };
+ char[] codon3 = new char[] { 't', 'g', 'A' };
+ char[] codon4 = new char[] { 'G', 'C', 't' };
+ int encoded1 = CodingUtils.encodeCodon(codon1);
+ int encoded2 = CodingUtils.encodeCodon(codon2);
+ int encoded3 = CodingUtils.encodeCodon(codon3);
+ int encoded4 = CodingUtils.encodeCodon(codon4);
+ codonCounts[2 + encoded1] = 30;
+ codonCounts[2 + encoded2] = 70;
+ codonCounts[2 + encoded3] = 9;
+ codonCounts[2 + encoded4] = 1;
+ codonCounts[0] = 120;
+ codonCounts[1] = 110;
+ profile.put(AAFrequency.PROFILE, codonCounts);
+
+ /*
+ * [0, noOfValues, totalPercent, char1, count1, ...]
+ * codon1: 30/110 = 27.2 = 27%
+ * codon2: 70/110 = 63.6% = 63%
+ * codon3: 9/110 = 8.1% = 8%
+ * codon4: 1/110 = 0.9% = 0% should be discarded
+ * total (rounded) percentages = 98
+ */
+ int[] extracted = AAFrequency.extractCdnaProfile(profile, true);
+ int[] expected = new int[] { AlignmentAnnotation.CDNA_PROFILE, 3, 98,
+ encoded2, 63, encoded1, 27, encoded3, 8 };
+ org.testng.Assert.assertEquals(extracted, expected);
+ }
+
+ @Test(groups = { "Functional" })
+ public void testExtractCdnaProfile_countGaps()
+ {
+ /*
+ * 200 sequences of which 30 gapped (170 ungapped)
+ * max count 70 for modal residue 'G'
+ */
+ Hashtable profile = new Hashtable();
+
+ /*
+ * cdna profile is {seqCount, ungappedCount, codonCount1, ...codonCount64}
+ * where 1..64 positions correspond to encoded codons
+ * see CodingUtils.encodeCodon()
+ */
+ int[] codonCounts = new int[66];
+ char[] codon1 = new char[] { 'G', 'C', 'A' };
+ char[] codon2 = new char[] { 'c', 'C', 'A' };
+ char[] codon3 = new char[] { 't', 'g', 'A' };
+ char[] codon4 = new char[] { 'G', 'C', 't' };
+ int encoded1 = CodingUtils.encodeCodon(codon1);
+ int encoded2 = CodingUtils.encodeCodon(codon2);
+ int encoded3 = CodingUtils.encodeCodon(codon3);
+ int encoded4 = CodingUtils.encodeCodon(codon4);
+ codonCounts[2 + encoded1] = 30;
+ codonCounts[2 + encoded2] = 70;
+ codonCounts[2 + encoded3] = 9;
+ codonCounts[2 + encoded4] = 1;
+ codonCounts[0] = 120;
+ codonCounts[1] = 110;
+ profile.put(AAFrequency.PROFILE, codonCounts);
+
+ /*
+ * [0, noOfValues, totalPercent, char1, count1, ...]
+ * codon1: 30/120 = 25%
+ * codon2: 70/120 = 58.3 = 58%
+ * codon3: 9/120 = 7.5 = 7%
+ * codon4: 1/120 = 0.8 = 0% should be discarded
+ * total (rounded) percentages = 90
+ */
+ int[] extracted = AAFrequency.extractCdnaProfile(profile, false);
+ int[] expected = new int[] { AlignmentAnnotation.CDNA_PROFILE, 3, 90,
+ encoded2, 58, encoded1, 25, encoded3, 7 };
+ org.testng.Assert.assertEquals(extracted, expected);
+ }
+
+ @Test(groups = { "Functional" })
+ public void testExtractHMMProfile()
+ throws MalformedURLException, IOException
+ {