1 package jalview.ws.dbsources;
4 import java.io.FileInputStream;
5 import java.io.FileNotFoundException;
6 import java.io.IOException;
8 import org.json.simple.parser.ParseException;
9 import org.testng.Assert;
10 import org.testng.FileAssert;
11 import org.testng.annotations.BeforeClass;
12 import org.testng.annotations.DataProvider;
13 import org.testng.annotations.Test;
15 import jalview.datamodel.Alignment;
16 import jalview.datamodel.AlignmentI;
17 import jalview.datamodel.Sequence;
18 import jalview.datamodel.SequenceI;
19 import jalview.gui.Desktop;
20 import jalview.gui.JvOptionPane;
21 import jalview.structure.StructureMapping;
22 import jalview.structure.StructureSelectionManager;
23 import jalview.ws.datamodel.alphafold.PAEContactMatrix;
25 public class EBIAlphaFoldTest
28 @BeforeClass(alwaysRun = true)
29 public void setUpJvOptionPane()
31 JvOptionPane.setInteractiveMode(false);
32 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
35 @DataProvider(name = "getExamplePAEfiles")
36 public Object[][] getExamplePAEfiles()
38 return new String[][] {
40 { "examples/test_fab41.result/test_fab41_predicted_aligned_error_v1.json" },
41 { "examples/AlphaFold/AF-A0A1U8FD60-F1-predicted_aligned_error_v4.json" },
42 { "examples/AlphaFold/AF-Q5VSL9-F1-predicted_aligned_error_v4.json" },
47 @Test(groups = { "Functional" }, dataProvider = "getExamplePAEfiles")
48 public void checkPAEimport(String paeFile) throws Exception
50 PAEContactMatrix cm = new PAEContactMatrix(
51 new Sequence("Dummy/1-2000", "ASDASDA"),
52 EBIAlfaFold.parseJSONtoPAEContactMatrix(
53 new FileInputStream(paeFile)));
54 Assert.assertNotEquals(cm.getMax(), 0.0f, "No data from " + paeFile);
57 @Test(groups = { "Functional" }, dataProvider = "getPDBandPAEfiles")
58 public void checkImportPAEToStructure(String pdbFile, String paeFile)
60 FileInputStream paeInput = null;
63 paeInput = new FileInputStream(paeFile);
64 } catch (FileNotFoundException e)
67 FileAssert.assertFile(new File(paeFile),
68 "Test file '" + paeFile + "' doesn't seem to exist");
70 SequenceI seq = new Sequence("Dummy/1-2000", "ASDASDA");
71 AlignmentI al = new Alignment(new SequenceI[] { seq });
72 StructureSelectionManager ssm = StructureSelectionManager
73 .getStructureSelectionManager(Desktop.instance);
74 StructureMapping sm = new StructureMapping(seq, pdbFile, null, null,
76 ssm.addStructureMapping(sm);
78 StructureMapping[] smArray = ssm.getMapping(pdbFile);
82 boolean done = EBIAlfaFold.importPaeJSONAsContactMatrixToStructure(
83 smArray, paeInput, "label");
84 Assert.assertTrue(done,
85 "Import of '" + paeFile + "' didn't complete successfully");
86 } catch (IOException | ParseException e)
88 Assert.fail("Exception importing paefile '" + paeFile + "'", e);
92 @DataProvider(name = "getPDBandPAEfiles")
93 public Object[][] getPDBandPAEfiles()
95 return new String[][] {
99 { "examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb",
100 "examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3_scores.json" },
101 { "examples/AlphaFold/AF-A0A1U8FD60-F1-model_v4.pdb",
102 "examples/AlphaFold/AF-A0A1U8FD60-F1-predicted_aligned_error_v4.json" },
103 { "examples/AlphaFold/AF-Q5VSL9-F1-model_v4.pdb",
104 "examples/AlphaFold/AF-Q5VSL9-F1-predicted_aligned_error_v4.json" },