2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5)
3 * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
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 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
18 package jalview.schemes;
21 import java.util.Hashtable;
23 import jalview.datamodel.AlignmentAnnotation;
26 * Looks at the information computed from an RNA Stockholm format file on the
27 * secondary structure of the alignment. Extracts the information on the
28 * positions of the helices present and assigns colors.
30 * @author Lauren Michelle Lui
33 public class RNAHelicesColour extends ResidueColourScheme
37 * Stores random colors generated for the number of helices
39 public Hashtable helixcolorhash = new Hashtable();
42 * Maps sequence positions to the RNA helix they belong to. Key: position,
45 public Hashtable positionsToHelix = new Hashtable();
48 * Number of helices in the RNA secondary structure
52 public AlignmentAnnotation annotation;
55 * Creates a new RNAHelicesColour object.
57 public RNAHelicesColour(AlignmentAnnotation annotation)
59 this.annotation = annotation;
61 // Figure out number of helices
62 // Length of rnasecstr is the number of pairs of positions that base pair
63 // with each other in the secondary structure
64 for (int x = 0; x < this.annotation._rnasecstr.length; x++)
68 * System.out.println(this.annotation._rnasecstr[x] + " Begin" +
69 * this.annotation._rnasecstr[x].getBegin());
71 // System.out.println(this.annotation._rnasecstr[x].getFeatureGroup());
73 positionsToHelix.put(this.annotation._rnasecstr[x].getBegin(),
74 this.annotation._rnasecstr[x].getFeatureGroup());
75 positionsToHelix.put(this.annotation._rnasecstr[x].getEnd(),
76 this.annotation._rnasecstr[x].getFeatureGroup());
78 if (Integer.parseInt(this.annotation._rnasecstr[x].getFeatureGroup()) > numHelix)
80 numHelix = Integer.parseInt(this.annotation._rnasecstr[x]
86 // Generate random colors and store
87 for (int j = 0; j <= numHelix; j++)
89 helixcolorhash.put(Integer.toString(j), jalview.util.ColorUtils
90 .generateRandomColor(Color.white));
96 * Returns default color base on purinepyrimidineIndex in
97 * jalview.schemes.ResidueProperties (Allows coloring in sequence logo)
100 * Character in sequence
102 * @return color in RGB
104 public Color findColour(char c)
106 return ResidueProperties.purinepyrimidine[ResidueProperties.purinepyrimidineIndex[c]];
107 // random colors for all positions
108 // jalview.util.ColorUtils.generateRandomColor(Color.white); If you want
112 * Returns color based on helices
115 * Character in sequence
119 * @return Color in RGB
121 public Color findColour(char c, int j)
123 Color currentColour = Color.white;
124 String currentHelix = null;
125 currentHelix = (String) positionsToHelix.get(j);
127 if (currentHelix != null)
129 currentColour = (Color) helixcolorhash.get(currentHelix);
132 // System.out.println(c + " " + j + " helix " + currentHelix + " " +
134 return currentColour;