From 2efd78f2ea2ca9cb61b259fbb22d6d125db7fd4c Mon Sep 17 00:00:00 2001 From: Daniel Barton Date: Fri, 30 Aug 2013 17:11:12 +0100 Subject: [PATCH] Colour be RNA helices bug fixed --- src/jalview/schemes/RNAHelicesColour.java | 3 ++- src/jalview/schemes/RNAHelicesColourChooser.java | 20 ++++++++++++++-- src/jalview/ws/jws2/RNAalifoldClient.java | 28 ++++++++++++++-------- 3 files changed, 38 insertions(+), 13 deletions(-) diff --git a/src/jalview/schemes/RNAHelicesColour.java b/src/jalview/schemes/RNAHelicesColour.java index 168aa31..a2ffff5 100644 --- a/src/jalview/schemes/RNAHelicesColour.java +++ b/src/jalview/schemes/RNAHelicesColour.java @@ -66,7 +66,8 @@ public class RNAHelicesColour extends ResidueColourScheme public void refresh() { - if (lastrefresh != annotation._rnasecstr.hashCode() + if ((annotation._rnasecstr == null + || lastrefresh != annotation._rnasecstr.hashCode()) && annotation.isValidStruc()) { annotation.getRNAStruc(); diff --git a/src/jalview/schemes/RNAHelicesColourChooser.java b/src/jalview/schemes/RNAHelicesColourChooser.java index 25b65b3..cef7eb6 100644 --- a/src/jalview/schemes/RNAHelicesColourChooser.java +++ b/src/jalview/schemes/RNAHelicesColourChooser.java @@ -97,8 +97,24 @@ public class RNAHelicesColourChooser return; } - currentAnnotation = av.getAlignment().getAlignmentAnnotation()[0];// annotations.getSelectedIndex()]; - + // This loop will find the first rna structure annotation by which to colour + // the sequences. + AlignmentAnnotation[] annotations = av.getAlignment().getAlignmentAnnotation(); + for (int i = 0; i < annotations.length; i++) { + + // is this a sensible way of determining type of annotation? + if (annotations[i].getRNAStruc() != null) { + currentAnnotation = annotations[i]; + break; + } + } + if (currentAnnotation == null) + { + System.err.println("Jalview is about to try and colour by RNAHelices even" + + " though there are no RNA secondary structure annotations present!"); + currentAnnotation = av.getAlignment().getAlignmentAnnotation()[0];// annotations.getSelectedIndex()]; + } + RNAHelicesColour rhc = null; rhc = new RNAHelicesColour(currentAnnotation); diff --git a/src/jalview/ws/jws2/RNAalifoldClient.java b/src/jalview/ws/jws2/RNAalifoldClient.java index 6f4dc48..7cd4230 100644 --- a/src/jalview/ws/jws2/RNAalifoldClient.java +++ b/src/jalview/ws/jws2/RNAalifoldClient.java @@ -4,16 +4,14 @@ import jalview.api.AlignCalcWorkerI; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.Annotation; import jalview.gui.AlignFrame; +import jalview.ws.jws2.dm.AAConSettings; import jalview.ws.jws2.jabaws2.Jws2Instance; import jalview.ws.params.WsParamSetI; import java.text.MessageFormat; import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; import java.util.LinkedHashMap; +import java.util.List; import java.util.TreeSet; import java.util.regex.Pattern; @@ -47,8 +45,17 @@ public class RNAalifoldClient extends JabawsAlignCalcWorker implements nucleotidesAllowed = true; proteinAllowed = false; - - } + initViewportParams(); + } + + protected void initViewportParams() + { + ((jalview.gui.AlignViewport) alignViewport).setCalcIdSettingsFor( + getCalcId(), + new AAConSettings(true, service, this.preset, + (arguments != null) ? JabaParamStore + .getJwsArgsfromJaba(arguments) : null), true); + } @Override public String getServiceActionText() @@ -71,8 +78,6 @@ public class RNAalifoldClient extends JabawsAlignCalcWorker implements List structs = ((RNAStructScoreManager) scoremanager).getStructs(); List> data = ((RNAStructScoreManager) scoremanager).getData(); - System.out.println("Length of RNAStructScoreManager is: " + structs.size()); - // test to see if this data object contains base pair contacts Score fscore = data.get(0).first(); this.bpScores = (fscore.getMethod().equals( @@ -153,7 +158,8 @@ public class RNAalifoldClient extends JabawsAlignCalcWorker implements annotation.belowAlignment = false; // annotation.showAllColLabels = true; - annotation.validateRangeAndDisplay(); + alignViewport.getAlignment().validateAnnotation(annotation); + af.setMenusForViewport(); ourAnnot.add(annotation); } @@ -220,6 +226,8 @@ public class RNAalifoldClient extends JabawsAlignCalcWorker implements String typename = ""; String datatype = score.getMethod(); + + // Look up java switch syntax and use one here if (datatype.equals(AlifoldResult.mfeStructure.toString())) { description = MessageFormat.format("Minimum Free Energy Structure. Energy: {0} = {1} + {2}", @@ -279,7 +287,7 @@ public class RNAalifoldClient extends JabawsAlignCalcWorker implements } private char isSS (char chr) { - String regex = "\\(|\\)|\\{|\\}|\\[|\\]"; + String regex = "\\(|\\)|\\{|\\}|\\[|\\]"; char ss = (Pattern.matches(regex, Character.toString(chr))) ? 'S': ' '; return ss; } -- 1.7.10.2