X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fanalysis%2FRna.java;h=e5cda93b985f33520b6b5450ddeb624bb900bb24;hb=e7c9f2a10d2d700121595539f2d9385a5043d7fe;hp=6bb123ad1e13778b23096bcfce5fc407699538e9;hpb=beceff8fb262b9b1c5d119855b75e5329c252a71;p=jalview.git diff --git a/src/jalview/analysis/Rna.java b/src/jalview/analysis/Rna.java index 6bb123a..e5cda93 100644 --- a/src/jalview/analysis/Rna.java +++ b/src/jalview/analysis/Rna.java @@ -49,7 +49,8 @@ public class Rna */ public static boolean isOpeningParenthesis(char c) { - return ('A' <= c && c <= 'Z' || c == '(' || c == '[' || c == '{' || c == '<'); + return ('A' <= c && c <= 'Z' || c == '(' || c == '[' || c == '{' + || c == '<'); } /** @@ -74,7 +75,8 @@ public class Rna */ public static boolean isClosingParenthesis(char c) { - return ('a' <= c && c <= 'z' || c == ')' || c == ']' || c == '}' || c == '>'); + return ('a' <= c && c <= 'z' || c == ')' || c == ']' || c == '}' + || c == '>'); } /** @@ -160,8 +162,8 @@ public class Rna 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 stack = stacks.get(opening); @@ -169,8 +171,8 @@ public class Rna { // 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(); @@ -188,9 +190,9 @@ public class Rna * 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; @@ -215,86 +217,6 @@ public class Rna */ /** - * 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 helices = new HashMap(); - // 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, ()[]{}<>. * @@ -518,8 +440,8 @@ public class Rna /* * catch things like <<..<<..>>..<<..>>>> | */ - int j = bps.size() - 1; - while (j >= 0) + int j = bps.size(); + while (--j >= 0) { int popen = bps.get(j).getBP5(); @@ -538,7 +460,6 @@ public class Rna break; } } - j -= 1; } // Put positions and helix information into the hashtable @@ -546,7 +467,7 @@ public class Rna 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;