Colour be RNA helices bug fixed
authorDaniel Barton <daluke.barton@gmail.com>
Fri, 30 Aug 2013 16:11:12 +0000 (17:11 +0100)
committerDaniel Barton <daluke.barton@gmail.com>
Fri, 30 Aug 2013 16:11:12 +0000 (17:11 +0100)
src/jalview/schemes/RNAHelicesColour.java
src/jalview/schemes/RNAHelicesColourChooser.java
src/jalview/ws/jws2/RNAalifoldClient.java

index 168aa31..a2ffff5 100644 (file)
@@ -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();
index 25b65b3..cef7eb6 100644 (file)
@@ -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);
index 6f4dc48..7cd4230 100644 (file)
@@ -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<String> structs = ((RNAStructScoreManager) scoremanager).getStructs();
                        List<TreeSet<Score>> 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;
        }