*/
/**
- * 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, ()[]{}<>.
*