From 5bf0d6b5cb67e66a38e82692c40426c21ba12593 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Tue, 9 Oct 2018 13:31:19 +0100 Subject: [PATCH] JAL-3127 Colour sequences by ID - need to check that group colours are properly propagated to structure view independently of shading by linked alignment by selecting from Structure Views colour menu. --- src/jalview/schemes/IdColourScheme.java | 101 ++++++++++++++++++++++++++ src/jalview/schemes/JalviewColourScheme.java | 3 +- 2 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 src/jalview/schemes/IdColourScheme.java diff --git a/src/jalview/schemes/IdColourScheme.java b/src/jalview/schemes/IdColourScheme.java new file mode 100644 index 0000000..a96ac0f --- /dev/null +++ b/src/jalview/schemes/IdColourScheme.java @@ -0,0 +1,101 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview 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 3 + * of the License, or (at your option) any later version. + * + * Jalview 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 Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ +package jalview.schemes; + +import jalview.api.AlignViewportI; +import jalview.datamodel.AnnotatedCollectionI; +import jalview.datamodel.SequenceCollectionI; +import jalview.datamodel.SequenceGroup; +import jalview.datamodel.SequenceI; + +import java.awt.Color; +import java.util.Map; + +public class IdColourScheme implements ColourSchemeI +{ + AlignViewportI view = null; + + AnnotatedCollectionI coll = null; + + public IdColourScheme() + { + + } + public IdColourScheme(AlignViewportI view, AnnotatedCollectionI coll) + { + this.view = view; + this.coll = coll; + } + + + @Override + public String getSchemeName() + { + return JalviewColourScheme.IdColour.toString(); + } + + /** + * Returns a new instance of this colour scheme with which the given data may + * be coloured + */ + @Override + public ColourSchemeI getInstance(AlignViewportI view, + AnnotatedCollectionI coll, + Map hrs) + { + return new IdColourScheme(view, coll); + } + + @Override + public void alignmentChanged(AnnotatedCollectionI alignment, + Map hiddenReps) + { + } + + @Override + public Color findColour(char symbol, int position, SequenceI seq, + String consensusResidue, float pid) + { + return (view == null) ? Color.WHITE + : ((coll instanceof SequenceGroup) + ? ((SequenceGroup) coll).idColour + : view.getSequenceColour(seq)); + } + + @Override + public boolean hasGapColour() + { + return false; + } + + @Override + public boolean isApplicableTo(AnnotatedCollectionI ac) + { + return true; + } + + @Override + public boolean isSimple() + { + // this is really a sequence colour + return true; + } +} diff --git a/src/jalview/schemes/JalviewColourScheme.java b/src/jalview/schemes/JalviewColourScheme.java index e1fc02d..4422d72 100644 --- a/src/jalview/schemes/JalviewColourScheme.java +++ b/src/jalview/schemes/JalviewColourScheme.java @@ -42,7 +42,8 @@ public enum JalviewColourScheme Nucleotide("Nucleotide", NucleotideColourScheme.class), PurinePyrimidine("Purine/Pyrimidine", PurinePyrimidineColourScheme.class), RNAHelices("RNA Helices", RNAHelicesColour.class), - TCoffee("T-Coffee Scores", TCoffeeColourScheme.class); + TCoffee("T-Coffee Scores", TCoffeeColourScheme.class), + IdColour("Sequence IDs", IdColourScheme.class); // RNAInteraction("RNA Interaction type", RNAInteractionColourScheme.class) private String name; -- 1.7.10.2