+ 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.
+ *
+ * @param ssString
+ * @return
+ */
+ public static String getRNASecStrucState(String ssString)
+ {
+ if (ssString == null)
+ {
+ return null;
+ }
+ StringBuilder result = new StringBuilder(ssString.length());
+ for (int i = 0; i < ssString.length(); i++)
+ {
+ char c = ssString.charAt(i);
+ result.append(isRnaSecondaryStructureSymbol(c) ? c : " ");
+ }
+ return result.toString();
+ }
+
+ /**
+ * Answers true if the base-pair is either a Watson-Crick (A:T/U, C:G) or a
+ * wobble (G:T/U) pair (either way round), else false
+ *
+ * @param first
+ * @param second
+ * @return
+ */
+ public static boolean isCanonicalOrWobblePair(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 'C':
+ switch (second)
+ {
+ case 'G':
+ return true;
+ }
+ break;
+ case 'T':
+ case 'U':
+ switch (second)
+ {
+ case 'A':
+ case 'G':
+ return true;
+ }
+ break;
+ case 'G':
+ switch (second)
+ {
+ case 'C':
+ case 'T':
+ case 'U':
+ return true;
+ }
+ break;
+ }
+ return false;
+ }
+
+ /**
+ * Answers true if the base-pair is Watson-Crick - (A:T/U or C:G, either way
+ * round), else false
+ *
+ * @param first
+ * @param second
+ * @return
+ */
+ 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
+ * is not a valid opening symbol.
+ *
+ * @param c
+ * @return
+ */
+ public static char getMatchingClosingParenthesis(char c)
+ {
+ if ('A' <= c && c <= 'Z')
+ {
+ return (char) (c + 'a' - 'A');
+ }
+ switch (c)
+ {
+ case '(':
+ return ')';
+ case '[':
+ return ']';
+ case '{':
+ return '}';
+ case '<':
+ return '>';
+ default:
+ return c;
+ }
+ }
+
+ public static SequenceFeature[] getHelixMap(CharSequence rnaAnnotation)
+ throws WUSSParseException
+ {
+ List<SequenceFeature> result = new ArrayList<SequenceFeature>();