X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fschemes%2FRNAHelicesColour.java;h=33b275d7f192b74ca64f337961b2b694f1bcb35f;hb=f3fa435d421eb9f071a526f802801c4a21ee2dc4;hp=9729a8347f2de9bc3a2e8c32ed7c5a2f070e7be7;hpb=dea079f732d46e67066405edece02f673f9c0f0c;p=jalview.git diff --git a/src/jalview/schemes/RNAHelicesColour.java b/src/jalview/schemes/RNAHelicesColour.java index 9729a83..33b275d 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; @@ -44,7 +46,7 @@ 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 @@ -54,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) @@ -116,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 @@ -142,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()); } } @@ -197,9 +207,44 @@ public class RNAHelicesColour extends ResidueColourScheme } @Override - public ColourSchemeI applyTo(AnnotatedCollectionI sg, - Map hiddenRepSequences) + public ColourSchemeI getInstance(AlignViewportI view, + AnnotatedCollectionI sg) + { + 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 new RNAHelicesColour(this); + return false; } -} \ No newline at end of file +}