From: jprocter Date: Mon, 11 Apr 2005 16:54:38 +0000 (+0000) Subject: added the alignment quality calculation from the old jalview, and X-Git-Tag: Release_2_0~440 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=a4e00252bb8629013635f2d577f9af28c92d76d8;p=jalview.git added the alignment quality calculation from the old jalview, and tried to debug conservation calculation based on existing alscript code. --- diff --git a/src/jalview/analysis/Conservation.java b/src/jalview/analysis/Conservation.java index 9786362..2b4ef63 100755 --- a/src/jalview/analysis/Conservation.java +++ b/src/jalview/analysis/Conservation.java @@ -98,7 +98,8 @@ public class Conservation { residueHash = new Hashtable(); for (int j=0; j < sequences.size(); j++) { - + // JBPNote - have to make sure elements of the sequences vector + // are tested like this everywhere... if (sequences.elementAt(j) instanceof Sequence) { Sequence s = (Sequence)sequences.elementAt(j); @@ -155,6 +156,7 @@ public class Conservation { } } } + total.addElement(resultHash); } } @@ -175,14 +177,53 @@ public class Conservation { } return count; } + /*** + * countConsNGaps + * returns gap count in int[0], and conserved residue count in int[1] + */ + public int[] countConsNGaps(int j) + { + int count = 0; + int cons=0; + int nres = 0; + int[] r = new int[2]; + char f='$'; + for (int i = 0; i < sequences.size();i++) + { + if( j >= ((Sequence)sequences.elementAt(i)).getSequence().length()) + { count++; + continue;} + + char c = ((Sequence)sequences.elementAt(i)).getSequence().charAt(j); + if (jalview.util.Comparison.isGap((c))) + count++; + else { + nres++; + if (nres==1) { + f = c; + cons++; + } else + if (f == c) { + cons++; + } + } + } + r[0] = (nres==cons) ? 1 : 0; + r[1] = count; + + + return r; + } public void verdict(boolean consflag, float percentageGaps) { String consString = ""; for (int i=start; i <= end; i++) { - int totGaps = countGaps(i); + int[] gapcons = countConsNGaps(i); + boolean cons = (gapcons[0]==1) ? true : false; + int totGaps = gapcons[1]; float pgaps = (float)totGaps*100/(float)sequences.size(); - + // System.out.println("percentage gaps = "+pgaps+"\n"); if (percentageGaps > pgaps) { Hashtable resultHash = (Hashtable)total.elementAt(i-start); @@ -211,9 +252,9 @@ public class Conservation { } if (count < 10) - consString = consString + String.valueOf(count); + consString = consString + String.valueOf(count);// Conserved props!=Identity else - consString = consString + "*"; + consString = consString + ((gapcons[0]==1) ? "*" : "+"); } else @@ -331,7 +372,7 @@ public void findQuality(int start, int end) { try { sr = (double)BLOSUM62[i][seqNum]+4; } catch (Exception e) { - System.out.println("Exception in sr " + e); + System.out.println("Exception in sr: " + e); } //Calculate X with another loop over residues