efficient solution; either by creating a Hashtable of pairs in
StructureFrequency or directly in a RNA class;
Change-Id: I7bd21eb4d952f22579c786f3d78395949fa046d0
package jalview.analysis;
package jalview.analysis;
+import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Vector;
import java.util.Hashtable;
import java.util.Vector;
+ static Hashtable<Integer, Integer> 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
/**
* 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
Object temp = stack.lastElement();
stack.remove(stack.size() - 1);
pairs.addElement(temp);
Object temp = stack.lastElement();
stack.remove(stack.size() - 1);
pairs.addElement(temp);
outPairs[p / 2] = new SequenceFeature("RNA helix", "", "", begin,
end, "");
outPairs[p / 2] = new SequenceFeature("RNA helix", "", "", begin,
end, "");
+ //pairHash.put(begin, end);
+
+
+
+ /**
+ * 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<Integer> pair = new ArrayList<Integer>();
+ return pairHash.get(indice);
+ }*/
+
/**
* Figures out which helix each position belongs to and stores the helix
/**
* Figures out which helix each position belongs to and stores the helix
+ public static int findPair(SequenceFeature[] pairs,int indice){
+ for(int i=0; i<pairs.length; i++){
+ if(pairs[i].getBegin()==indice){
+ return pairs[i].getEnd();
+ }
+ }
+ return -1;
+ }
+
/**
* Method to calculate a 'base pair consensus row', very similar
* to nucleotide consensus but takes into account a given structure
/**
* Method to calculate a 'base pair consensus row', very similar
* to nucleotide consensus but takes into account a given structure
*/
public static final void calculate(SequenceI[] sequences, int start,
int end, Hashtable[] result, boolean profile, AlignmentAnnotation rnaStruc){
*/
public static final void calculate(SequenceI[] sequences, int start,
int end, Hashtable[] result, boolean profile, AlignmentAnnotation rnaStruc){
+ System.out.println("StructureFrequency.calculate");
Hashtable residueHash;
String maxResidue;
char[] seq, struc=rnaStruc.getRNAStruc().toCharArray();
Hashtable residueHash;
String maxResidue;
char[] seq, struc=rnaStruc.getRNAStruc().toCharArray();
int[] values = new int[255];
float percentage;
int[] values = new int[255];
float percentage;
+ /*for(int x=(rna.length-1); x>=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();
for (i = start; i < end; i++) //foreach column
{
residueHash = new Hashtable();
values = new int[255];
bpEnd=-1;
values = new int[255];
bpEnd=-1;
values['-']++;
continue;
}
values['-']++;
continue;
}
- if(s == '('){
- bpEnd=rna[(rna.length-1-nonGap)].getEnd();
+ //if(s == '('){
+ //bpEnd=rna[(rna.length-1-nonGap)].getEnd();
+ bpEnd=findPair(rna,i);
+ //System.out.println(i+","+bpEnd);
if(checkBpType(c,cEnd)){
values['H']++; //H means it's a helix (structured)
}
if(checkBpType(c,cEnd)){
values['H']++; //H means it's a helix (structured)
}
- /*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 } });
+ // }
+
-
- if (count == 0)
- {
- maxResidue = "-";
- }else{
- maxResidue="H";
- }
-
residueHash.put(MAXCOUNT, new Integer(count));
residueHash.put(MAXRESIDUE, maxResidue);
residueHash.put(MAXCOUNT, new Integer(count));
residueHash.put(MAXRESIDUE, maxResidue);
if(bpEnd>0){
result[bpEnd]=residueHash;
}
if(bpEnd>0){
result[bpEnd]=residueHash;
}