Merge branch 'JAL-952_rnahelix' into develop
authorJim Procter <jprocter@dundee.ac.uk>
Sun, 27 Apr 2014 20:41:06 +0000 (21:41 +0100)
committerJim Procter <jprocter@dundee.ac.uk>
Sun, 27 Apr 2014 20:41:06 +0000 (21:41 +0100)
Conflicts:
src/jalview/schemes/ColourSchemeProperty.java

examples-jbake/content/appletParameters.html
examples/appletParameters.html
src/jalview/schemes/ColourSchemeProperty.java
src/jalview/schemes/RNAHelicesColour.java
src/jalview/schemes/RNAHelicesColourChooser.java
test/jalview/io/Jalview2xmlTests.java

index e02a7be..b936824 100644 (file)
@@ -78,7 +78,7 @@ the applet can be interacted with <em>via</em> its
             <td>defaultColour</td>
             <td> <em>One of: </em><br>
               Clustal, Blosum62, % Identity, Hydrophobic, Zappo, Taylor, Helix 
-              Propensity, Strand Propensity, Turn Propensity, Buried Index, Nucleotide</td>
+              Propensity, Strand Propensity, Turn Propensity, Buried Index, Nucleotide, T-Coffee Scores, RNA Helices</td>
             <td>Default is no colour.</td>
           </tr>
           <tr> 
index a1af716..fe29b2e 100644 (file)
@@ -236,7 +236,7 @@ the applet can be interacted with <em>via</em> its
             <td>defaultColour</td>
             <td> <em>One of: </em><br>
               Clustal, Blosum62, % Identity, Hydrophobic, Zappo, Taylor, Helix 
-              Propensity, Strand Propensity, Turn Propensity, Buried Index, Nucleotide</td>
+              Propensity, Strand Propensity, Turn Propensity, Buried Index, Nucleotide, T-Coffee Scores, RNA Helices</td>
             <td>Default is no colour.</td>
           </tr>
           <tr> 
index 91a4890..8996691 100755 (executable)
@@ -86,6 +86,8 @@ public class ColourSchemeProperty
   public static final int COVARIATION = 14;
 
   public static final int TCOFFEE = 15;
+  
+  public static final int RNAHELIX = 16;
 
   public static final int RNAINTERACTION = 16;
 
@@ -94,7 +96,7 @@ public class ColourSchemeProperty
    */
   public static final int FIRST_COLOUR = NONE;
 
-  public static final int LAST_COLOUR = NUCLEOTIDE;
+  public static final int LAST_COLOUR = RNAHELIX;
 
   /**
    * DOCUMENT ME!
@@ -169,11 +171,14 @@ public class ColourSchemeProperty
     {
       ret = PURINEPYRIMIDINE;
     }
-    
     else if (name.equalsIgnoreCase("RNA Interaction type"))
     {
       ret = RNAINTERACTION;
     }
+    else if (name.equalsIgnoreCase("RNA Helices"))
+    {
+      ret = RNAHELIX;
+    }
     // else if (name.equalsIgnoreCase("Covariation"))
     // {
     // ret = COVARIATION;
@@ -247,9 +252,16 @@ public class ColourSchemeProperty
     {
       index = TCOFFEE;
     }
+<<<<<<< HEAD
    
     
     
+=======
+    else if (cs instanceof RNAHelicesColour)
+    {
+      index = RNAHELIX;
+    }
+>>>>>>> JAL-952_rnahelix
     /*
      * else if (cs instanceof CovariationColourScheme) { index = COVARIATION; }
      */
@@ -344,11 +356,18 @@ public class ColourSchemeProperty
       ret = "T-Coffee Scores";
 
       break;
+<<<<<<< HEAD
       
     case RNAINTERACTION:
         ret = "RNA Interaction type";
 
         break;
