JAL-1569 revise tests to count number and type of annotation in each file
authorJim Procter <jprocter@dundee.ac.uk>
Sun, 23 Nov 2014 16:32:37 +0000 (16:32 +0000)
committerJim Procter <jprocter@dundee.ac.uk>
Sun, 23 Nov 2014 16:32:37 +0000 (16:32 +0000)
test/jalview/io/StockholmFileTest.java

index 8fece9d..cf61e6e 100644 (file)
@@ -20,6 +20,7 @@
  */
 package jalview.io;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import jalview.datamodel.Alignment;
@@ -45,7 +46,7 @@ public class StockholmFileTest
   @Test
   public void pfamFileIO() throws Exception
   {
-    testFileIOwithFormat(new File(PfamFile), "STH");
+    testFileIOwithFormat(new File(PfamFile), "STH", -1, 0);
   }
 
   @Test
@@ -70,7 +71,7 @@ public class StockholmFileTest
   @Test
   public void rfamFileIO() throws Exception
   {
-    testFileIOwithFormat(new File(RfamFile), "STH");
+    testFileIOwithFormat(new File(RfamFile), "STH", 2, 1);
   }
 
   /**
@@ -83,7 +84,8 @@ public class StockholmFileTest
    *          - label for IO class used to write and read back in the data from
    *          f
    */
-  public static void testFileIOwithFormat(File f, String ioformat)
+  public static void testFileIOwithFormat(File f, String ioformat,
+          int naliannot, int nminseqann)
   {
     System.out.println("Reading file: " + f);
     String ff = f.getPath();
@@ -118,6 +120,28 @@ public class StockholmFileTest
                       + ioformat + "' writer",
               ioformat.equals(identifyoutput));
       testAlignmentEquivalence(al, al_input);
+      int numaliannot = 0, numsqswithali = 0;
+      for (AlignmentAnnotation ala : al_input.getAlignmentAnnotation())
+      {
+        if (ala.sequenceRef == null)
+        {
+          numaliannot++;
+        }
+        else
+        {
+          numsqswithali++;
+        }
+      }
+      if (naliannot > -1)
+      {
+        assertEquals("Number of alignment annotations", naliannot,
+              numaliannot);
+      }
+
+      assertTrue(
+              "Number of sequence associated annotations wasn't at least "
+                      + nminseqann, numsqswithali >= nminseqann);
+
     } catch (Exception e)
     {
       e.printStackTrace();