}
/**
+ * Answers true if the string is a valid open pair rna secondary structure
+ * symbol. Currently accepts A-Z, ([{<
+ *
+ * @param s
+ * @return
+ */
+ public static boolean isOpeningParenthesis(String s)
+ {
+ return s != null && s.length() == 1
+ && isOpeningParenthesis(s.charAt(0));
+ }
+
+ /**
* Answers true if the character is a valid close pair rna secondary structure
* symbol. Currently accepts a-z, )]}>
*
}
/**
+ * Answers true if the string is a valid close pair rna secondary structure
+ * symbol. Currently accepts a-z, )]}>
+ *
+ * @param s
+ * @return
+ */
+ public static boolean isClosingParenthesis(String s)
+ {
+ return s != null && s.length() == 1
+ && isClosingParenthesis(s.charAt(0));
+ }
+
+ /**
* Returns the matching open pair symbol for the given closing symbol.
* Currently returns A-Z for a-z, or ([{< for )]}>, or the input symbol if it
* is not a valid closing symbol.
}
/**
+ * Answers true if the string is a recognised symbol for RNA secondary
+ * structure. Currently accepts a-z, A-Z, ()[]{}<>.
+ *
+ * @param s
+ * @return
+ */
+ public static boolean isRnaSecondaryStructureSymbol(String s)
+ {
+ return isOpeningParenthesis(s) || isClosingParenthesis(s);
+ }
+
+ /**
* Translates a string to RNA secondary structure representation. Returns the
* string with any non-SS characters changed to spaces. Accepted characters
* are a-z, A-Z, and (){}[]<> brackets.
Rna.getRNASecStrucState("a.[K-]z}?{Q b(w)p><i"));
}
+ /**
+ * Tests for isClosingParenthesis with char or String argument
+ */
@Test(groups = { "Functional" })
public void testIsClosingParenthesis()
{
+ assertFalse(Rna.isClosingParenthesis(null));
+
/*
* only a-z, )]}> are closing bracket symbols
*/
for (int i = 0; i <= 255; i++)
{
- boolean isClosing = Rna.isClosingParenthesis((char) i);
+ boolean isClosingChar = Rna.isClosingParenthesis((char) i);
+ boolean isClosingString = Rna.isClosingParenthesis(String
+ .valueOf((char) i));
if ((i >= 'a' && i <= 'z') || i == ')' || i == '}' || i == ']'
|| i == '>')
{
- assertTrue(String.format("close base pair %c", i), isClosing);
+ assertTrue(String.format("close base pair %c", i), isClosingChar);
+ assertTrue(String.format("close base pair %c", i), isClosingString);
}
else
{
- assertFalse(String.format("close base pair %c", i), isClosing);
+ assertFalse(String.format("close base pair %c", i), isClosingChar);
+ assertFalse(String.format("close base pair %c", i), isClosingString);
}
+ assertFalse(Rna.isClosingParenthesis(String.valueOf((char) i) + " "));
}
}
}
}
+ /**
+ * Tests for isOpeningParenthesis with char or String argument
+ */
@Test(groups = { "Functional" })
public void testIsOpeningParenthesis()
{
*/
for (int i = 0; i <= 255; i++)
{
- boolean isOpening = Rna.isOpeningParenthesis((char) i);
+ boolean isOpeningChar = Rna.isOpeningParenthesis((char) i);
+ boolean isOpeningString = Rna.isOpeningParenthesis(String
+ .valueOf((char) i));
if ((i >= 'A' && i <= 'Z') || i == '(' || i == '{' || i == '['
|| i == '<')
{
- assertTrue(String.format("Open base pair %c", i), isOpening);
+ assertTrue(String.format("Open base pair %c", i), isOpeningChar);
+ assertTrue(String.format("Open base pair %c", i), isOpeningString);
}
else
{
- assertFalse(String.format("Open base pair %c", i), isOpening);
+ assertFalse(String.format("Open base pair %c", i), isOpeningChar);
+ assertFalse(String.format("Open base pair %c", i), isOpeningString);
}
+ assertFalse(Rna.isOpeningParenthesis(String.valueOf((char) i) + " "));
}
}
}
}
}
+
+ /**
+ * Tests for isRnaSecondaryStructureSymbol with char or String argument
+ */
+ @Test(groups = { "Functional" })
+ public void testIsRnaSecondaryStructureSymbol()
+ {
+ assertFalse(Rna.isRnaSecondaryStructureSymbol(null));
+
+ /*
+ * only A-Z, a-z, ()[]{}<> are valid symbols
+ */
+ for (int i = 0; i <= 255; i++)
+ {
+ boolean isValidChar = Rna.isRnaSecondaryStructureSymbol((char) i);
+ boolean isValidString = Rna.isRnaSecondaryStructureSymbol(String
+ .valueOf((char) i));
+ if ((i >= 'A' && i <= 'Z') || (i >= 'a' && i <= 'z') || i == '('
+ || i == ')' || i == '{' || i == '}' || i == '[' || i == ']'
+ || i == '<' || i == '>')
+ {
+ assertTrue(String.format("close base pair %c", i), isValidChar);
+ assertTrue(String.format("close base pair %c", i), isValidString);
+ }
+ else
+ {
+ assertFalse(String.format("close base pair %c", i), isValidChar);
+ assertFalse(String.format("close base pair %c", i), isValidString);
+ }
+ assertFalse(Rna.isRnaSecondaryStructureSymbol(String
+ .valueOf((char) i) + " "));
+ }
+ }
}