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.AlignFrame;
20 import jalview.gui.Desktop;
21 import jalview.gui.JvOptionPane;
22 import jalview.structure.StructureMapping;
23 import jalview.structure.StructureSelectionManager;
24 import jalview.ws.datamodel.alphafold.PAEContactMatrix;
26 public class EBIAlphaFoldTest
29 @BeforeClass(alwaysRun = true)
30 public void setUpJvOptionPane()
32 JvOptionPane.setInteractiveMode(false);
33 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
36 @DataProvider(name = "getExamplePAEfiles")
37 public Object[][] getExamplePAEfiles()
39 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" },
43 { "examples/AlphaFold/AF-Q5VSL9-F1-predicted_aligned_error_v4_2023.json" } };
46 @Test(groups = { "Functional" }, dataProvider = "getExamplePAEfiles")
47 public void checkPAEimport(String paeFile) throws Exception
49 PAEContactMatrix cm = new PAEContactMatrix(
50 new Sequence("Dummy/1-2000", "ASDASDA"),
51 EBIAlfaFold.parseJSONtoPAEContactMatrix(
52 new FileInputStream(paeFile)));
53 Assert.assertNotEquals(cm.getMax(), 0.0f, "No data from " + paeFile);
56 @Test(groups = { "Functional" }, dataProvider = "getPDBandPAEfiles")
57 public void checkImportPAEToStructure(String pdbFile, String paeFile)
59 FileInputStream paeInput = null;
62 paeInput = new FileInputStream(paeFile);
63 } catch (FileNotFoundException e)
66 FileAssert.assertFile(new File(paeFile),
67 "Test file '" + paeFile + "' doesn't seem to exist");
69 SequenceI seq = new Sequence("Dummy/1-2000",
70 "ASDASDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
71 AlignmentI al = new Alignment(new SequenceI[] { seq });
72 AlignFrame af = new AlignFrame(al, seq.getLength(), 1);
73 StructureSelectionManager ssm = StructureSelectionManager
74 .getStructureSelectionManager(Desktop.instance);
75 StructureMapping sm = new StructureMapping(seq, pdbFile, null, null,
77 ssm.addStructureMapping(sm);
79 StructureMapping[] smArray = ssm.getMapping(pdbFile);
83 boolean done = EBIAlfaFold.importPaeJSONAsContactMatrixToStructure(
84 smArray, paeInput, "label");
85 Assert.assertTrue(done,
86 "Import of '" + paeFile + "' didn't complete successfully");
87 } catch (IOException | ParseException e)
93 @DataProvider(name = "getPDBandPAEfiles")
94 public Object[][] getPDBandPAEfiles()
96 return new String[][] {
100 { "examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb",
101 "examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3_scores.json" },
103 { "examples/AlphaFold/AF-A0A1U8FD60-F1-model_v4.pdb",
104 "examples/AlphaFold/AF-A0A1U8FD60-F1-predicted_aligned_error_v4.json" },
105 { "examples/AlphaFold/AF-Q5VSL9-F1-model_v4.pdb",
106 "examples/AlphaFold/AF-Q5VSL9-F1-predicted_aligned_error_v4.json" },
107 { "examples/AlphaFold/AF-Q5VSL9-F1-model_v4.pdb",
108 "examples/AlphaFold/AF-Q5VSL9-F1-predicted_aligned_error_v4_2023.json" },