From 0f3f69c44e4a266029ebc16171bebfe34bd5ac96 Mon Sep 17 00:00:00 2001 From: janengelhardt Date: Wed, 3 Aug 2011 14:30:54 +0200 Subject: [PATCH] JAL-885; Multi-helix bug is solved; One should think about a more efficient solution; either by creating a Hashtable of pairs in StructureFrequency or directly in a RNA class; Change-Id: I7bd21eb4d952f22579c786f3d78395949fa046d0 --- src/jalview/analysis/Rna.java | 21 +++++++++- src/jalview/analysis/StructureFrequency.java | 55 +++++++++++++++----------- 2 files changed, 52 insertions(+), 24 deletions(-) diff --git a/src/jalview/analysis/Rna.java b/src/jalview/analysis/Rna.java index f2ef118..71ccbd1 100644 --- a/src/jalview/analysis/Rna.java +++ b/src/jalview/analysis/Rna.java @@ -21,6 +21,7 @@ package jalview.analysis; +import java.util.ArrayList; import java.util.Hashtable; import java.util.Vector; @@ -28,6 +29,7 @@ import jalview.datamodel.SequenceFeature; public class Rna { + static Hashtable pairHash = new Hashtable(); /** * Based off of RALEE code ralee-get-base-pairs. Keeps track of open bracket * positions in "stack" vector. When a close bracket is reached, pair this @@ -62,7 +64,7 @@ public class Rna Object temp = stack.lastElement(); stack.remove(stack.size() - 1); pairs.addElement(temp); - pairs.addElement(i); + pairs.addElement(i); } i++; @@ -79,10 +81,27 @@ public class Rna outPairs[p / 2] = new SequenceFeature("RNA helix", "", "", begin, end, ""); + //pairHash.put(begin, end); + } return outPairs; } + + + /** + * Function to get the end position corresponding to a given start position + * @param indice - start position of a base pair + * @return - end position of a base pair + */ + /*makes no sense at the moment :( + public int findEnd(int indice){ + //TODO: Probably extend this to find the start to a given end? + //could be done by putting everything twice to the hash + ArrayList pair = new ArrayList(); + return pairHash.get(indice); + }*/ + /** * Figures out which helix each position belongs to and stores the helix diff --git a/src/jalview/analysis/StructureFrequency.java b/src/jalview/analysis/StructureFrequency.java index 29c0a0b..a5dd030 100644 --- a/src/jalview/analysis/StructureFrequency.java +++ b/src/jalview/analysis/StructureFrequency.java @@ -181,6 +181,15 @@ public class StructureFrequency } } + public static int findPair(SequenceFeature[] pairs,int indice){ + for(int i=0; i=0; x--){ + System.out.println("BP-"+((rna.length-1)-x)+" "+rna[x].getBegin()+","+rna[x].getEnd()+" "+rna[x].getFeatureGroup()); + }*/ + + for (i = start; i < end; i++) //foreach column { residueHash = new Hashtable(); - maxResidue=""; + maxResidue="-"; values = new int[255]; bpEnd=-1; @@ -216,7 +230,7 @@ public class StructureFrequency s = '-'; } - if(s == '-'){ + if(s != '('){ values['-']++; } else @@ -245,35 +259,31 @@ public class StructureFrequency values['-']++; continue; } - if(s == '('){ - bpEnd=rna[(rna.length-1-nonGap)].getEnd(); + //if(s == '('){ + //bpEnd=rna[(rna.length-1-nonGap)].getEnd(); + bpEnd=findPair(rna,i); cEnd=seq[bpEnd]; + //System.out.println(i+","+bpEnd); if(checkBpType(c,cEnd)){ values['H']++; //H means it's a helix (structured) } - } + maxResidue="H"; + //} } } nonGap++; } - /*UPDATE this for new values - if (profile) - { - residueHash.put(PROFILE, new int[][] - { values, new int[] - { jSize, nongap } }); - } - */ + //UPDATE this for new values + //if (profile) + //{ + // residueHash.put(PROFILE, new int[][] + // { values, new int[] + // { jSize, nongap } }); + // } + count=values['H']; - - if (count == 0) - { - maxResidue = "-"; - }else{ - maxResidue="H"; - } - + residueHash.put(MAXCOUNT, new Integer(count)); residueHash.put(MAXRESIDUE, maxResidue); @@ -288,7 +298,6 @@ public class StructureFrequency if(bpEnd>0){ result[bpEnd]=residueHash; } - } } -- 1.7.10.2