| 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 |
|
|
| |
|
| 79.3% |
Uncovered Elements: 6 (29) |
Complexity: 8 |
Complexity Density: 0.35 |
|
| 27 |
|
public class EBIAlphaFoldTest |
| 28 |
|
{ |
| 29 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 30 |
1 |
@BeforeClass(alwaysRun = true)... |
| 31 |
|
public void setUpJvOptionPane() |
| 32 |
|
{ |
| 33 |
1 |
JvOptionPane.setInteractiveMode(false); |
| 34 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
| 35 |
|
} |
| 36 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 37 |
1 |
@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 |
|
|
| 46 |
|
}; |
| 47 |
|
} |
| 48 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
| 49 |
3 |
@Test(groups = { "Functional" }, dataProvider = "getExamplePAEfiles")... |
| 50 |
|
public void checkPAEimport(String paeFile) throws Exception |
| 51 |
|
{ |
| 52 |
3 |
PAEContactMatrix cm = new PAEContactMatrix( |
| 53 |
|
new Sequence("Dummy/1-2000", "ASDASDA"), |
| 54 |
|
EBIAlfaFold.parseJSONtoPAEContactMatrix( |
| 55 |
|
new FileInputStream(paeFile))); |
| 56 |
3 |
Assert.assertNotEquals(cm.getMax(), 0.0f, "No data from " + paeFile); |
| 57 |
|
} |
| 58 |
|
|
| |
|
| 80% |
Uncovered Elements: 3 (15) |
Complexity: 3 |
Complexity Density: 0.2 |
1PASS
|
|
| 59 |
3 |
@Test(groups = { "Functional" }, dataProvider = "getPDBandPAEfiles")... |
| 60 |
|
public void checkImportPAEToStructure(String pdbFile, String paeFile) |
| 61 |
|
{ |
| 62 |
3 |
FileInputStream paeInput = null; |
| 63 |
3 |
try |
| 64 |
|
{ |
| 65 |
3 |
paeInput = new FileInputStream(paeFile); |
| 66 |
|
} catch (FileNotFoundException e) |
| 67 |
|
{ |
| 68 |
0 |
e.printStackTrace(); |
| 69 |
0 |
FileAssert.assertFile(new File(paeFile), |
| 70 |
|
"Test file '" + paeFile + "' doesn't seem to exist"); |
| 71 |
|
} |
| 72 |
3 |
SequenceI seq = new Sequence("Dummy/1-2000", "ASDASDA"); |
| 73 |
3 |
AlignmentI al = new Alignment(new SequenceI[] { seq }); |
| 74 |
3 |
StructureSelectionManager ssm = StructureSelectionManager |
| 75 |
|
.getStructureSelectionManager(Desktop.getInstance()); |
| 76 |
3 |
StructureMapping sm = new StructureMapping(seq, pdbFile, null, null, |
| 77 |
|
null, null); |
| 78 |
3 |
ssm.addStructureMapping(sm); |
| 79 |
|
|
| 80 |
3 |
StructureMapping[] smArray = ssm.getMapping(pdbFile); |
| 81 |
|
|
| 82 |
3 |
try |
| 83 |
|
{ |
| 84 |
3 |
boolean done = EBIAlfaFold.importPaeJSONAsContactMatrixToStructure( |
| 85 |
|
smArray, paeInput, "label"); |
| 86 |
3 |
Assert.assertTrue(done, |
| 87 |
|
"Import of '" + paeFile + "' didn't complete successfully"); |
| 88 |
|
} catch (IOException | ParseException e) |
| 89 |
|
{ |
| 90 |
0 |
Assert.fail("Exception importing paefile '" + paeFile + "'", e); |
| 91 |
|
} |
| 92 |
|
} |
| 93 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 94 |
1 |
@DataProvider(name = "getPDBandPAEfiles")... |
| 95 |
|
public Object[][] getPDBandPAEfiles() |
| 96 |
|
{ |
| 97 |
1 |
return new String[][] { |
| 98 |
|
|
| 99 |
|
|
| 100 |
|
|
| 101 |
|
{ "examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb", |
| 102 |
|
"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 |
|
|
| 108 |
|
|
| 109 |
|
}; |
| 110 |
|
} |
| 111 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
| 112 |
0 |
@Test(groups = { "Network" })... |
| 113 |
|
public void testPing() throws Exception |
| 114 |
|
{ |
| 115 |
0 |
String version = EBIAlfaFold.pingAPIVersion(); |
| 116 |
0 |
assertNotEquals("", version); |
| 117 |
|
} |
| 118 |
|
} |