* that depend on the amount of conservation in each alignment column. */\r
public static Vector calculate(Vector sequences, int start, int end)\r
{\r
- Vector result = new Vector();\r
+ Vector result = new Vector();\r
+ Hashtable residueHash;\r
+ int count, maxCount, nongap, i, j, jSize = sequences.size();\r
+ String maxResidue, sequence, res;\r
+ float percentage;\r
\r
- for (int i = start; i <= end; i++)\r
+ for (i = start; i <= end; i++)\r
{\r
- Hashtable residueHash = new Hashtable();\r
- int maxCount = 0;\r
- String maxResidue = "-";\r
- int nongap = 0;\r
+ residueHash = new Hashtable();\r
+ maxCount = 0;\r
+ maxResidue = "-";\r
+ nongap = 0;\r
\r
- for (int j = 0; j < sequences.size(); j++)\r
+ for (j = 0; j < jSize; j++)\r
{\r
if (sequences.elementAt(j) instanceof Sequence)\r
{\r
- Sequence s = (Sequence) sequences.elementAt(j);\r
+ sequence = ((Sequence) sequences.elementAt(j)).getSequence();\r
\r
- if (s.getSequence().length() > i)\r
+ if (sequence.length() > i)\r
{\r
- String res = s.getSequence().charAt(i) + "";\r
+ res = sequence.substring(i,i+1);\r
\r
- if (!jalview.util.Comparison.isGap(res.charAt(0)))\r
- {\r
- nongap++;\r
- }\r
- else\r
+ if (jalview.util.Comparison.isGap(res.charAt(0)))\r
{\r
res = "-"; // we always use this for gaps in the property vectors\r
}\r
+ else\r
+ { nongap++; }\r
\r
if (residueHash.containsKey(res))\r
{\r
- int count = ((Integer) residueHash.get(res)).intValue();\r
+ count = ((Integer) residueHash.get(res)).intValue();\r
count++;\r
\r
if (!jalview.util.Comparison.isGap(res.charAt(0)) &&\r
{\r
if (residueHash.containsKey("-"))\r
{\r
- int count = ((Integer) residueHash.get("-")).intValue();\r
+ count = ((Integer) residueHash.get("-")).intValue();\r
count++;\r
residueHash.put("-", new Integer(count));\r
}\r
}\r
\r
residueHash.put("maxCount", new Integer(maxCount));\r
+ residueHash.put("maxResidue", maxResidue);\r
\r
- if (maxCount < 0)\r
- {\r
- System.out.println("asasa " + maxCount);\r
- }\r
\r
- residueHash.put("maxResidue", maxResidue);\r
- residueHash.put("size", new Integer(sequences.size()));\r
- residueHash.put("nongap", new Integer(nongap));\r
+ //Size is redundant at present if we calculate percentage here\r
+ //residueHash.put("size", new Integer(jSize));\r
+ //residueHash.put("nogaps", new Integer(nongap));\r
+\r
+ percentage = ((float)maxCount*100) / (float)jSize;\r
+ residueHash.put("pid_gaps", new Float(percentage) );\r
+\r
+ percentage = ((float)maxCount*100) / (float)nongap;\r
+ residueHash.put("pid_nogaps", new Float(percentage) );\r
result.addElement(residueHash);\r
}\r
\r
+\r
+\r
return result;\r
}\r
}\r