X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fschemes%2FRNAHelicesColour.java;h=dbc9c03dd6ac5b3ab9c265f915eaa1997a45a1e7;hb=9e926ac4305fd9dff38b6e079e55b4f50664d544;hp=cc7f5cad8b8c15ffb07f3499e22a962440ed3b5a;hpb=c19d2a91ca05e052e3408bf5852d88eb5d0608f1;p=jalview.git diff --git a/src/jalview/schemes/RNAHelicesColour.java b/src/jalview/schemes/RNAHelicesColour.java index cc7f5ca..dbc9c03 100644 --- a/src/jalview/schemes/RNAHelicesColour.java +++ b/src/jalview/schemes/RNAHelicesColour.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b2) - * Copyright (C) 2015 The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors * * This file is part of Jalview. * @@ -21,6 +21,7 @@ package jalview.schemes; import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.AlignmentI; import jalview.datamodel.AnnotatedCollectionI; import jalview.datamodel.SequenceCollectionI; import jalview.datamodel.SequenceI; @@ -54,6 +55,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) @@ -91,6 +100,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++) { @@ -112,9 +125,9 @@ 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(); @@ -138,11 +151,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()); } } @@ -193,9 +206,44 @@ public class RNAHelicesColour extends ResidueColourScheme } @Override - public ColourSchemeI applyTo(AnnotatedCollectionI sg, + public ColourSchemeI getInstance(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 +}