From af0b03a2579577b4525e144776565c1446e7d68f Mon Sep 17 00:00:00 2001 From: kiran Date: Tue, 9 Jun 2009 00:53:45 +0000 Subject: [PATCH] Added tests for mostFrequentBaseFraction() and reverseComplementString() git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@944 348d0f76-0448-11de-a6fe-93d51630548a --- .../sting/utils/BaseUtilsTest.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/java/test/org/broadinstitute/sting/utils/BaseUtilsTest.java b/java/test/org/broadinstitute/sting/utils/BaseUtilsTest.java index e37ac8d5c..9d246fed3 100755 --- a/java/test/org/broadinstitute/sting/utils/BaseUtilsTest.java +++ b/java/test/org/broadinstitute/sting/utils/BaseUtilsTest.java @@ -18,6 +18,11 @@ public class BaseUtilsTest extends BaseTest { compareFrequentBaseFractionToExpected("ACCCCTTTTG", 4.0/10.0); } + private void compareFrequentBaseFractionToExpected(String sequence, double expected) { + double fraction = BaseUtils.mostFrequentBaseFraction(sequence.getBytes()); + Assert.assertTrue(MathUtils.compareDoubles(fraction, expected) == 0); + } + @Test public void testTransitionTransversion() { logger.warn("Executing testTransitionTransversion"); @@ -45,8 +50,18 @@ public class BaseUtilsTest extends BaseTest { Assert.assertTrue( BaseUtils.SNPSubstitutionType( 'a', 'c' ) == BaseUtils.BaseSubstitutionType.TRANSVERSION ); } - private void compareFrequentBaseFractionToExpected(String sequence, double expected) { - double fraction = BaseUtils.mostFrequentBaseFraction(sequence.getBytes()); - Assert.assertTrue(MathUtils.compareDoubles(fraction, expected) == 0); + @Test + public void testReverseComplementString() { + logger.warn("Executing testReverseComplementString"); + + compareRCStringToExpected("ACGGT", "ACCGT"); + compareRCStringToExpected("TCGTATATCTCGCTATATATATATAGCTCTAGTATA", "TATACTAGAGCTATATATATATAGCGAGATATACGA"); + compareRCStringToExpected("AAAN", "NTTT"); + } + + private void compareRCStringToExpected(String fw, String rcExp) { + String rcObs = BaseUtils.simpleReverseComplement(fw); + + Assert.assertTrue(rcObs.equals(rcExp)); } }