- }\r
- private void calcSeqNum(int i) {\r
- String sq=null; // for dumb jbuilder not-inited exception warning\r
- int[] sqnum = null;\r
- if (i>-1 && i<sequences.size()) {\r
- sq = ((SequenceI)sequences.elementAt(i)).getSequence();\r
- if (seqNums.size()<=i) {\r
- seqNums.add(new int[sq.length()+1]);\r
- }\r
- if (sq.hashCode()!=((int[])seqNums.elementAt(i))[0])\r
- {\r
- int j, len;\r
- seqNumsChanged = true;\r
- sq = ((SequenceI) sequences.elementAt(i)).getSequence();\r
- len = sq.length();\r
- if (maxLength < len)\r
- maxLength = len;\r
- sqnum = new int[len + 1]; // better to always make a new array - sequence can change its length\r
- sqnum[0] = sq.hashCode();\r
- for (j = 1; j <= len; j++)\r
- {\r
- sqnum[j] = ( (Integer) jalview.schemes.ResidueProperties.aaHash.get(new\r
- String(sq.substring(j - 1, j)))).intValue(); // yuk\r
- }\r
- seqNums.set(i, sqnum);\r
- }\r
- } else {\r
- // JBPNote INFO level debug\r
- System.out.println("calcSeqNum called with out of range sequence index for Alignment\n");\r
- }\r
- }\r
- Vector total = new Vector();\r
- public Vector quality;\r
- public Double[] qualityRange = new Double[2];\r
- String consString = "";\r
-\r
- Sequence consSequence;\r
- Hashtable propHash;\r
- int threshold;\r
-\r
- String name = "";\r
-\r
- public Conservation(String name,Hashtable propHash, int threshold, Vector sequences, int start, int end) {\r
- this.name = name;\r
- this.propHash = propHash;\r
- this.threshold = threshold;\r
- this.sequences = sequences;\r
- this.start = start;\r
- this.end = end;\r
- seqNums = new Vector(sequences.size());\r
- calcSeqNums();\r
- }\r
-\r
-\r
- public void calculate() {\r
-\r
- for (int i = start;i <= end; i++) {\r
- Hashtable resultHash = null;\r
- Hashtable residueHash = null;\r
-\r
- resultHash = new Hashtable();\r
- residueHash = new Hashtable();\r
-\r
- for (int j=0; j < sequences.size(); j++) {\r
-\r
- if (sequences.elementAt(j) instanceof Sequence) {\r
- Sequence s = (Sequence)sequences.elementAt(j);\r
-\r
- if (s.getLength() > i) {\r
- String res = s.getSequence().substring(i,i+1);\r
-\r
- if (residueHash.containsKey(res)) {\r
- int count = ((Integer)residueHash.get(res)).intValue() ;\r
- count++;\r
- residueHash.put(res,new Integer(count));\r
- } else {\r
- residueHash.put(res,new Integer(1));\r
- }\r
- } else {\r
- if (residueHash.containsKey("-")) {\r
- int count = ((Integer)residueHash.get("-")).intValue() ;\r
- count++;\r
- residueHash.put("-",new Integer(count));\r
- } else {\r
- residueHash.put("-",new Integer(1));\r
- }\r
- }\r
- }\r
- }\r