2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.schemes;
23 import jalview.datamodel.AlignmentAnnotation;
24 import jalview.datamodel.AnnotatedCollectionI;
25 import jalview.datamodel.SequenceCollectionI;
26 import jalview.datamodel.SequenceI;
27 import jalview.util.Comparison;
29 import java.awt.Color;
32 public class Blosum62ColourScheme extends ResidueColourScheme
34 private static final Color LIGHT_BLUE = new Color(204, 204, 255);
35 private static final Color DARK_BLUE = new Color(154, 154, 255);
37 public Blosum62ColourScheme()
43 * Returns a new instance of this colour scheme with which the given data may
47 public ColourSchemeI getInstance(AnnotatedCollectionI coll,
48 Map<SequenceI, SequenceCollectionI> hrs)
50 return new Blosum62ColourScheme();
54 public Color findColour(char res, int j, SequenceI seq)
56 if ('a' <= res && res <= 'z')
62 if (consensus == null || consensus.get(j) == null
63 || (threshold != 0 && !aboveThreshold(res, j)))
70 if (!Comparison.isGap(res))
73 * test if this is the consensus (or joint consensus) residue
75 String max = consensus.get(j).getModalResidue();
77 if (max.indexOf(res) > -1)
79 currentColour = DARK_BLUE;
89 c += ResidueProperties.getBLOSUM62(max.charAt(max_aa), res);
90 } while (++max_aa < n);
94 currentColour = LIGHT_BLUE;
98 currentColour = Color.white;
102 if (conservationColouring)
104 currentColour = applyConservation(currentColour, j);
112 return currentColour;
116 public boolean isPeptideSpecific()
122 public String getSchemeName()
124 return JalviewColourScheme.Blosum62.toString();
128 * Answers true if Conservation annotation is present, else false
131 public boolean isApplicableTo(AnnotatedCollectionI ac)
133 AlignmentAnnotation[] anns = ac.getAlignmentAnnotation();
138 for (AlignmentAnnotation ann : anns)
140 if ("Conservation".equals(ann.label))