X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fschemes%2FRNAHelicesColour.java;h=0011d5c641053e03400a24130463a9b671e0c486;hb=1d0f5219658cdf6ad5e1a1cbe6e1bb8cd12e6d85;hp=ffc013d654ced7a2ad6b1e113356cbcc33070553;hpb=60b63ec67604be95d1be4ff04e51c5705b05b109;p=jalview.git diff --git a/src/jalview/schemes/RNAHelicesColour.java b/src/jalview/schemes/RNAHelicesColour.java index ffc013d..0011d5c 100644 --- a/src/jalview/schemes/RNAHelicesColour.java +++ b/src/jalview/schemes/RNAHelicesColour.java @@ -20,7 +20,9 @@ */ package jalview.schemes; +import jalview.api.AlignViewportI; import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.AlignmentI; import jalview.datamodel.AnnotatedCollectionI; import jalview.datamodel.SequenceCollectionI; import jalview.datamodel.SequenceI; @@ -40,12 +42,11 @@ import java.util.Map; public class RNAHelicesColour extends ResidueColourScheme { - /** * Maps sequence positions to the RNA helix they belong to. Key: position, * Value: helix TODO: Revise or drop in favour of annotation position numbers */ - public Hashtable positionsToHelix = new Hashtable(); + public Hashtable positionsToHelix = new Hashtable<>(); /** * Number of helices in the RNA secondary structure @@ -55,6 +56,14 @@ public class RNAHelicesColour extends ResidueColourScheme public AlignmentAnnotation annotation; /** + * Default constructor (required for ColourSchemes cache) + */ + public RNAHelicesColour() + { + + } + + /** * Creates a new RNAHelicesColour object. */ public RNAHelicesColour(AlignmentAnnotation annotation) @@ -92,6 +101,10 @@ public class RNAHelicesColour extends ResidueColourScheme // This loop will find the first rna structure annotation by which to colour // the sequences. AlignmentAnnotation[] annotations = alignment.getAlignmentAnnotation(); + if (annotations == null) + { + return; + } for (int i = 0; i < annotations.length; i++) { @@ -113,14 +126,14 @@ public class RNAHelicesColour extends ResidueColourScheme public void refresh() { - if (annotation != null - && ((annotation._rnasecstr == null || lastrefresh != annotation._rnasecstr - .hashCode()) && annotation.isValidStruc())) + if (annotation != null && ((annotation._rnasecstr == null + || lastrefresh != annotation._rnasecstr.hashCode()) + && annotation.isValidStruc())) { annotation.getRNAStruc(); lastrefresh = annotation._rnasecstr.hashCode(); numHelix = 0; - positionsToHelix = new Hashtable(); + positionsToHelix = new Hashtable<>(); // Figure out number of helices // Length of rnasecstr is the number of pairs of positions that base pair @@ -139,11 +152,11 @@ public class RNAHelicesColour extends ResidueColourScheme positionsToHelix.put(this.annotation._rnasecstr[x].getEnd(), this.annotation._rnasecstr[x].getFeatureGroup()); - if (Integer.parseInt(this.annotation._rnasecstr[x] - .getFeatureGroup()) > numHelix) + if (Integer.parseInt( + this.annotation._rnasecstr[x].getFeatureGroup()) > numHelix) { - numHelix = Integer.parseInt(this.annotation._rnasecstr[x] - .getFeatureGroup()); + numHelix = Integer.parseInt( + this.annotation._rnasecstr[x].getFeatureGroup()); } } @@ -194,9 +207,45 @@ public class RNAHelicesColour extends ResidueColourScheme } @Override - public ColourSchemeI applyTo(AnnotatedCollectionI sg, + public ColourSchemeI getInstance(AlignViewportI view, + AnnotatedCollectionI sg, Map hiddenRepSequences) { - return new RNAHelicesColour(this); + return new RNAHelicesColour(sg); + } + + @Override + public boolean isNucleotideSpecific() + { + return true; + } + + /** + * Answers true if the data has RNA secondary structure annotation + */ + @Override + public boolean isApplicableTo(AnnotatedCollectionI ac) + { + if (ac instanceof AlignmentI && ((AlignmentI) ac).hasRNAStructure()) + { + return true; + } + + /* + * not currently supporting this option for group annotation / colouring + */ + return false; + } + + @Override + public String getSchemeName() + { + return JalviewColourScheme.RNAHelices.toString(); + } + + @Override + public boolean isSimple() + { + return false; } -} \ No newline at end of file +}