2 import jalview.schemes.ResidueColourScheme;
3 import jalview.schemes.ColourSchemes;
4 import jalview.datamodel.AnnotatedCollectionI;
6 import jalview.datamodel.SequenceI;
9 * Example script that registers two new alignment colour schemes
13 * Class that defines a colour scheme where odd columns are red,
14 * even numbered columns are blue, and gaps are yellow
16 class Stripy extends ResidueColourScheme {
18 String getSchemeName() { "stripy" }
19 Stripy getInstance(AnnotatedCollectionI coll, Map map) { new Stripy() }
20 Color findColour(char res, int col, SequenceI seq) {
21 // determine the colour
22 Color colour = findColour(res, col)
23 // let Jalview apply conservation or consensus shading
24 adjustColour(res, col, colour);
26 Color findColour(char res, int col) {
27 if (res == ' ' || res == '-' || res == '.')
30 } else if (col % 2 == 0)
41 * Class that defines a colour scheme graduated
42 * (approximately) by amino acid weight
44 class ByWeight extends ResidueColourScheme {
48 boolean isPeptideSpecific() {true}
49 String getSchemeName() { "By Weight" }
50 ByWeight getInstance(AnnotatedCollectionI coll, Map map) { new ByWeight() }
51 Color makeColour(int weight) {
52 int i = 255 * (weight - min) / (max - min);
55 Color findColour(char res, int col, SequenceI seq) {
56 // determine the colour
57 Color colour = findColour(res, col)
58 // let Jalview apply any conservation or consensus shading
59 adjustColour(res, col, colour);
61 Color findColour(char res, int col) {
124 ColourSchemes.instance.registerColourScheme(new Stripy())
125 ColourSchemes.instance.registerColourScheme(new ByWeight())