From f77eb502a59321b9cc541a561c2b72a6ae1422bc Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Sun, 23 Nov 2014 16:32:37 +0000 Subject: [PATCH] JAL-1569 revise tests to count number and type of annotation in each file --- test/jalview/io/StockholmFileTest.java | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/test/jalview/io/StockholmFileTest.java b/test/jalview/io/StockholmFileTest.java index 8fece9d..cf61e6e 100644 --- a/test/jalview/io/StockholmFileTest.java +++ b/test/jalview/io/StockholmFileTest.java @@ -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(); -- 1.7.10.2