Merge branch 'develop' into features/JAL-2094_colourInterface
[jalview.git] / test / jalview / io / Jalview2xmlBase.java
1 package jalview.io;
2
3 import jalview.bin.Cache;
4 import jalview.bin.Jalview;
5 import jalview.datamodel.AlignmentAnnotation;
6 import jalview.datamodel.SequenceI;
7 import jalview.gui.Desktop;
8
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     /*
25      * use read-only test properties file
26      */
27     Cache.loadProperties("test/jalview/io/testProps.jvprops");
28
29     /*
30      * set news feed last read to a future time to ensure no
31      * 'unread' news item is displayed
32      */
33     Date oneHourFromNow = new Date(System.currentTimeMillis() + 3600 * 1000);
34     Cache.setDateProperty("JALVIEW_NEWS_RSS_LASTMODIFIED", oneHourFromNow);
35
36     Jalview.main(new String[] {});
37   }
38
39   /**
40    * @throws java.lang.Exception
41    */
42   @AfterClass(alwaysRun = true)
43   public static void tearDownAfterClass() throws Exception
44   {
45     jalview.gui.Desktop.instance.closeAll_actionPerformed(null);
46   }
47
48   @BeforeTest(alwaysRun = true)
49   public static void clearDesktop()
50   {
51     if (Desktop.instance != null && Desktop.getAlignFrames() != null)
52     {
53       Desktop.instance.closeAll_actionPerformed(null);
54     }
55   }
56
57   public int countDsAnn(jalview.viewmodel.AlignmentViewport avp)
58   {
59     int numdsann = 0;
60     for (SequenceI sq : avp.getAlignment().getDataset().getSequences())
61     {
62       if (sq.getAnnotation() != null)
63       {
64         for (AlignmentAnnotation dssa : sq.getAnnotation())
65         {
66           if (dssa.isValidStruc())
67           {
68             numdsann++;
69           }
70         }
71       }
72     }
73     return numdsann;
74   }
75
76 }