X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fschemes%2FClustalxColourScheme.java;h=353accf324cfd95f26d2677f9db04f4778f6f285;hb=a6cd54c46366acd8bc3350a79374b18f9eb0b240;hp=bbca4deb11ca70628f43f34d6e2d62e9d3b35c5f;hpb=99c58ee0ae2a848f982552e53feaf6d5cb9925e5;p=jalview.git diff --git a/src/jalview/schemes/ClustalxColourScheme.java b/src/jalview/schemes/ClustalxColourScheme.java index bbca4de..353accf 100755 --- a/src/jalview/schemes/ClustalxColourScheme.java +++ b/src/jalview/schemes/ClustalxColourScheme.java @@ -1,51 +1,52 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ - + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ package jalview.schemes; -import jalview.datamodel.*; import java.util.*; + import java.awt.*; -public class ClustalxColourScheme extends ResidueColourScheme +import jalview.datamodel.*; + +public class ClustalxColourScheme + extends ResidueColourScheme { + public static Hashtable colhash = new Hashtable(); Hashtable[] cons; int[][] cons2; ConsensusColour[] colours; ConsensusColour[] ResidueColour; int size; - Consensus[] conses = new Consensus[32]; - public static Hashtable colhash = new Hashtable(); - - { - colhash.put("RED",new Color((float)0.9,(float)0.2,(float)0.1)); - colhash.put("BLUE",new Color((float)0.5,(float)0.7,(float)0.9)); - colhash.put("GREEN",new Color((float)0.1,(float)0.8,(float)0.1)); - colhash.put("ORANGE",new Color((float)0.9,(float)0.6,(float)0.3)); - colhash.put("CYAN",new Color((float)0.1,(float)0.7,(float)0.7)); - colhash.put("PINK",new Color((float)0.9,(float)0.5,(float)0.5)); - colhash.put("MAGENTA",new Color((float)0.8,(float)0.3,(float)0.8)); - colhash.put("YELLOW",new Color((float)0.8,(float)0.8,(float)0.0)); - - } + Consensus[] conses = new Consensus[32]; Vector colourTable = new Vector(); + { + colhash.put("RED", new Color( (float) 0.9, (float) 0.2, (float) 0.1)); + colhash.put("BLUE", new Color( (float) 0.5, (float) 0.7, (float) 0.9)); + colhash.put("GREEN", new Color( (float) 0.1, (float) 0.8, (float) 0.1)); + colhash.put("ORANGE", new Color( (float) 0.9, (float) 0.6, (float) 0.3)); + colhash.put("CYAN", new Color( (float) 0.1, (float) 0.7, (float) 0.7)); + colhash.put("PINK", new Color( (float) 0.9, (float) 0.5, (float) 0.5)); + colhash.put("MAGENTA", new Color( (float) 0.8, (float) 0.3, (float) 0.8)); + colhash.put("YELLOW", new Color( (float) 0.8, (float) 0.8, (float) 0.0)); + } + public ClustalxColourScheme(Vector seqs, int maxWidth) { resetClustalX(seqs, maxWidth); @@ -54,83 +55,101 @@ public class ClustalxColourScheme extends ResidueColourScheme public void resetClustalX(Vector seqs, int maxWidth) { cons2 = new int[maxWidth][24]; + int start = 0; // Initialize the array - for (int j=0;j<24;j++) - for (int i=0; i < maxWidth;i++) + for (int j = 0; j < 24; j++) + { + for (int i = 0; i < maxWidth; i++) + { cons2[i][j] = 0; + } + } + + int res; + int i; + int j = 0; + String seq; + + while (j < seqs.size()) + { + seq = ( (SequenceI) seqs.elementAt(j)).getSequence(); - int res,i, j = 0; - String seq; - while(j < seqs.size()) + int end_j = seq.length() - 1; + + for (i = start; i <= end_j; i++) { - seq = ( (SequenceI) seqs.elementAt(j)).getSequence(); - int end_j = seq.length()-1; - for (i = start; i <= end_j; i++) + if ( (seq.length() - 1) < i) + { + res = 23; + } + else { - if(seq.length()-119) - return c; + if (i > 19) + { + return currentColour; + } - for (int k=0; k < ResidueColour[i].conses.length ; k++) - if (ResidueColour[i].conses[k].isConserved(cons2,j,size)) - c = ResidueColour[i].c; + for (int k = 0; k < ResidueColour[i].conses.length; k++) + { + if (ResidueColour[i].conses[k].isConserved(cons2, j, size)) + { + currentColour = ResidueColour[i].c; + } + } - if (i == 4) + if (i == 4) { if (conses[27].isConserved(cons2, j, size)) - c = (Color) colhash.get("PINK"); + { + currentColour = (Color) colhash.get("PINK"); + } } + if(conservationColouring) + applyConservation(j); - return c; - - } + return currentColour; + } } -class ConsensusColour { - +class ConsensusColour +{ Consensus[] conses; Color c; - public ConsensusColour(Color c,Consensus[] conses) { + public ConsensusColour(Color c, Consensus[] conses) + { this.conses = conses; + // this.list = list; this.c = c; } } - - - - - - - - - - - - - - -