+/*\r
+* Jalview - A Sequence Alignment Editor and Viewer\r
+* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+*\r
+* This program is free software; you can redistribute it and/or\r
+* modify it under the terms of the GNU General Public License\r
+* as published by the Free Software Foundation; either version 2\r
+* of the License, or (at your option) any later version.\r
+*\r
+* This program is distributed in the hope that it will be useful,\r
+* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+* GNU General Public License for more details.\r
+*\r
+* You should have received a copy of the GNU General Public License\r
+* along with this program; if not, write to the Free Software\r
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\r
+*/\r
+\r
package jalview.analysis;\r
\r
import jalview.jbgui.*;\r
// This class is used extensively in calculating alignment colourschemes\r
// that depend on the amount of conservation in each alignment column.\r
\r
+\r
public static Vector calculate(Vector sequences,int start,int end) {\r
\r
Vector result = new Vector();\r
\r
if (!jalview.util.Comparison.isGap(res.charAt(0)))\r
nongap++;\r
+ else\r
+ res = "-"; // we always use this for gaps in the property vectors\r
\r
if (residueHash.containsKey(res))\r
{\r
\r
for (int k = winstart; k <= winend; k++) {\r
String refchar = refseq.getSequence().substring(k,k+1);\r
+ if (jalview.util.Comparison.isGap(refchar.charAt(0)))\r
+ refchar="-";\r
+ else {\r
+ for (int j = 0; j < sequences.size(); j++) {\r
\r
- for (int j = 0; j < sequences.size(); j++) {\r
+ Sequence s = (Sequence)sequences.elementAt(j);\r
\r
- if (refchar.equals("-") == false) {\r
+ if (s.getSequence().length() > k) {\r
\r
- Sequence s = (Sequence)sequences.elementAt(j);\r
+ String res = s.getSequence().substring(k,k+1); // no gapchar test needed\r
\r
- if (s.getSequence().length() > k) {\r
+ if (res.equals(refchar)) {\r
+ int val = ((Integer)values.elementAt(j)).intValue();\r
+ val++;\r
+ values.setElementAt(new Integer(val),j);\r
+ }\r
+ }\r
+ }\r
+ }\r
\r
- String res = s.getSequence().substring(k,k+1);\r
+ }\r
\r
- if (res.equals(refchar)) {\r
- int val = ((Integer)values.elementAt(j)).intValue();\r
- val++;\r
- values.setElementAt(new Integer(val),j);\r
- }\r
- }\r
- }\r
- }\r
- }\r
prev = values;\r
} else {\r
int winstart = i-window/2;\r
\r
// Now substract 1 if the chars at winstart-1 match\r
\r
- if (pre_refchar.equals("-") == false && pre_char.equals(pre_refchar)) {\r
+ if (jalview.util.Comparison.isGap(pre_refchar.charAt(0)) == false\r
+ && pre_char.equals(pre_refchar)) {\r
val--;\r
}\r
\r
- if (pos_refchar.equals("-") == false && pos_char.equals(pos_refchar)) {\r
+ if (jalview.util.Comparison.isGap(pos_refchar.charAt(0)) == false\r
+ && pos_char.equals(pos_refchar)) {\r
val++;\r
}\r
\r