From: amwaterhouse Date: Tue, 1 Feb 2005 18:58:40 +0000 (+0000) Subject: Clustal colours now work X-Git-Tag: Release_2_0~714 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=0f530039f8c0ac9c6613063a576c3a13c8644fcd;p=jalview.git Clustal colours now work --- diff --git a/src/jalview/schemes/ClustalxColourScheme.java b/src/jalview/schemes/ClustalxColourScheme.java index 128929c..b28ac76 100755 --- a/src/jalview/schemes/ClustalxColourScheme.java +++ b/src/jalview/schemes/ClustalxColourScheme.java @@ -17,6 +17,8 @@ */ package jalview.schemes; + +import jalview.datamodel.*; import java.util.*; import java.awt.*; @@ -42,14 +44,32 @@ public class ClustalxColourScheme implements ColourSchemeI } Vector colourTable = new Vector(); - public ClustalxColourScheme() { - this.cons2 = null; - this.size = 0; - makeColours(); - } - public ClustalxColourScheme(int[][] cons2, int size) { - this.cons2 = cons2; - this.size = size; + + + public ClustalxColourScheme(Vector seqs, int maxWidth) + { + cons2 = new int[maxWidth][24]; + int start = 0, end = maxWidth-1; + + // Initialize the array + for (int j=0;j<24;j++) + for (int i=0; i < maxWidth;i++) + cons2[i][j] = 0; + + int res,i, j = 0; + String seq; + while(j < seqs.size()) + { + seq = ( (SequenceI) seqs.get(j)).getSequence(); + for (i = start; i <= end; i++) + { + res = ( (Integer) ResidueProperties.aaHash.get(seq.charAt(i) + "")).intValue(); + cons2[i][res]++; + } + j++; + } + + this.size = seqs.size(); makeColours(); } public void makeColours() { @@ -196,16 +216,35 @@ public class ClustalxColourScheme implements ColourSchemeI return Color.pink; } + public void setGroupSizeChanged(int i) + { + size = i; + } + public Color findColour(String s, int j, Vector seqs) - { + { + int i = ((Integer)ResidueProperties.aaHash.get(s)).intValue(); - int i = Integer.parseInt( ResidueProperties.aaHash.get(s).toString() ); + Color c = Color.white; - if(i>22) // ie -, ., or space - return Color.white; + if(i>20) + return c; + + for (int k=0; k < ResidueColour[i].conses.length ; k++) + if (ResidueColour[i].conses[k].isConserved(cons2,j,size)) + c = ResidueColour[i].c; + + if (i == 4) + { + if (conses[27].isConserved(cons2, j, size)) + c = (Color) colhash.get("PINK"); + } + + + return c; + + } - return ResidueColour[i].c; - } public boolean canThreshold() { @@ -217,6 +256,7 @@ public class ClustalxColourScheme implements ColourSchemeI return false; } + } class ConsensusColour { @@ -236,3 +276,12 @@ class ConsensusColour { + + + + + + + + + diff --git a/src/jalview/schemes/Consensus.java b/src/jalview/schemes/Consensus.java index 7b0dbbb..17cb789 100755 --- a/src/jalview/schemes/Consensus.java +++ b/src/jalview/schemes/Consensus.java @@ -18,8 +18,6 @@ package jalview.schemes; -import jalview.datamodel.*; -import java.util.*; //////////////////////////////////////////// // This does nothing at all at the moment!!!!!!!!!! // AW 15th Dec 2004 @@ -28,25 +26,29 @@ public class Consensus { int[] mask; double threshold; + String maskstr; - public Consensus(String m, double threshold) - { - mask = setNums(m); + public Consensus(String mask, double threshold) { + // this.id = id; + // this.mask = mask; + this.maskstr = mask; + setMask(mask); this.threshold = threshold; } + public void setMask(String s) { + this.mask = setNums(s); + // for (int i=0; i < mask.length; i++) { + // System.out.println(mask[i] + " " + ResidueProperties.aa[mask[i]]); + // } + } - public boolean isConserved(int[][] cons2,int col, int res,int size) - { + public boolean isConserved(int[][] cons2,int col ,int size) { int tot = 0; - -try{ - for (int i=0; i < mask.length; i++) + for (int i = 0; i < mask.length; i++) tot += cons2[col][mask[i]]; -}catch(Exception ex) -{ return true; } - if ((double)tot > threshold*size/100) + if ( (double) tot > threshold * size / 100) return true; return false; @@ -60,7 +62,9 @@ try{ { out[i] = ( (Integer) ResidueProperties.aaHash.get(s.substring(i, i + 1))).intValue(); i++; + } + return out; }