+=======
+    case RNAHELIX:
+      ret = "RNA Helices";
+
+      break;
+>>>>>>> JAL-952_rnahelix
     /*
      * case COVARIATION: ret = "Covariation";
      * 
@@ -501,6 +520,10 @@ public class ColourSchemeProperty
     case TCOFFEE:
       cs = new TCoffeeColourScheme(coll);
       break;
+    
+    case RNAHELIX:
+      cs = new RNAHelicesColour(coll);
+      break;
       
       // case COVARIATION:
       // cs = new CovariationColourScheme(annotation);
index 7cbca66..06553f0 100644 (file)
@@ -20,8 +20,11 @@ package jalview.schemes;
 
 import java.awt.*;
 import java.util.Hashtable;
+import java.util.Map;
 
 import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AnnotatedCollectionI;
+import jalview.datamodel.SequenceCollectionI;
 import jalview.datamodel.SequenceI;
 
 /**
@@ -62,14 +65,40 @@ public class RNAHelicesColour extends ResidueColourScheme
     this.annotation = annotation;
     refresh();
   }
+  public RNAHelicesColour(AnnotatedCollectionI alignment)
+  {
+    super(ResidueProperties.nucleotideIndex);
+    alignmentChanged(alignment, null);
+  }
+
+  @Override
+  public void alignmentChanged(AnnotatedCollectionI alignment,
+          Map<SequenceI, SequenceCollectionI> hiddenReps)
+  {
 
+    // This loop will find the first rna structure annotation by which to colour
+    //  the sequences.
+    AlignmentAnnotation[] annotations = alignment.getAlignmentAnnotation();
+    for (int i = 0; i < annotations.length; i++) {
+        
+        // is this a sensible way of determining type of annotation?
+        if (annotations[i].getRNAStruc() != null) { 
+                annotation = annotations[i];
+                break;
+        }
+    }
+
+    refresh();
+
+  }
   private long lastrefresh = -1;
 
   public void refresh()
   {
-    if ((annotation._rnasecstr == null
+    
+    if (annotation!=null && ((annotation._rnasecstr == null
                || lastrefresh != annotation._rnasecstr.hashCode())
-            && annotation.isValidStruc())
+            && annotation.isValidStruc()))
     {
       annotation.getRNAStruc();
       lastrefresh = annotation._rnasecstr.hashCode();
index 45c374d..bcac5c7 100644 (file)
@@ -97,28 +97,9 @@ public class RNAHelicesColourChooser
     {
       return;
     }
-
-    // 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);
+    rhc = new RNAHelicesColour(av.getAlignment());
 
     av.setGlobalColourScheme(rhc);
 
@@ -131,7 +112,7 @@ public class RNAHelicesColourChooser
           continue;
         }
 
-        sg.cs = new RNAHelicesColour(currentAnnotation);
+        sg.cs = new RNAHelicesColour(sg);
 
       }
     }
index 4ef038a..3a69595 100644 (file)
@@ -57,6 +57,8 @@ public class Jalview2xmlTests
     assertTrue("Didn't read input file "+inFile, af!=null);
     int olddsann=countDsAnn(af.getViewport());
     assertTrue("Didn't find any dataset annotations",olddsann>0);
+    af.rnahelicesColour_actionPerformed(null);
+    assertTrue("Couldn't apply RNA helices colourscheme",af.getViewport().getGlobalColourScheme() instanceof jalview.schemes.RNAHelicesColour);
     assertTrue("Failed to store as a project.",af.saveAlignment(tfile, "Jalview"));
     af.closeMenuItem_actionPerformed(true);
     af=null;
@@ -65,6 +67,7 @@ public class Jalview2xmlTests
     int newdsann=countDsAnn(af.getViewport());
     assertTrue("Differing numbers of dataset sequence annotation\nOriginally "+olddsann+" and now "+newdsann,olddsann==newdsann);
     System.out.println("Read in same number of annotations as originally present ("+olddsann+")");
+    assertTrue("RNA helices colourscheme was not applied on import.",af.getViewport().getGlobalColourScheme() instanceof jalview.schemes.RNAHelicesColour);
   }
   @Test
   public void testTCoffeeScores() throws Exception
@@ -93,5 +96,4 @@ public class Jalview2xmlTests
     assertTrue("Didn't set T-coffee colourscheme for imported project.",af.getViewport().getGlobalColourScheme().getClass().equals(jalview.schemes.TCoffeeColourScheme.class));
     System.out.println("T-Coffee score shading successfully recovered from project.");
   }
-
 }