From: jprocter Date: Wed, 13 Apr 2005 16:42:21 +0000 (+0000) Subject: Gap characters are now properly detected in the conservation and PID X-Git-Tag: Release_2_0~427 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=dbba2779042727476e41d2cdfa7346780ca00cbd;p=jalview.git Gap characters are now properly detected in the conservation and PID calculation. They are always counted in the '-' element of the residue count hash. --- diff --git a/src/jalview/analysis/AAFrequency.java b/src/jalview/analysis/AAFrequency.java index c61e7ef..edcc50f 100755 --- a/src/jalview/analysis/AAFrequency.java +++ b/src/jalview/analysis/AAFrequency.java @@ -20,6 +20,7 @@ public class AAFrequency { // This class is used extensively in calculating alignment colourschemes // that depend on the amount of conservation in each alignment column. + public static Vector calculate(Vector sequences,int start,int end) { Vector result = new Vector(); @@ -45,6 +46,8 @@ public class AAFrequency { if (!jalview.util.Comparison.isGap(res.charAt(0))) nongap++; + else + res = "-"; // we always use this for gaps in the property vectors if (residueHash.containsKey(res)) { @@ -133,26 +136,28 @@ public class AAFrequency { for (int k = winstart; k <= winend; k++) { String refchar = refseq.getSequence().substring(k,k+1); + if (jalview.util.Comparison.isGap(refchar.charAt(0))) + refchar="-"; + else { + for (int j = 0; j < sequences.size(); j++) { - for (int j = 0; j < sequences.size(); j++) { + Sequence s = (Sequence)sequences.elementAt(j); - if (refchar.equals("-") == false) { + if (s.getSequence().length() > k) { - Sequence s = (Sequence)sequences.elementAt(j); + String res = s.getSequence().substring(k,k+1); // no gapchar test needed - if (s.getSequence().length() > k) { + if (res.equals(refchar)) { + int val = ((Integer)values.elementAt(j)).intValue(); + val++; + values.setElementAt(new Integer(val),j); + } + } + } + } - String res = s.getSequence().substring(k,k+1); + } - if (res.equals(refchar)) { - int val = ((Integer)values.elementAt(j)).intValue(); - val++; - values.setElementAt(new Integer(val),j); - } - } - } - } - } prev = values; } else { int winstart = i-window/2; @@ -189,11 +194,13 @@ public class AAFrequency { // Now substract 1 if the chars at winstart-1 match - if (pre_refchar.equals("-") == false && pre_char.equals(pre_refchar)) { + if (jalview.util.Comparison.isGap(pre_refchar.charAt(0)) == false + && pre_char.equals(pre_refchar)) { val--; } - if (pos_refchar.equals("-") == false && pos_char.equals(pos_refchar)) { + if (jalview.util.Comparison.isGap(pos_refchar.charAt(0)) == false + && pos_char.equals(pos_refchar)) { val++; }