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