*/
public static boolean isOpeningParenthesis(char c)
{
- return ('A' <= c && c <= 'Z' || c == '(' || c == '[' || c == '{' || c == '<');
+ return ('A' <= c && c <= 'Z' || c == '(' || c == '[' || c == '{'
+ || c == '<');
}
/**
*/
public static boolean isClosingParenthesis(char c)
{
- return ('a' <= c && c <= 'z' || c == ')' || c == ']' || c == '}' || c == '>');
+ return ('a' <= c && c <= 'z' || c == ')' || c == ']' || c == '}'
+ || c == '>');
}
/**
if (!stacks.containsKey(opening))
{
throw new WUSSParseException(MessageManager.formatMessage(
- "exception.mismatched_unseen_closing_char",
- new String[] { String.valueOf(base) }), i);
+ "exception.mismatched_unseen_closing_char", new String[]
+ { String.valueOf(base) }), i);
}
Stack<Integer> stack = stacks.get(opening);
{
// error whilst parsing i'th position. pass back
throw new WUSSParseException(MessageManager.formatMessage(
- "exception.mismatched_closing_char",
- new String[] { String.valueOf(base) }), i);
+ "exception.mismatched_closing_char", new String[]
+ { String.valueOf(base) }), i);
}
int temp = stack.pop();
* i (length of input string)
*/
throw new WUSSParseException(MessageManager.formatMessage(
- "exception.mismatched_opening_char",
- new String[] { String.valueOf(opening),
- String.valueOf(stack.pop()) }), i);
+ "exception.mismatched_opening_char", new String[]
+ { String.valueOf(opening), String.valueOf(stack.pop()) }),
+ i);
}
}
return pairs;
}
-
-
-
-
/**
* Function to get the end position corresponding to a given start position
*
*/
/**
- * Figures out which helix each position belongs to and stores the helix
- * number in the 'featureGroup' member of a SequenceFeature Based off of RALEE
- * code ralee-helix-map.
- *
- * @param pairs
- * Array of SequenceFeature (output from Rna.GetBasePairs)
- */
- protected static void computeHelixMap(SequenceFeature[] pairs)
- {
-
- int helix = 0; // Number of helices/current helix
- int lastopen = 0; // Position of last open bracket reviewed
- int lastclose = 9999999; // Position of last close bracket reviewed
-
- int open; // Position of an open bracket under review
- int close; // Position of a close bracket under review
- int j; // Counter
-
- Map<Integer, Integer> helices = new HashMap<Integer, Integer>();
- // Keep track of helix number for each position
-
- // Go through each base pair and assign positions a helix
- for (int i = 0; i < pairs.length; i++)
- {
-
- open = pairs[i].getBegin();
- close = pairs[i].getEnd();
-
- // System.out.println("open " + open + " close " + close);
- // System.out.println("lastclose " + lastclose + " lastopen " + lastopen);
-
- // we're moving from right to left based on closing pair
- /*
- * catch things like <<..>>..<<..>> |
- */
- if (open > lastclose)
- {
- helix++;
- }
-
- /*
- * catch things like <<..<<..>>..<<..>>>> |
- */
- j = pairs.length - 1;
- while (j >= 0)
- {
- int popen = pairs[j].getBegin();
-
- // System.out.println("j " + j + " popen " + popen + " lastopen "
- // +lastopen + " open " + open);
- if ((popen < lastopen) && (popen > open))
- {
- if (helices.containsValue(popen)
- && ((helices.get(popen)) == helix))
- {
- continue;
- }
- else
- {
- helix++;
- break;
- }
- }
-
- j -= 1;
- }
-
- // Put positions and helix information into the hashtable
- helices.put(open, helix);
- helices.put(close, helix);
-
- // Record helix as featuregroup
- pairs[i].setFeatureGroup(Integer.toString(helix));
-
- lastopen = open;
- lastclose = close;
- }
- }
-
- /**
* Answers true if the character is a recognised symbol for RNA secondary
* structure. Currently accepts a-z, A-Z, ()[]{}<>.
*
/*
* catch things like <<..<<..>>..<<..>>>> |
*/
- int j = bps.size() - 1;
- while (j >= 0)
+ int j = bps.size();
+ while (--j >= 0)
{
int popen = bps.get(j).getBP5();
break;
}
}
- j -= 1;
}
// Put positions and helix information into the hashtable
helices.put(close, helix);
// Record helix as featuregroup
- result.add(new SequenceFeature("RNA helix", "", "", open, close,
+ result.add(new SequenceFeature("RNA helix", "", open, close,
String.valueOf(helix)));
lastopen = open;