| 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.analysis.AlignmentUtils; |
| 18 |
|
import jalview.bin.Console; |
| 19 |
|
import jalview.datamodel.Alignment; |
| 20 |
|
import jalview.datamodel.AlignmentI; |
| 21 |
|
import jalview.datamodel.Sequence; |
| 22 |
|
import jalview.datamodel.SequenceI; |
| 23 |
|
import jalview.gui.Desktop; |
| 24 |
|
import jalview.gui.JvOptionPane; |
| 25 |
|
import jalview.io.DataSourceType; |
| 26 |
|
import jalview.io.FileLoader; |
| 27 |
|
import jalview.structure.StructureMapping; |
| 28 |
|
import jalview.structure.StructureSelectionManager; |
| 29 |
|
import jalview.ws.datamodel.alphafold.PAEContactMatrix; |
| 30 |
|
|
| |
|
| 64.8% |
Uncovered Elements: 25 (71) |
Complexity: 14 |
Complexity Density: 0.23 |
|
| 31 |
|
public class EBIAlphaFoldTest |
| 32 |
|
{ |
| 33 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 34 |
1 |
@BeforeClass(alwaysRun = true)... |
| 35 |
|
public void setUpJvOptionPane() |
| 36 |
|
{ |
| 37 |
1 |
JvOptionPane.setInteractiveMode(false); |
| 38 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
| 39 |
|
} |
| 40 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 41 |
1 |
@DataProvider(name = "getExamplePAEfiles")... |
| 42 |
|
public Object[][] getExamplePAEfiles() |
| 43 |
|
{ |
| 44 |
1 |
return new String[][] { |
| 45 |
|
|
| 46 |
|
{ "examples/test_fab41.result/test_fab41_predicted_aligned_error_v1.json" }, |
| 47 |
|
{ "examples/AlphaFold/AF-A0A1U8FD60-F1-predicted_aligned_error_v4.json" }, |
| 48 |
|
{ "examples/AlphaFold/AF-Q5VSL9-F1-predicted_aligned_error_v4.json" }, |
| 49 |
|
{"examples/AlphaFold/AF-Q5VSL9-F1-predicted_aligned_error_v4_cmp.json" }, |
| 50 |
|
{"examples/AlphaFold/AF-0000000203848083-predicted_aligned_error_v1.json" }, |
| 51 |
|
|
| 52 |
|
}; |
| 53 |
|
} |
| 54 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
| 55 |
5 |
@Test(groups = { "Functional" }, dataProvider = "getExamplePAEfiles")... |
| 56 |
|
public void checkPAEimport(String paeFile) throws Exception |
| 57 |
|
{ |
| 58 |
5 |
PAEContactMatrix cm = new PAEContactMatrix( |
| 59 |
|
new Sequence("Dummy/1-2000", "ASDASDA"), |
| 60 |
|
EBIAlfaFold.parseJSONtoPAEContactMatrix( |
| 61 |
|
new FileInputStream(paeFile))); |
| 62 |
5 |
Assert.assertNotEquals(cm.getMax(), 0.0f, "No data from " + paeFile); |
| 63 |
|
} |
| 64 |
|
|
| |
|
| 80% |
Uncovered Elements: 3 (15) |
Complexity: 3 |
Complexity Density: 0.2 |
1PASS
|
|
| 65 |
5 |
@Test(groups = { "Functional" }, dataProvider = "getPDBandPAEfiles")... |
| 66 |
|
public void checkImportPAEToStructure(String pdbFile, String paeFile) |
| 67 |
|
{ |
| 68 |
5 |
FileInputStream paeInput = null; |
| 69 |
5 |
try |
| 70 |
|
{ |
| 71 |
5 |
paeInput = new FileInputStream(paeFile); |
| 72 |
|
} catch (FileNotFoundException e) |
| 73 |
|
{ |
| 74 |
0 |
e.printStackTrace(); |
| 75 |
0 |
FileAssert.assertFile(new File(paeFile), |
| 76 |
|
"Test file '" + paeFile + "' doesn't seem to exist"); |
| 77 |
|
} |
| 78 |
5 |
SequenceI seq = new Sequence("Dummy/1-2000", "ASDASDA"); |
| 79 |
5 |
AlignmentI al = new Alignment(new SequenceI[] { seq }); |
| 80 |
5 |
StructureSelectionManager ssm = StructureSelectionManager |
| 81 |
|
.getStructureSelectionManager(Desktop.instance); |
| 82 |
5 |
StructureMapping sm = new StructureMapping(seq, pdbFile, null, null, |
| 83 |
|
null, null); |
| 84 |
5 |
ssm.addStructureMapping(sm); |
| 85 |
|
|
| 86 |
5 |
StructureMapping[] smArray = ssm.getMapping(pdbFile); |
| 87 |
|
|
| 88 |
5 |
try |
| 89 |
|
{ |
| 90 |
5 |
boolean done = EBIAlfaFold.importPaeJSONAsContactMatrixToStructure( |
| 91 |
|
smArray, paeInput, "label"); |
| 92 |
4 |
Assert.assertTrue(done, |
| 93 |
|
"Import of '" + paeFile + "' didn't complete successfully"); |
| 94 |
|
} catch (IOException | ParseException e) |
| 95 |
|
{ |
| 96 |
0 |
Assert.fail("Exception importing paefile '" + paeFile + "'", e); |
| 97 |
|
} |
| 98 |
|
} |
| 99 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 100 |
2 |
@DataProvider(name = "getPDBandPAEfiles")... |
| 101 |
|
public Object[][] getPDBandPAEfiles() |
| 102 |
|
{ |
| 103 |
2 |
return new String[][] { |
| 104 |
|
|
| 105 |
|
|
| 106 |
|
|
| 107 |
|
{ "examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb", |
| 108 |
|
"examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3_scores.json" }, |
| 109 |
|
{ "examples/AlphaFold/AF-A0A1U8FD60-F1-model_v4.pdb", |
| 110 |
|
"examples/AlphaFold/AF-A0A1U8FD60-F1-predicted_aligned_error_v4.json" }, |
| 111 |
|
{ "examples/AlphaFold/AF-Q5VSL9-F1-model_v4.pdb", |
| 112 |
|
"examples/AlphaFold/AF-Q5VSL9-F1-predicted_aligned_error_v4.json" }, |
| 113 |
|
{ "examples/AlphaFold/AF-Q5VSL9-F1-model_v4.pdb", |
| 114 |
|
"examples/AlphaFold/AF-Q5VSL9-F1-predicted_aligned_error_v4_cmp.json" }, |
| 115 |
|
{ "examples/AlphaFold/AF-0000000203848083-model_v1.cif","examples/AlphaFold/AF-0000000203848083-predicted_aligned_error_v1.json" }, |
| 116 |
|
|
| 117 |
|
|
| 118 |
|
}; |
| 119 |
|
} |
| 120 |
|
|
| 121 |
|
|
| 122 |
|
|
| 123 |
|
@param |
| 124 |
|
@param |
| 125 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
| 126 |
5 |
@Test(groups = { "Functional" }, dataProvider = "getPDBandPAEfiles")... |
| 127 |
|
public void checkImportPAEForStructure(String pdbFile, String paeFile) throws Exception |
| 128 |
|
{ |
| 129 |
5 |
doTestImportMsaPaeForStructure(pdbFile, pdbFile, paeFile); |
| 130 |
|
} |
| |
|
| 90.9% |
Uncovered Elements: 2 (22) |
Complexity: 3 |
Complexity Density: 0.15 |
|
| 131 |
5 |
protected void doTestImportMsaPaeForStructure(String alFile, String pdbFile, String paeFile) throws Exception... |
| 132 |
|
{ |
| 133 |
5 |
FileInputStream paeInput = null; |
| 134 |
5 |
try |
| 135 |
|
{ |
| 136 |
5 |
paeInput = new FileInputStream(paeFile); |
| 137 |
|
} catch (FileNotFoundException e) |
| 138 |
|
{ |
| 139 |
0 |
e.printStackTrace(); |
| 140 |
0 |
FileAssert.assertFile(new File(paeFile), |
| 141 |
|
"Test file '" + paeFile + "' doesn't seem to exist"); |
| 142 |
|
} |
| 143 |
5 |
String mp=new File(alFile).getAbsolutePath(); |
| 144 |
5 |
AlignmentI al = new FileLoader().LoadFileWaitTillLoaded(mp, DataSourceType.FILE).getViewport().getAlignment(); |
| 145 |
|
|
| 146 |
5 |
StructureSelectionManager ssm = StructureSelectionManager |
| 147 |
|
.getStructureSelectionManager(Desktop.instance); |
| 148 |
5 |
String[] chainIds = new String[al.getHeight()]; |
| 149 |
5 |
int s=0; |
| 150 |
5 |
for (SequenceI sq:al.getSequences()) |
| 151 |
|
{ |
| 152 |
6 |
chainIds[s++]=sq.getDatasetSequence().getAllPDBEntries().get(0).getChainCode(); |
| 153 |
|
} |
| 154 |
|
|
| 155 |
5 |
if (chainIds.length>1) |
| 156 |
|
{ |
| 157 |
1 |
Console.info("Checking for multimer PAE import"); |
| 158 |
|
} |
| 159 |
|
|
| 160 |
|
|
| 161 |
5 |
ssm.computeMapping(false, al.getSequencesArray(), chainIds, mp, DataSourceType.FILE, null, null, paeFile, true); |
| 162 |
5 |
AlignmentUtils.addAllReferenceAnnotations(al); |
| 163 |
|
|
| 164 |
5 |
for (SequenceI sq:al.getSequences()) { |
| 165 |
6 |
String failed=" no contact map found for "+sq.getName(); |
| 166 |
6 |
Assert.assertTrue(sq.getContactMaps()!=null,failed); |
| 167 |
6 |
Assert.assertEquals(sq.getContactMaps().size(),1,failed); |
| 168 |
|
} |
| 169 |
|
} |
| 170 |
|
|
| |
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 2 |
Complexity Density: 0.12 |
3FAIL
|
|
| 171 |
0 |
@Test(groups= {"Functional"})... |
| 172 |
|
public void testImportPAEAndStructureForMultiChainSeqs() throws Exception |
| 173 |
|
{ |
| 174 |
0 |
String pdbFile="examples/AlphaFold/AF-0000000203848083-model_v1.cif",paeFile="examples/AlphaFold/AF-0000000203848083-predicted_aligned_error_v1.json",faFile="examples/AlphaFold/AF-0000000203848083-uniprot.fa"; |
| 175 |
0 |
FileInputStream paeInput = null; |
| 176 |
0 |
try |
| 177 |
|
{ |
| 178 |
0 |
paeInput = new FileInputStream(paeFile); |
| 179 |
|
} catch (FileNotFoundException e) |
| 180 |
|
{ |
| 181 |
0 |
e.printStackTrace(); |
| 182 |
0 |
FileAssert.assertFile(new File(paeFile), |
| 183 |
|
"Test file '" + paeFile + "' doesn't seem to exist"); |
| 184 |
|
} |
| 185 |
0 |
AlignmentI al = new FileLoader().LoadFileWaitTillLoaded(new File(faFile).getAbsolutePath(), DataSourceType.FILE).getViewport().getAlignment(); |
| 186 |
|
|
| 187 |
0 |
StructureSelectionManager ssm = StructureSelectionManager |
| 188 |
|
.getStructureSelectionManager(Desktop.instance); |
| 189 |
0 |
String[] chainIds = new String[] { "A","B"}; |
| 190 |
|
|
| 191 |
0 |
String mp=new File(pdbFile).getAbsolutePath(); |
| 192 |
|
|
| 193 |
|
|
| 194 |
0 |
ssm.computeMapping(false, al.getSequencesArray(), chainIds, mp, DataSourceType.FILE, null, null, paeFile, true); |
| 195 |
0 |
AlignmentUtils.addAllReferenceAnnotations(al); |
| 196 |
|
|
| 197 |
0 |
for (SequenceI sq:al.getSequences()) { |
| 198 |
0 |
String failed=" no contact map found for "+sq.getName(); |
| 199 |
0 |
Assert.assertTrue(sq.getContactMaps()!=null,failed); |
| 200 |
0 |
Assert.assertEquals(sq.getContactMaps().size(),1,failed); |
| 201 |
|
} |
| 202 |
|
|
| 203 |
|
} |
| 204 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
3FAIL
|
|
| 205 |
0 |
@Test(groups = { "Network" })... |
| 206 |
|
public void testPing() throws Exception |
| 207 |
|
{ |
| 208 |
0 |
String version = EBIAlfaFold.pingAPIVersion(); |
| 209 |
0 |
assertNotEquals("", version); |
| 210 |
|
} |
| 211 |
|
} |