-
- /**
- * Method to calculate a 'base pair consensus row', very similar
- * to nucleotide consensus but takes into account a given structure
- * @param sequences
- * @param start
- * @param end
- * @param result
- * @param profile
- * @param rnaStruc
- */
- public static final void calculate(SequenceI[] sequences, int start,
- int end, Hashtable[] result, boolean profile, AlignmentAnnotation rnaStruc){
-
- Hashtable residueHash;
- String maxResidue;
- char[] seq, struc=rnaStruc.getRNAStruc().toCharArray();
- SequenceFeature[] rna =rnaStruc._rnasecstr;
- char c,s,cEnd;
- int count,nonGap=0,i,bpEnd=-1,j,jSize = sequences.length;
- int[] values = new int[255];
- float percentage;
-
- for (i = start; i < end; i++) //foreach column
- {
- residueHash = new Hashtable();
- maxResidue="";
- values = new int[255];
- bpEnd=-1;
-
- s = struc[i];
- if (s == '.' || s == ' ')
- {
- s = '-';
- }
-
- if(s == '-'){
- values['-']++;
- }
- else
- {
- for (j = 0; j < jSize; j++) //foreach row
- {
- if (sequences[j]==null)
- {
- System.err.println("WARNING: Consensus skipping null sequence - possible race condition.");
- continue;
- }
- seq = sequences[j].getSequence();
-
- if (seq.length > i)
- {
- c = seq[i];
-
- //standard representation for gaps in sequence and structure
- if (c == '.' || c == ' ')
- {
- c = '-';
- }
-
- if (c == '-')
- {
- values['-']++;
- continue;
- }
- if(s == '('){
- bpEnd=rna[(rna.length-1-nonGap)].getEnd();
- cEnd=seq[bpEnd];
- if(checkBpType(c,cEnd)){
- values['H']++; //H means it's a helix (structured)
- }
- }
- }
- }
- 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);
-
- percentage = ((float) count * 100) / (float) jSize;
- residueHash.put(PID_GAPS, new Float(percentage));
-
- //percentage = ((float) count * 100) / (float) nongap;
- //residueHash.put(PID_NOGAPS, new Float(percentage));
- if(result[i]==null){
- result[i] = residueHash;
- }
- if(bpEnd>0){
- result[bpEnd]=residueHash;
- }
-
- }
- }