Clover icon

Coverage Report

  1. Project Clover database Fri Jun 19 2026 07:23:26 BST
  2. Package jalview.ws.dbsources

File EBIAlphaFoldTest.java

 
checkImportPAEToStructure: Exception importing paefile 'examples/AlphaFold/AF-Q5VSL9...
 

Code metrics

0
23
6
1
121
101
8
0.35
3.83
6
1.33

Classes

Class Line # Actions
EBIAlphaFoldTest 27 23 8
0.7931034679.3%
 

Contributing tests

This file is covered by 8 tests. .

Source view

1    package jalview.ws.dbsources;
2   
3    import static org.junit.Assert.assertNotEquals;
4   
5    import java.io.File;
6    import java.io.FileInputStream;
7    import java.io.FileNotFoundException;
8    import java.io.IOException;
9   
10    import org.json.simple.parser.ParseException;
11    import org.testng.Assert;
12    import org.testng.FileAssert;
13    import org.testng.annotations.BeforeClass;
14    import org.testng.annotations.DataProvider;
15    import org.testng.annotations.Test;
16   
17    import jalview.datamodel.Alignment;
18    import jalview.datamodel.AlignmentI;
19    import jalview.datamodel.Sequence;
20    import jalview.datamodel.SequenceI;
21    import jalview.gui.Desktop;
22    import jalview.gui.JvOptionPane;
23    import jalview.structure.StructureMapping;
24    import jalview.structure.StructureSelectionManager;
25    import jalview.ws.datamodel.alphafold.PAEContactMatrix;
26   
 
27    public class EBIAlphaFoldTest
28    {
29   
 
30  1 toggle @BeforeClass(alwaysRun = true)
31    public void setUpJvOptionPane()
32    {
33  1 JvOptionPane.setInteractiveMode(false);
34  1 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
35    }
36   
 
37  1 toggle @DataProvider(name = "getExamplePAEfiles")
38    public Object[][] getExamplePAEfiles()
39    {
40  1 return new String[][] {
41    //
42    { "examples/test_fab41.result/test_fab41_predicted_aligned_error_v1.json" },
43    { "examples/AlphaFold/AF-A0A1U8FD60-F1-predicted_aligned_error_v4.json" },
44    { "examples/AlphaFold/AF-Q5VSL9-F1-predicted_aligned_error_v4.json" },
45    {"examples/AlphaFold/AF-Q5VSL9-F1-predicted_aligned_error_v4_cmp.json" },
46    //
47    };
48    }
49   
 
50  4 toggle @Test(groups = { "Functional" }, dataProvider = "getExamplePAEfiles")
51    public void checkPAEimport(String paeFile) throws Exception
52    {
53  4 PAEContactMatrix cm = new PAEContactMatrix(
54    new Sequence("Dummy/1-2000", "ASDASDA"),
55    EBIAlfaFold.parseJSONtoPAEContactMatrix(
56    new FileInputStream(paeFile)));
57  4 Assert.assertNotEquals(cm.getMax(), 0.0f, "No data from " + paeFile);
58    }
59   
 
60  4 toggle @Test(groups = { "Functional" }, dataProvider = "getPDBandPAEfiles")
61    public void checkImportPAEToStructure(String pdbFile, String paeFile)
62    {
63  4 FileInputStream paeInput = null;
64  4 try
65    {
66  4 paeInput = new FileInputStream(paeFile);
67    } catch (FileNotFoundException e)
68    {
69  0 e.printStackTrace();
70  0 FileAssert.assertFile(new File(paeFile),
71    "Test file '" + paeFile + "' doesn't seem to exist");
72    }
73  4 SequenceI seq = new Sequence("Dummy/1-2000", "ASDASDA");
74  4 AlignmentI al = new Alignment(new SequenceI[] { seq });
75  4 StructureSelectionManager ssm = StructureSelectionManager
76    .getStructureSelectionManager(Desktop.instance);
77  4 StructureMapping sm = new StructureMapping(seq, pdbFile, null, null,
78    null, null);
79  4 ssm.addStructureMapping(sm);
80   
81  4 StructureMapping[] smArray = ssm.getMapping(pdbFile);
82   
83  4 try
84    {
85  4 Test failure here boolean done = EBIAlfaFold.importPaeJSONAsContactMatrixToStructure(
86    smArray, paeInput, "label");
87  3 Assert.assertTrue(done,
88    "Import of '" + paeFile + "' didn't complete successfully");
89    } catch (IOException | ParseException e)
90    {
91  0 Test failure here Assert.fail("Exception importing paefile '" + paeFile + "'", e);
92    }
93    }
94   
 
95  1 toggle @DataProvider(name = "getPDBandPAEfiles")
96    public Object[][] getPDBandPAEfiles()
97    {
98  1 return new String[][] {
99    //
100    /*
101    */
102    { "examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb",
103    "examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3_scores.json" },
104    { "examples/AlphaFold/AF-A0A1U8FD60-F1-model_v4.pdb",
105    "examples/AlphaFold/AF-A0A1U8FD60-F1-predicted_aligned_error_v4.json" },
106    { "examples/AlphaFold/AF-Q5VSL9-F1-model_v4.pdb",
107    "examples/AlphaFold/AF-Q5VSL9-F1-predicted_aligned_error_v4.json" },
108    { "examples/AlphaFold/AF-Q5VSL9-F1-model_v4.pdb",
109    "examples/AlphaFold/AF-Q5VSL9-F1-predicted_aligned_error_v4_cmp.json" },
110    /*
111    */
112    };
113    }
114   
 
115  0 toggle @Test(groups = { "Network" })
116    public void testPing() throws Exception
117    {
118  0 String version = EBIAlfaFold.pingAPIVersion();
119  0 assertNotEquals("", version);
120    }
121    }