From 983ec14d5f8eb5f4f96536ebb50ff295440f2547 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Tue, 3 May 2005 12:43:54 +0000 Subject: [PATCH] 1.1 compatible, formatting changes --- src/jalview/schemes/ClustalxColourScheme.java | 2 +- src/jalview/schemes/ColourSchemeProperty.java | 200 ++++++++++----------- src/jalview/schemes/ConservationColourScheme.java | 173 +++++++++--------- 3 files changed, 188 insertions(+), 187 deletions(-) diff --git a/src/jalview/schemes/ClustalxColourScheme.java b/src/jalview/schemes/ClustalxColourScheme.java index 06b62c6..1bf8567 100755 --- a/src/jalview/schemes/ClustalxColourScheme.java +++ b/src/jalview/schemes/ClustalxColourScheme.java @@ -60,7 +60,7 @@ public class ClustalxColourScheme implements ColourSchemeI String seq; while(j < seqs.size()) { - seq = ( (SequenceI) seqs.get(j)).getSequence(); + seq = ( (SequenceI) seqs.elementAt(j)).getSequence(); int end_j = seq.length()-1; for (i = start; i <= end_j; i++) { diff --git a/src/jalview/schemes/ColourSchemeProperty.java b/src/jalview/schemes/ColourSchemeProperty.java index 6831ec2..6488b8d 100755 --- a/src/jalview/schemes/ColourSchemeProperty.java +++ b/src/jalview/schemes/ColourSchemeProperty.java @@ -1,100 +1,100 @@ -package jalview.schemes; - -public class ColourSchemeProperty -{ - public static final int CLUSTAL = 0; - public static final int BLOSUM = 1; - public static final int PID = 2; - public static final int ZAPPO = 3; - public static final int HYDROPHOBIC=4; - public static final int HELIX=5; - public static final int STRAND=6; - public static final int TURN = 7; - public static final int BURIED = 8; - public static final int NUCLEOTIDE = 9; - public static final int USER_DEFINED = 10; - public static final int NONE = 11; - - public static int getColourIndexFromName(String name) - { - int ret=11; - if(name.equals("Clustal")) - ret = CLUSTAL; - else if(name.equals("Blosum62")) - ret = BLOSUM; - else if(name.equals("% Identity")) - ret = PID; - else if(name.equals("Zappo")) - ret = ZAPPO; - else if(name.equals("Hydrophobic")) - ret = HYDROPHOBIC; - else if(name.equals("Helix Propensity")) - ret = HELIX; - else if(name.equals("Strand Propensity")) - ret = STRAND; - else if(name.equals("Turn Propensity")) - ret = TURN; - else if(name.equals("Buried Index")) - ret = BURIED; - else if(name.equals("Nucleotide")) - ret = NUCLEOTIDE; - else if(name.equals("User Defined")) - ret = USER_DEFINED; - - return ret; - } - - public static String getColourName(int index) - { - String ret=null; - switch(index) - { - case CLUSTAL: ret = "Clustal"; break; - case BLOSUM: ret = "Blosum62"; break; - case PID: ret = "% Identity"; break; - case ZAPPO: ret = "Zappo"; break; - case HYDROPHOBIC: ret="Hydrophobic";break; - case HELIX: ret="Helix Propensity";break; - case STRAND: ret="Strand Propensity";break; - case TURN: ret="Turn Propensity";break; - case BURIED: ret="Buried Index";break; - case NUCLEOTIDE:ret="Nucleotide"; break; - case USER_DEFINED:ret="User Defined";break; - default: ret = "None"; break; - } - return ret; - } - - public static ColourSchemeI getColour(jalview.datamodel.AlignmentI al, String name) - { - return getColour(al, getColourIndexFromName(name)); - } - - public static ColourSchemeI getColour(jalview.datamodel.AlignmentI al, int index) - { - ColourSchemeI cs = null; - switch(index) - { - case CLUSTAL: cs = new ClustalxColourScheme(al.getSequences(), al.getWidth()); break; - case BLOSUM: cs = new Blosum62ColourScheme(); break; - case PID: cs = new PIDColourScheme(); break; - case ZAPPO: cs = new ZappoColourScheme(); break; - case HYDROPHOBIC: cs = new HydrophobicColourScheme(); break; - case HELIX: cs = new HelixColourScheme(); break; - case STRAND: cs = new StrandColourScheme(); break; - case TURN: cs = new TurnColourScheme(); break; - case BURIED: cs = new BuriedColourScheme(); break; - case NUCLEOTIDE: cs = new NucleotideColourScheme(); break; - case USER_DEFINED: - if(jalview.bin.Cache.getProperty("USER_DEFINED_COLOUR")!=null) - { - cs = jalview.gui.UserDefinedColours.loadDefaultColours(jalview.bin.Cache.getProperty("USER_DEFINED_COLOUR")); - } - break; - - default: break; - } - - return cs; - } -} +package jalview.schemes; + +public class ColourSchemeProperty +{ + public static final int CLUSTAL = 0; + public static final int BLOSUM = 1; + public static final int PID = 2; + public static final int ZAPPO = 3; + public static final int HYDROPHOBIC=4; + public static final int HELIX=5; + public static final int STRAND=6; + public static final int TURN = 7; + public static final int BURIED = 8; + public static final int NUCLEOTIDE = 9; + public static final int USER_DEFINED = 10; + public static final int NONE = 11; + + public static int getColourIndexFromName(String name) + { + int ret=11; + if(name.equalsIgnoreCase("Clustal")) + ret = CLUSTAL; + else if(name.equalsIgnoreCase("Blosum62")) + ret = BLOSUM; + else if(name.equalsIgnoreCase("% Identity")) + ret = PID; + else if(name.equalsIgnoreCase("Zappo")) + ret = ZAPPO; + else if(name.equalsIgnoreCase("Hydrophobic")) + ret = HYDROPHOBIC; + else if(name.equalsIgnoreCase("Helix Propensity")) + ret = HELIX; + else if(name.equalsIgnoreCase("Strand Propensity")) + ret = STRAND; + else if(name.equalsIgnoreCase("Turn Propensity")) + ret = TURN; + else if(name.equalsIgnoreCase("Buried Index")) + ret = BURIED; + else if(name.equalsIgnoreCase("Nucleotide")) + ret = NUCLEOTIDE; + else if(name.equalsIgnoreCase("User Defined")) + ret = USER_DEFINED; + + return ret; + } + + public static String getColourName(int index) + { + String ret=null; + switch(index) + { + case CLUSTAL: ret = "Clustal"; break; + case BLOSUM: ret = "Blosum62"; break; + case PID: ret = "% Identity"; break; + case ZAPPO: ret = "Zappo"; break; + case HYDROPHOBIC: ret="Hydrophobic";break; + case HELIX: ret="Helix Propensity";break; + case STRAND: ret="Strand Propensity";break; + case TURN: ret="Turn Propensity";break; + case BURIED: ret="Buried Index";break; + case NUCLEOTIDE:ret="Nucleotide"; break; + case USER_DEFINED:ret="User Defined";break; + default: ret = "None"; break; + } + return ret; + } + + public static ColourSchemeI getColour(jalview.datamodel.AlignmentI al, String name) + { + return getColour(al, getColourIndexFromName(name)); + } + + public static ColourSchemeI getColour(jalview.datamodel.AlignmentI al, int index) + { + ColourSchemeI cs = null; + switch(index) + { + case CLUSTAL: cs = new ClustalxColourScheme(al.getSequences(), al.getWidth()); break; + case BLOSUM: cs = new Blosum62ColourScheme(); break; + case PID: cs = new PIDColourScheme(); break; + case ZAPPO: cs = new ZappoColourScheme(); break; + case HYDROPHOBIC: cs = new HydrophobicColourScheme(); break; + case HELIX: cs = new HelixColourScheme(); break; + case STRAND: cs = new StrandColourScheme(); break; + case TURN: cs = new TurnColourScheme(); break; + case BURIED: cs = new BuriedColourScheme(); break; + case NUCLEOTIDE: cs = new NucleotideColourScheme(); break; + case USER_DEFINED: + // if(jalview.bin.Cache.getProperty("USER_DEFINED_COLOUR")!=null) + { + // cs = jalview.gui.UserDefinedColours.loadDefaultColours(jalview.bin.Cache.getProperty("USER_DEFINED_COLOUR")); + } + break; + + default: break; + } + + return cs; + } +} diff --git a/src/jalview/schemes/ConservationColourScheme.java b/src/jalview/schemes/ConservationColourScheme.java index 88a6686..6394124 100755 --- a/src/jalview/schemes/ConservationColourScheme.java +++ b/src/jalview/schemes/ConservationColourScheme.java @@ -1,86 +1,87 @@ -/* Jalview - a java multiple alignment editor - * Copyright (C) 1998 Michele Clamp - * - * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package jalview.schemes; -import java.awt.*; -import jalview.analysis.*; -import java.util.Vector; - -public class ConservationColourScheme extends ResidueColourScheme { - public Conservation conserve; - public ColourSchemeI cs; - public int inc = 30; - - public ConservationColourScheme(Conservation cons, ColourSchemeI oldcs) - { - super(); - conserve = cons; - cs = oldcs; - } - - public void setConsensus(Vector consensus) - { - this.consensus = consensus; - cs.setConsensus(consensus); - } - - public Color findColour(String s, int i) - { - Color c = Color.white; - if (cs == null) - return c; - - char ch = conserve.getConsSequence().getSequence().charAt(i); - if (ch == '*' || ch == '+') - { - c = cs.findColour(s, i); - } - else - { - int tmp = 10; - int t = 0; - if (!jalview.util.Comparison.isGap(ch)) - t = Integer.parseInt(ch + ""); - - c = cs.findColour(s, i); - - while (tmp >= t) - { - c = lighter(c, inc); - tmp--; - } - - } - - return c; - } - - - public Color lighter(Color c, int inc) { - int red = c.getRed(); - int blue = c.getBlue(); - int green = c.getGreen(); - - if (red < 255-inc) { red = red +inc;} else {red = 255;} - if (blue < 255-inc) { blue = blue +inc;} else {blue = 255;} - if (green < 255-inc) { green = green +inc;} else {green = 255;} - - return new Color(red,green,blue); - } - -} +/* Jalview - a java multiple alignment editor + * Copyright (C) 1998 Michele Clamp + * + * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package jalview.schemes; +import java.awt.*; +import jalview.analysis.*; +import java.util.Vector; + +public class ConservationColourScheme extends ResidueColourScheme { + public Conservation conserve; + public ColourSchemeI cs; + public int inc = 30; + + public ConservationColourScheme(Conservation cons, ColourSchemeI oldcs) + { + super(); + conserve = cons; + cs = oldcs; + } + + public void setConsensus(Vector consensus) + { + this.consensus = consensus; + if(cs!=null) + cs.setConsensus(consensus); + } + + public Color findColour(String s, int i) + { + Color c = Color.white; + if (cs == null) + return c; + + char ch = conserve.getConsSequence().getSequence().charAt(i); + if (ch == '*' || ch == '+') + { + c = cs.findColour(s, i); + } + else + { + int tmp = 10; + int t = 0; + if (!jalview.util.Comparison.isGap(ch)) + t = Integer.parseInt(ch + ""); + + c = cs.findColour(s, i); + + while (tmp >= t) + { + c = lighter(c, inc); + tmp--; + } + + } + + return c; + } + + + public Color lighter(Color c, int inc) { + int red = c.getRed(); + int blue = c.getBlue(); + int green = c.getGreen(); + + if (red < 255-inc) { red = red +inc;} else {red = 255;} + if (blue < 255-inc) { blue = blue +inc;} else {blue = 255;} + if (green < 255-inc) { green = green +inc;} else {green = 255;} + + return new Color(red,green,blue); + } + +} -- 1.7.10.2