Merge branch 'develop' into features/JAL-2446NCList
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 16 May 2017 11:18:05 +0000 (12:18 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 16 May 2017 11:18:05 +0000 (12:18 +0100)
src/jalview/appletgui/SeqPanel.java
src/jalview/datamodel/HiddenColumns.java
src/jalview/io/StockholmFile.java
test/jalview/datamodel/AlignmentTest.java
test/jalview/io/AnnotationFileIOTest.java
test/jalview/io/PhylipFileTests.java
test/jalview/io/RNAMLfileTest.java
test/jalview/io/StockholmFileTest.java
test/jalview/ws/jabaws/DisorderAnnotExportImport.java
test/jalview/ws/jabaws/JpredJabaStructExportImport.java
test/jalview/ws/jabaws/RNAStructExportImport.java

index f80c078..02dc848 100644 (file)
@@ -238,7 +238,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
       {
         ap.scrollUp(true);
       }
-      while (seqCanvas.cursorY + 1 > ranges.getEndSeq())
+      while (seqCanvas.cursorY > ranges.getEndSeq())
       {
         ap.scrollUp(false);
       }
index 2edb3f1..3685ab0 100644 (file)
@@ -1247,9 +1247,10 @@ public class HiddenColumns
   /**
    * Returns a hashCode built from hidden column ranges
    */
-  public int hashCode(int hc)
+  @Override
+  public int hashCode()
   {
-    int hashCode = hc;
+    int hashCode = 1;
     if (hiddenColumns != null)
     {
       for (int[] hidden : hiddenColumns)
index e4d9f60..c2f3683 100644 (file)
@@ -33,6 +33,7 @@ import jalview.datamodel.Sequence;
 import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceI;
 import jalview.schemes.ResidueProperties;
+import jalview.util.Comparison;
 import jalview.util.Format;
 import jalview.util.MessageManager;
 
@@ -817,12 +818,16 @@ public class StockholmFile extends AlignFile
       type = (label.indexOf("_cons") == label.length() - 5) ? label
               .substring(0, label.length() - 5) : label;
     }
-    boolean ss = false;
+    boolean ss = false, posterior = false;
     type = id2type(type);
-    if (type.equals("secondary structure"))
+    if (type.equalsIgnoreCase("secondary structure"))
     {
       ss = true;
     }
+    if (type.equalsIgnoreCase("posterior probability"))
+    {
+      posterior = true;
+    }
     // decide on secondary structure or not.
     Annotation[] els = new Annotation[annots.length()];
     for (int i = 0; i < annots.length(); i++)
@@ -857,6 +862,25 @@ public class StockholmFile extends AlignFile
         }
 
       }
+      if (posterior && !ann.isWhitespace()
+              && !Comparison.isGap(pos.charAt(0)))
+      {
+        float val = 0;
+        // symbol encodes values - 0..*==0..10
+        if (pos.charAt(0) == '*')
+        {
+          val = 10;
+        }
+        else
+        {
+          val = pos.charAt(0) - '0';
+          if (val > 9)
+          {
+            val = 10;
+          }
+        }
+        ann.value = val;
+      }
 
       els[i] = ann;
     }
@@ -1139,10 +1163,10 @@ public class StockholmFile extends AlignFile
     if (typeIds == null)
     {
       typeIds = new Hashtable();
-      typeIds.put("SS", "secondary structure");
-      typeIds.put("SA", "surface accessibility");
+      typeIds.put("SS", "Secondary Structure");
+      typeIds.put("SA", "Surface Accessibility");
       typeIds.put("TM", "transmembrane");
-      typeIds.put("PP", "posterior probability");
+      typeIds.put("PP", "Posterior Probability");
       typeIds.put("LI", "ligand binding");
       typeIds.put("AS", "active site");
       typeIds.put("IN", "intron");
@@ -1153,7 +1177,7 @@ public class StockholmFile extends AlignFile
       typeIds.put("DE", "description");
       typeIds.put("DR", "reference");
       typeIds.put("LO", "look");
-      typeIds.put("RF", "reference positions");
+      typeIds.put("RF", "Reference Positions");
 
     }
   }
@@ -1176,7 +1200,7 @@ public class StockholmFile extends AlignFile
     while (e.hasMoreElements())
     {
       Object ll = e.nextElement();
-      if (typeIds.get(ll).toString().equals(type))
+      if (typeIds.get(ll).toString().equalsIgnoreCase(type))
       {
         key = (String) ll;
         break;
index 660a69c..d6e09fd 100644 (file)
@@ -658,7 +658,7 @@ public class AlignmentTest
     assertFalse(iter.hasNext());
 
     // search for annotation with a particular label - expect three
-    anns = al.findAnnotations(null, null, "secondary structure");
+    anns = al.findAnnotations(null, null, "Secondary Structure");
     iter = anns.iterator();
     assertTrue(iter.hasNext());
     iter.next();
index 105f6e4..6a00cde 100644 (file)
@@ -153,7 +153,8 @@ public class AnnotationFileIOTest
                       DataSourceType.PASTE));
 
       // test for consistency in io
-      StockholmFileTest.testAlignmentEquivalence(al, al_new, false);
+      StockholmFileTest.testAlignmentEquivalence(al, al_new, false, false,
+              false);
       return;
     } catch (Exception e)
     {
index f99c67a..d853350 100644 (file)
@@ -190,7 +190,8 @@ public class PhylipFileTests
             DataSourceType.PASTE, FileFormat.Phylip);
     assertNotNull("Couldn't parse reimported alignment data.", al_input);
 
