updated to jalview 2.1 and begun ArchiveClient/VamsasClient/VamsasStore updates.
[jalview.git] / src / jalview / schemes / PIDColourScheme.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer
3  * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
18  */
19 package jalview.schemes;
20
21 import java.awt.*;
22
23 import jalview.datamodel.*;
24
25 public class PIDColourScheme
26     extends ResidueColourScheme
27 {
28   public Color[] pidColours;
29   public float[] thresholds;
30   SequenceGroup group;
31
32   public PIDColourScheme()
33   {
34     this.pidColours = ResidueProperties.pidColours;
35     this.thresholds = ResidueProperties.pidThresholds;
36   }
37
38   public Color findColour(String s, int j)
39   {
40     char res = s.charAt(0);
41     if ('a' <= res && res <= 'z')
42     {
43       s = String.valueOf(res -= ('a' - 'A'));
44     }
45
46
47     if ( (threshold != 0) && !aboveThreshold(s, j))
48     {
49       return Color.white;
50     }
51
52     currentColour = Color.white;
53
54     double sc = 0;
55
56     if(consensus.length<=j)
57       return Color.white;
58
59       if ( (Integer.parseInt(consensus[j].get("maxCount").toString()) != -1) &&
60           consensus[j].contains(s))
61       {
62         sc = ( (Float) consensus[j].get(ignoreGaps)).floatValue();
63
64         if (!jalview.util.Comparison.isGap(res))
65         {
66           for (int i = 0; i < thresholds.length; i++)
67           {
68             if (sc > thresholds[i])
69             {
70               currentColour = pidColours[i];
71
72               break;
73             }
74           }
75         }
76       }
77
78     if(conservationColouring)
79          applyConservation(j);
80
81     return currentColour;
82   }
83 }