*/\r
\r
package jalview.schemes;\r
+\r
+import jalview.datamodel.*;\r
import java.util.*;\r
import java.awt.*;\r
\r
\r
}\r
Vector colourTable = new Vector();\r
- public ClustalxColourScheme() {\r
- this.cons2 = null;\r
- this.size = 0;\r
- makeColours();\r
- }\r
- public ClustalxColourScheme(int[][] cons2, int size) {\r
- this.cons2 = cons2;\r
- this.size = size;\r
+\r
+\r
+ public ClustalxColourScheme(Vector seqs, int maxWidth)\r
+ {\r
+ cons2 = new int[maxWidth][24];\r
+ int start = 0, end = maxWidth-1;\r
+\r
+ // Initialize the array\r
+ for (int j=0;j<24;j++)\r
+ for (int i=0; i < maxWidth;i++)\r
+ cons2[i][j] = 0;\r
+\r
+ int res,i, j = 0;\r
+ String seq;\r
+ while(j < seqs.size())\r
+ {\r
+ seq = ( (SequenceI) seqs.get(j)).getSequence();\r
+ for (i = start; i <= end; i++)\r
+ {\r
+ res = ( (Integer) ResidueProperties.aaHash.get(seq.charAt(i) + "")).intValue();\r
+ cons2[i][res]++;\r
+ }\r
+ j++;\r
+ }\r
+\r
+ this.size = seqs.size();\r
makeColours();\r
}\r
public void makeColours() {\r
return Color.pink;\r
}\r
\r
+ public void setGroupSizeChanged(int i)\r
+ {\r
+ size = i;\r
+ }\r
+\r
public Color findColour(String s, int j, Vector seqs)\r
- {\r
+ {\r
+ int i = ((Integer)ResidueProperties.aaHash.get(s)).intValue();\r
\r
- int i = Integer.parseInt( ResidueProperties.aaHash.get(s).toString() );\r
+ Color c = Color.white;\r
\r
- if(i>22) // ie -, ., or space\r
- return Color.white;\r
+ if(i>20)\r
+ return c;\r
+\r
+ for (int k=0; k < ResidueColour[i].conses.length ; k++)\r
+ if (ResidueColour[i].conses[k].isConserved(cons2,j,size))\r
+ c = ResidueColour[i].c;\r
+\r
+ if (i == 4)\r
+ {\r
+ if (conses[27].isConserved(cons2, j, size))\r
+ c = (Color) colhash.get("PINK");\r
+ }\r
+\r
+\r
+ return c;\r
+\r
+ }\r
\r
- return ResidueColour[i].c;\r
- }\r
\r
public boolean canThreshold()\r
{\r
return false;\r
}\r
\r
+\r
}\r
\r
class ConsensusColour {\r
\r
\r
\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
\r
package jalview.schemes;\r
\r
-import jalview.datamodel.*;\r
-import java.util.*;\r
////////////////////////////////////////////\r
// This does nothing at all at the moment!!!!!!!!!!\r
// AW 15th Dec 2004\r
\r
int[] mask;\r
double threshold;\r
+ String maskstr;\r
\r
- public Consensus(String m, double threshold)\r
- {\r
- mask = setNums(m);\r
+ public Consensus(String mask, double threshold) {\r
+ // this.id = id;\r
+ // this.mask = mask;\r
+ this.maskstr = mask;\r
+ setMask(mask);\r
this.threshold = threshold;\r
}\r
\r
+ public void setMask(String s) {\r
+ this.mask = setNums(s);\r
+ // for (int i=0; i < mask.length; i++) {\r
+ // System.out.println(mask[i] + " " + ResidueProperties.aa[mask[i]]);\r
+ // }\r
+ }\r
\r
- public boolean isConserved(int[][] cons2,int col, int res,int size)\r
- {\r
+ public boolean isConserved(int[][] cons2,int col ,int size) {\r
int tot = 0;\r
-\r
-try{\r
- for (int i=0; i < mask.length; i++)\r
+ for (int i = 0; i < mask.length; i++)\r
tot += cons2[col][mask[i]];\r
-}catch(Exception ex)\r
-{ return true; }\r
\r
- if ((double)tot > threshold*size/100)\r
+ if ( (double) tot > threshold * size / 100)\r
return true;\r
\r
return false;\r
{\r
out[i] = ( (Integer) ResidueProperties.aaHash.get(s.substring(i, i + 1))).intValue();\r
i++;\r
+\r
}\r
+\r
return out;\r
}\r
\r