-    StockholmFileTest.testAlignmentEquivalence(al, al_input, false);
+    StockholmFileTest.testAlignmentEquivalence(al, al_input, false, false,
+            false);
 
   }
 }
index 1c54980..ae72de4 100644 (file)
@@ -53,7 +53,7 @@ public class RNAMLfileTest
   {
     StockholmFileTest.testFileIOwithFormat(new File(
             "examples/testdata/rna-alignment.xml"), FileFormat.Stockholm,
-            -1, -1, true);
+            -1, -1, true, true, true);
 
   }
 
index 1a18fb9..228c935 100644 (file)
@@ -60,7 +60,7 @@ public class StockholmFileTest
   public void pfamFileIO() throws Exception
   {
     testFileIOwithFormat(new File(PfamFile), FileFormat.Stockholm, -1, 0,
-            false);
+            false, false, false);
   }
 
   @Test(groups = { "Functional" })
@@ -86,7 +86,7 @@ public class StockholmFileTest
   public void rfamFileIO() throws Exception
   {
     testFileIOwithFormat(new File(RfamFile), FileFormat.Stockholm, 2, 1,
-            false);
+            false, false, false);
   }
 
   /**
@@ -98,11 +98,14 @@ public class StockholmFileTest
    * @param ioformat
    *          - label for IO class used to write and read back in the data from
    *          f
+   * @param ignoreFeatures
    * @param ignoreRowVisibility
+   * @param allowNullAnnotations
    */
 
   public static void testFileIOwithFormat(File f, FileFormatI ioformat,
-          int naliannot, int nminseqann, boolean ignoreRowVisibility)
+          int naliannot, int nminseqann, boolean ignoreFeatures,
+          boolean ignoreRowVisibility, boolean allowNullAnnotations)
   {
     System.out.println("Reading file: " + f);
     String ff = f.getPath();
@@ -136,7 +139,8 @@ public class StockholmFileTest
               "Identify routine could not recognise output generated by '"
                       + ioformat + "' writer",
               ioformat.equals(identifyoutput));
-      testAlignmentEquivalence(al, al_input, false);
+      testAlignmentEquivalence(al, al_input, ignoreFeatures,
+              ignoreRowVisibility, allowNullAnnotations);
       int numaliannot = 0, numsqswithali = 0;
       for (AlignmentAnnotation ala : al_input.getAlignmentAnnotation())
       {
index 2714d6c..e8b6c2b 100644 (file)
@@ -177,7 +177,8 @@ public class DisorderAnnotExportImport
                       DataSourceType.PASTE));
 
       // test for consistency in io
-      StockholmFileTest.testAlignmentEquivalence(al, al_new, true);
+      StockholmFileTest.testAlignmentEquivalence(al, al_new, true, false,
+              false);
       return;
     } catch (Exception e)
     {
index d5b6ed1..dc157e2 100644 (file)
@@ -49,6 +49,7 @@ import javax.swing.JMenuItem;
 import org.testng.Assert;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeGroups;
 import org.testng.annotations.Test;
 
 import compbio.metadata.Argument;
@@ -74,7 +75,7 @@ public class JpredJabaStructExportImport
 
   public static jalview.gui.AlignFrame af = null;
 
-  @BeforeClass(alwaysRun = true)
+  @BeforeGroups(groups = { "Network" })
   public static void setUpBeforeClass() throws Exception
   {
     Cache.loadProperties("test/jalview/io/testProps.jvprops");
@@ -106,7 +107,7 @@ public class JpredJabaStructExportImport
     }
   }
 
-  @Test(groups = { "Functional" })
+  @Test(groups = { "Network" }, enabled = false)
   public void testJPredStructOneSeqOnly()
   {
     af.selectAllSequenceMenuItem_actionPerformed(null);
@@ -158,7 +159,7 @@ public class JpredJabaStructExportImport
 
   }
 
-  @Test(groups = { "Functional" })
+  @Test(groups = { "Network" }, enabled = false)
   public void testJPredStructExport()
   {
 
@@ -218,7 +219,8 @@ public class JpredJabaStructExportImport
                       DataSourceType.PASTE));
 
       // test for consistency in io
-      StockholmFileTest.testAlignmentEquivalence(al, al_new, false);
+      StockholmFileTest.testAlignmentEquivalence(al, al_new, false, false,
+              false);
       return;
     } catch (Exception e)
     {
@@ -229,7 +231,7 @@ public class JpredJabaStructExportImport
             + "\nCouldn't complete Annotation file roundtrip input/output/input test.");
   }
 
-  @Test(groups = { "Functional" })
+  @Test(groups = { "Network" }, enabled = false)
   public void testJpredwsSettingsRecovery()
   {
     Assert.fail("not implemnented");
index 4e9741e..5ea97ff 100644 (file)
@@ -242,7 +242,8 @@ public class RNAStructExportImport
                       DataSourceType.PASTE));
 
       // test for consistency in io
-      StockholmFileTest.testAlignmentEquivalence(al, al_new, false);
+      StockholmFileTest.testAlignmentEquivalence(al, al_new, false, false,
+              false);
       return;
     } catch (Exception e)
     {