bfd5ca48c57208050e2c93d65a764729a5989c41
[jalview.git] / test / jalview / io / Jalview2xmlBase.java
1 package jalview.io;
2
3 import jalview.bin.Cache;
4 import jalview.datamodel.AlignmentAnnotation;
5 import jalview.datamodel.SequenceI;
6
7 import java.time.Instant;
8 import java.util.Date;
9
10 import org.testng.annotations.AfterClass;
11 import org.testng.annotations.BeforeClass;
12
13 public class Jalview2xmlBase
14 {
15
16   /**
17    * @throws java.lang.Exception
18    */
19   @BeforeClass(alwaysRun = true)
20   public static void setUpBeforeClass() throws Exception
21   {
22     jalview.bin.Jalview.main(new String[] { "-props",
23         "test/jalview/io/testProps.jvprops" });
24     jalview.bin.Cache.setProperty(
25             "JALVIEW_NEWS_RSS_LASTMODIFIED",
26             Cache.date_format.format(Date.from(Instant.now().plusSeconds(
27                     3600))));
28   }
29
30   /**
31    * @throws java.lang.Exception
32    */
33   @AfterClass(alwaysRun = true)
34   public static void tearDownAfterClass() throws Exception
35   {
36     jalview.gui.Desktop.instance.closeAll_actionPerformed(null);
37   }
38
39   public int countDsAnn(jalview.viewmodel.AlignmentViewport avp)
40   {
41     int numdsann = 0;
42     for (SequenceI sq : avp.getAlignment().getDataset().getSequences())
43     {
44       if (sq.getAnnotation() != null)
45       {
46         for (AlignmentAnnotation dssa : sq.getAnnotation())
47         {
48           if (dssa.isValidStruc())
49           {
50             numdsann++;
51           }
52         }
53       }
54     }
55     return numdsann;
56   }
57
58 }