- int count = ((Integer)residueHash.get("-")).intValue() ;\r
- count++;\r
- residueHash.put("-",new Integer(count));\r
- }\r
- else\r
- residueHash.put("-",new Integer(1));\r
-\r
- }\r
- }\r
- }\r
-\r
- residueHash.put("maxCount",new Integer(maxCount));\r
- if(maxCount<0)\r
- System.out.println("asasa "+maxCount);\r
- residueHash.put("maxResidue", maxResidue);\r
- residueHash.put("size", new Integer(sequences.size()));\r
- residueHash.put("nongap", new Integer(nongap));\r
- result.addElement(residueHash);\r
- }\r
-\r
- return result;\r
- }\r
-\r
- public static Vector calculatePID(SequenceI refseq,Vector sequences,int window,int start,int end) {\r
-\r
- Vector result = new Vector();\r
-\r
- boolean init = true;\r
-\r
-\r
- Vector prev = null;\r
-\r
- for (int i = start;i <= end; i++) {\r
- Vector values = new Vector();\r
-\r
- result.addElement(values);\r
-\r
- // If start < window/2 then set value to zero.\r
-\r
- if (i< window/2 || i >= refseq.getSequence().length()-window/2) {\r
- for (int j = 0; j < sequences.size(); j++) {\r
- values.addElement(new Integer(0));\r
- }\r
- } else if (init == true) {\r
- init = false;\r
-\r
- int winstart = i-window/2;\r
- int winend = i+window/2;\r
-\r
- if (window%2 != 0) {\r
- winend++;\r
- }\r
-\r
- for (int j = 0; j < sequences.size(); j++) {\r
- values.addElement(new Integer(0));\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
- Sequence s = (Sequence)sequences.elementAt(j);\r
-\r
- if (s.getSequence().length() > k) {\r
-\r
- String res = s.getSequence().substring(k,k+1); // no gapchar test needed\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
+ if (sequences.elementAt(j) instanceof Sequence)\r
+ {\r
+ sequence = ((Sequence) sequences.elementAt(j)).getSequence();\r
+\r
+ if (sequence.length() > i)\r
+ {\r
+ res = String.valueOf(Character.toUpperCase(sequence.charAt(i)));\r
+\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
+ count = ((Integer) residueHash.get(res)).intValue();\r
+ count++;\r
+\r
+ if (!jalview.util.Comparison.isGap(res.charAt(0)) &&\r
+ (count >= maxCount))\r
+ {\r
+ if (count > maxCount)\r
+ {\r
+ maxResidue = res;\r
+ }\r
+ else if (maxResidue.indexOf(res) == -1)\r
+ {\r
+ maxResidue += res;\r
+ }\r
+\r
+ maxCount = count;\r
+ }\r
+\r
+ residueHash.put(res, new Integer(count));\r
+ }\r
+ else\r
+ {\r
+ residueHash.put(res, new Integer(1));\r
+ }\r
+ }\r
+ else\r
+ {\r
+ if (residueHash.containsKey("-"))\r
+ {\r
+ count = ((Integer) residueHash.get("-")).intValue();\r
+ count++;\r
+ residueHash.put("-", new Integer(count));\r
+ }\r
+ else\r
+ {\r
+ residueHash.put("-", new Integer(1));\r
+ }\r