return false;
}
+ public static boolean isCanonicalPair(char first, char second)
+ {
+
+ if (first > 'Z')
+ {
+ first -= 32;
+ }
+ if (second > 'Z')
+ {
+ second -= 32;
+ }
+
+ switch (first)
+ {
+ case 'A':
+ switch (second)
+ {
+ case 'T':
+ case 'U':
+ return true;
+ }
+ break;
+ case 'G':
+ switch (second)
+ {
+ case 'C':
+ return true;
+ }
+ break;
+ case 'C':
+ switch (second)
+ {
+ case 'G':
+ return true;
+ }
+ break;
+ case 'T':
+ case 'U':
+ switch (second)
+ {
+ case 'A':
+ return true;
+ }
+ break;
+ }
+ return false;
+ }
+
/**
* Returns the matching close pair symbol for the given opening symbol.
* Currently returns a-z for A-Z, or )]}> for ([{<, or the input symbol if it
}
}
+ @Test(groups = { "Functional" })
+ public void testIsCanonicalPair()
+ {
+ String bases = "acgtuACGTU";
+ for (int i = 0; i < bases.length(); i++)
+ {
+ for (int j = 0; j < bases.length(); j++)
+ {
+ char first = bases.charAt(i);
+ char second = bases.charAt(j);
+ boolean result = Rna.isCanonicalPair(first, second);
+ String pair = new String(new char[] { first, second })
+ .toUpperCase();
+ if (pair.equals("AT") || pair.equals("TA") || pair.equals("AU")
+ || pair.equals("UA") || pair.equals("GC")
+ || pair.equals("CG"))
+ {
+ assertTrue(pair + " should be valid", result);
+ }
+ else
+ {
+ assertFalse(pair + " should be invalid", result);
+ }
+ }
+ }
+ }
+
/**
* Tests for isOpeningParenthesis with char or String argument
*/