JAL-2136 update merged code for JAL-2040 for new FileFormat/Protocol interface (JAL...
[jalview.git] / test / jalview / io / ImportHomologyModelTest.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3
10  * of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
19  * The Jalview Authors are detailed in the 'AUTHORS' file.
20  */
21 package jalview.io;
22
23 import jalview.bin.Cache;
24 import jalview.datamodel.AlignmentI;
25 import jalview.datamodel.PDBEntry;
26 import jalview.datamodel.SequenceI;
27 import jalview.gui.AlignFrame;
28 import jalview.gui.Desktop;
29
30 import org.junit.Assert;
31 import org.testng.annotations.AfterClass;
32 import org.testng.annotations.BeforeClass;
33 import org.testng.annotations.BeforeMethod;
34 import org.testng.annotations.Test;
35
36 public class ImportHomologyModelTest
37 {
38
39   public static String base = "examples/testdata/phyre2/";
40
41   public static String profile_msa = base + "query.jal",
42           profile_annot = base + "query.jal.ann";
43
44   public static String templaten[] = new String[] { "c1o1nA_", "c3pt8B_",
45       "d1scta_" };
46
47   AlignmentI al;
48   AlignFrame af;
49
50   /**
51    * Ensure 'process secondary structure from PDB and add annotations' are set
52    * in preferences, and load PDB example file 1gaq
53    * 
54    * @throws Exception
55    */
56   @BeforeMethod(alwaysRun = true)
57   public void setup() throws Exception
58   {
59     Cache.applicationProperties.setProperty("STRUCT_FROM_PDB",
60             Boolean.TRUE.toString());
61     Cache.applicationProperties.setProperty("ADD_SS_ANN",
62             Boolean.TRUE.toString());
63     FileLoader loader = new FileLoader(false);
64     af = loader.LoadFileWaitTillLoaded(profile_msa,
65             jalview.io.DataSourceType.FILE);
66     Desktop.addInternalFrame(af, "homology models", 800, 500);
67     al = af.getViewport().getAlignment();
68     af.loadJalviewDataFile(profile_annot, jalview.io.DataSourceType.FILE,
69             null, null);
70     // if file was loaded, the view should have a reference sequence set
71     Assert.assertTrue(al.hasSeqrep());
72   }
73
74
75   @Test(groups = { "Functional" })
76   public void testModelsAssociated()
77   {
78     for (String template : templaten)
79     {
80       SequenceI templseq = al.findName(template);
81       Assert.assertNotNull("Couldn't find template sequence for "
82               + template, templseq);
83       PDBEntry querymdl = al.getSeqrep().getPDBEntry(template);
84       PDBEntry templmdl = templseq.getPDBEntry(template);
85       Assert.assertEquals(querymdl.getFile(), templmdl.getFile());
86     }
87   }
88
89   /**
90    * @throws java.lang.Exception
91    */
92   @BeforeClass(alwaysRun = true)
93   public static void setUpBeforeClass() throws Exception
94   {
95     jalview.bin.Jalview.main(new String[] { "-props",
96         "test/jalview/io/testProps.jvprops" });
97   }
98
99   /**
100    * @throws java.lang.Exception
101    */
102   @AfterClass(alwaysRun = true)
103   public static void tearDownAfterClass() throws Exception
104   {
105     jalview.gui.Desktop.instance.closeAll_actionPerformed(null);
106   }
107
108
109 }