From: janengelhardt Date: Thu, 11 Aug 2011 00:07:08 +0000 (+0200) Subject: JAL-885; hasRNAStructure method was introduced to AlignmentI and X-Git-Tag: Jalview_2_9~576^2~10 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=478701c9ed0354b27e4cd74789f8c01a5c9ff004;p=jalview.git JAL-885; hasRNAStructure method was introduced to AlignmentI and Alignment; determines if Alignment contains an RNA structure; Structure conservation row is just added if yes; Change-Id: I6fa20f14e54cd656c65f82bc6b68f84d1d6f2c64 --- diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index 4e279d3..a2392b1 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -43,6 +43,8 @@ public class Alignment implements AlignmentI public static final int PROTEIN = 0; public static final int NUCLEOTIDE = 1; + + public boolean hasRNAStructure = false; /** DOCUMENT ME!! */ public AlignmentAnnotation[] annotations; @@ -732,6 +734,10 @@ public class Alignment implements AlignmentI */ public void addAnnotation(AlignmentAnnotation aa, int pos) { + if(aa.getRNAStruc()!= null){ + hasRNAStructure=true; + } + int aSize = 1; if (annotations != null) { @@ -832,6 +838,10 @@ public class Alignment implements AlignmentI return false; } } + + public boolean hasRNAStructure(){ + return hasRNAStructure; + } public void setDataset(Alignment data) { diff --git a/src/jalview/datamodel/AlignmentI.java b/src/jalview/datamodel/AlignmentI.java index 2e0903d..05d3a10 100755 --- a/src/jalview/datamodel/AlignmentI.java +++ b/src/jalview/datamodel/AlignmentI.java @@ -204,9 +204,9 @@ public interface AlignmentI /** * Deletes a specific AlignmentAnnotation from the alignment, and removes its - * reference from any SequenceI or SequenceGroup object's annotation if and only if aa is - * contained within the alignment's annotation vector. Otherwise, it will do - * nothing. + * reference from any SequenceI or SequenceGroup object's annotation if and + * only if aa is contained within the alignment's annotation vector. + * Otherwise, it will do nothing. * * @param aa * the annotation to delete @@ -215,15 +215,17 @@ public interface AlignmentI public boolean deleteAnnotation(AlignmentAnnotation aa); /** - * Deletes a specific AlignmentAnnotation from the alignment, and optionally removes any - * reference from any SequenceI or SequenceGroup object's annotation if and only if aa is - * contained within the alignment's annotation vector. Otherwise, it will do - * nothing. + * Deletes a specific AlignmentAnnotation from the alignment, and optionally + * removes any reference from any SequenceI or SequenceGroup object's + * annotation if and only if aa is contained within the alignment's annotation + * vector. Otherwise, it will do nothing. * * @param aa * the annotation to delete * @param unhook - * flag indicating if any references should be removed from annotation - use this if you intend to add the annotation back into the alignment + * flag indicating if any references should be removed from + * annotation - use this if you intend to add the annotation back + * into the alignment * @return true if annotation was deleted from this alignment. */ public boolean deleteAnnotation(AlignmentAnnotation aa, boolean unhook); @@ -259,6 +261,13 @@ public interface AlignmentI public boolean isNucleotide(); /** + * Test if alignment contains RNA structure + * + * @return true if RNA structure AligmnentAnnotation was added to alignment + */ + public boolean hasRNAStructure(); + + /** * Set alignment to be a nucleotide sequence * */ diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 0a9cad4..b056fec 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -413,7 +413,7 @@ public class AlignViewport implements SelectionSource, VamsasSource consensus.hasText = true; consensus.autoCalculated = true; - if (alignment.isNucleotide()) + if (alignment.isNucleotide() && alignment.hasRNAStructure()) { strucConsensus = new AlignmentAnnotation("StrucConsensus", "PID", new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH); @@ -425,7 +425,7 @@ public class AlignViewport implements SelectionSource, VamsasSource { alignment.addAnnotation(consensus); // TODO: Make own if for structure - if (alignment.isNucleotide()) + if (alignment.isNucleotide() && alignment.hasRNAStructure()) { alignment.addAnnotation(strucConsensus); }