Clover icon

Coverage Report

  1. Project Clover database Mon Nov 11 2024 15:05:32 GMT
  2. Package jalview.ws.dbsources

File EBIAlphaFoldTest.java

 

Code metrics

0
21
5
1
110
91
7
0.33
4.2
5
1.4

Classes

Class Line # Actions
EBIAlphaFoldTest 25 21 7
0.8846153688.5%
 

Contributing tests

This file is covered by 6 tests. .

Source view

1    package jalview.ws.dbsources;
2   
3    import java.io.File;
4    import java.io.FileInputStream;
5    import java.io.FileNotFoundException;
6    import java.io.IOException;
7   
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;
14   
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;
24   
 
25    public class EBIAlphaFoldTest
26    {
27   
 
28  1 toggle @BeforeClass(alwaysRun = true)
29    public void setUpJvOptionPane()
30    {
31  1 JvOptionPane.setInteractiveMode(false);
32  1 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
33    }
34   
 
35  1 toggle @DataProvider(name = "getExamplePAEfiles")
36    public Object[][] getExamplePAEfiles()
37    {
38  1 return new String[][] {
39    //
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    //
44    };
45    }
46   
 
47  3 toggle @Test(groups = { "Functional" }, dataProvider = "getExamplePAEfiles")
48    public void checkPAEimport(String paeFile) throws Exception
49    {
50  3 PAEContactMatrix cm = new PAEContactMatrix(
51    new Sequence("Dummy/1-2000", "ASDASDA"),
52    EBIAlfaFold.parseJSONtoPAEContactMatrix(
53    new FileInputStream(paeFile)));
54  3 Assert.assertNotEquals(cm.getMax(), 0.0f, "No data from " + paeFile);
55    }
56   
 
57  3 toggle @Test(groups = { "Functional" }, dataProvider = "getPDBandPAEfiles")
58    public void checkImportPAEToStructure(String pdbFile, String paeFile)
59    {
60  3 FileInputStream paeInput = null;
61  3 try
62    {
63  3 paeInput = new FileInputStream(paeFile);
64    } catch (FileNotFoundException e)
65    {
66  0 e.printStackTrace();
67  0 FileAssert.assertFile(new File(paeFile),
68    "Test file '" + paeFile + "' doesn't seem to exist");
69    }
70  3 SequenceI seq = new Sequence("Dummy/1-2000", "ASDASDA");
71  3 AlignmentI al = new Alignment(new SequenceI[] { seq });
72  3 StructureSelectionManager ssm = StructureSelectionManager
73    .getStructureSelectionManager(Desktop.instance);
74  3 StructureMapping sm = new StructureMapping(seq, pdbFile, null, null,
75    null, null);
76  3 ssm.addStructureMapping(sm);
77   
78  3 StructureMapping[] smArray = ssm.getMapping(pdbFile);
79   
80  3 try
81    {
82  3 boolean done = EBIAlfaFold.importPaeJSONAsContactMatrixToStructure(
83    smArray, paeInput, "label");
84  3 Assert.assertTrue(done,
85    "Import of '" + paeFile + "' didn't complete successfully");
86    } catch (IOException | ParseException e)
87    {
88  0 Assert.fail("Exception importing paefile '" + paeFile + "'", e);
89    }
90    }
91   
 
92  1 toggle @DataProvider(name = "getPDBandPAEfiles")
93    public Object[][] getPDBandPAEfiles()
94    {
95  1 return new String[][] {
96    //
97    /*
98    */
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" },
105    /*
106    */
107    };
108    }
109   
110    }