| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.gui; |
| 22 |
|
|
| 23 |
|
import static org.testng.Assert.assertEquals; |
| 24 |
|
import static org.testng.Assert.fail; |
| 25 |
|
import static org.testng.AssertJUnit.assertNotNull; |
| 26 |
|
import static org.testng.AssertJUnit.assertTrue; |
| 27 |
|
|
| 28 |
|
import java.io.File; |
| 29 |
|
import java.io.IOException; |
| 30 |
|
import java.util.Collection; |
| 31 |
|
import java.util.List; |
| 32 |
|
import java.util.Vector; |
| 33 |
|
|
| 34 |
|
import org.junit.Assert; |
| 35 |
|
import org.testng.annotations.AfterMethod; |
| 36 |
|
import org.testng.annotations.BeforeClass; |
| 37 |
|
import org.testng.annotations.BeforeMethod; |
| 38 |
|
import org.testng.annotations.DataProvider; |
| 39 |
|
import org.testng.annotations.Test; |
| 40 |
|
|
| 41 |
|
import jalview.api.AlignViewportI; |
| 42 |
|
import jalview.bin.Cache; |
| 43 |
|
import jalview.bin.Jalview; |
| 44 |
|
import jalview.datamodel.AlignmentAnnotation; |
| 45 |
|
import jalview.datamodel.AlignmentI; |
| 46 |
|
import jalview.datamodel.DBRefEntry; |
| 47 |
|
import jalview.datamodel.PDBEntry; |
| 48 |
|
import jalview.datamodel.Sequence; |
| 49 |
|
import jalview.datamodel.SequenceI; |
| 50 |
|
import jalview.fts.api.FTSData; |
| 51 |
|
import jalview.fts.core.FTSRestClient; |
| 52 |
|
import jalview.fts.service.pdb.PDBFTSRestClient; |
| 53 |
|
import jalview.fts.service.pdb.PDBFTSRestClientTest; |
| 54 |
|
import jalview.fts.service.threedbeacons.TDBeaconsFTSRestClient; |
| 55 |
|
import jalview.fts.threedbeacons.TDBeaconsFTSRestClientTest; |
| 56 |
|
import jalview.gui.StructureViewer.ViewerType; |
| 57 |
|
import jalview.gui.structurechooser.PDBStructureChooserQuerySource; |
| 58 |
|
import jalview.io.DataSourceType; |
| 59 |
|
import jalview.io.FileFormatException; |
| 60 |
|
import jalview.io.FileFormatI; |
| 61 |
|
import jalview.io.FileLoader; |
| 62 |
|
import jalview.io.IdentifyFile; |
| 63 |
|
import jalview.jbgui.FilterOption; |
| 64 |
|
import jalview.structure.StructureImportSettings.TFType; |
| 65 |
|
import jalview.structure.StructureMapping; |
| 66 |
|
import jalview.structure.StructureSelectionManager; |
| 67 |
|
import junit.extensions.PA; |
| 68 |
|
|
| 69 |
|
@Test(singleThreaded = true) |
| |
|
| 70.1% |
Uncovered Elements: 67 (224) |
Complexity: 38 |
Complexity Density: 0.21 |
|
| 70 |
|
public class StructureChooserTest |
| 71 |
|
{ |
| 72 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 73 |
1 |
@BeforeClass(alwaysRun = true)... |
| 74 |
|
public void setUpJvOptionPane() |
| 75 |
|
{ |
| 76 |
1 |
JvOptionPane.setInteractiveMode(false); |
| 77 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
| 78 |
|
} |
| 79 |
|
|
| 80 |
|
Sequence seq, upSeq, upSeq_nocanonical; |
| 81 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 2 |
Complexity Density: 0.11 |
|
| 82 |
12 |
@BeforeMethod(alwaysRun = true)... |
| 83 |
|
public void setUp() throws Exception |
| 84 |
|
{ |
| 85 |
12 |
seq = new Sequence("PDB|4kqy|4KQY|A", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 1, |
| 86 |
|
26); |
| 87 |
12 |
seq.createDatasetSequence(); |
| 88 |
60 |
for (int x = 1; x < 5; x++) |
| 89 |
|
{ |
| 90 |
48 |
DBRefEntry dbRef = new DBRefEntry(); |
| 91 |
48 |
dbRef.setAccessionId("XYZ_" + x); |
| 92 |
48 |
seq.addDBRef(dbRef); |
| 93 |
|
} |
| 94 |
|
|
| 95 |
12 |
PDBEntry dbRef = new PDBEntry(); |
| 96 |
12 |
dbRef.setId("1tim"); |
| 97 |
|
|
| 98 |
12 |
Vector<PDBEntry> pdbIds = new Vector<>(); |
| 99 |
12 |
pdbIds.add(dbRef); |
| 100 |
|
|
| 101 |
12 |
seq.setPDBId(pdbIds); |
| 102 |
|
|
| 103 |
|
|
| 104 |
12 |
upSeq = new Sequence("P38398", |
| 105 |
|
"MDLSALRVEEVQNVINAMQKILECPICLELIKEPVSTKCDHIFCKFCMLKLLNQKKGPSQCPLCKNDITKRS\n" |
| 106 |
|
+ "LQESTRFSQLVEELLKIICAFQLDTGLEYANSYNFAKKENNSPEHLKDEVSIIQSMGYRNRAKRLLQSEPEN\n" |
| 107 |
|
+ "PSLQETSLSVQLSNLGTVRTLRTKQRIQPQKTSVYIELGSDSSEDTVNKATYCSVGDQELLQITPQGTRDEI\n" |
| 108 |
|
+ "SLDSAKKAACEFSETDVTNTEHHQPSNNDLNTTEKRAAERHPEKYQGSSVSNLHVEPCGTNTHASSLQHENS\n" |
| 109 |
|
+ "SLLLTKDRMNVEKAEFCNKSKQPGLARSQHNRWAGSKETCNDRRTPSTEKKVDLNADPLCERKEWNKQKLPC\n" |
| 110 |
|
+ "SENPRDTEDVPWITLNSSIQKVNEWFSRSDELLGSDDSHDGESESNAKVADVLDVLNEVDEYSGSSEKIDLL\n" |
| 111 |
|
+ "ASDPHEALICKSERVHSKSVESNIEDKIFGKTYRKKASLPNLSHVTENLIIGAFVTEPQIIQERPLTNKLKR\n" |
| 112 |
|
+ "KRRPTSGLHPEDFIKKADLAVQKTPEMINQGTNQTEQNGQVMNITNSGHENKTKGDSIQNEKNPNPIESLEK\n" |
| 113 |
|
+ "ESAFKTKAEPISSSISNMELELNIHNSKAPKKNRLRRKSSTRHIHALELVVSRNLSPPNCTELQIDSCSSSE\n" |
| 114 |
|
+ "EIKKKKYNQMPVRHSRNLQLMEGKEPATGAKKSNKPNEQTSKRHDSDTFPELKLTNAPGSFTKCSNTSELKE\n" |
| 115 |
|
+ "FVNPSLPREEKEEKLETVKVSNNAEDPKDLMLSGERVLQTERSVESSSISLVPGTDYGTQESISLLEVSTLG\n" |
| 116 |
|
+ "KAKTEPNKCVSQCAAFENPKGLIHGCSKDNRNDTEGFKYPLGHEVNHSRETSIEMEESELDAQYLQNTFKVS\n" |
| 117 |
|
+ "KRQSFAPFSNPGNAEEECATFSAHSGSLKKQSPKVTFECEQKEENQGKNESNIKPVQTVNITAGFPVVGQKD\n" |
| 118 |
|
+ "KPVDNAKCSIKGGSRFCLSSQFRGNETGLITPNKHGLLQNPYRIPPLFPIKSFVKTKCKKNLLEENFEEHSM\n" |
| 119 |
|
+ "SPEREMGNENIPSTVSTISRNNIRENVFKEASSSNINEVGSSTNEVGSSINEIGSSDENIQAELGRNRGPKL\n" |
| 120 |
|
+ "NAMLRLGVLQPEVYKQSLPGSNCKHPEIKKQEYEEVVQTVNTDFSPYLISDNLEQPMGSSHASQVCSETPDD\n" |
| 121 |
|
+ "LLDDGEIKEDTSFAENDIKESSAVFSKSVQKGELSRSPSPFTHTHLAQGYRRGAKKLESSEENLSSEDEELP\n" |
| 122 |
|
+ "CFQHLLFGKVNNIPSQSTRHSTVATECLSKNTEENLLSLKNSLNDCSNQVILAKASQEHHLSEETKCSASLF\n" |
| 123 |
|
+ "SSQCSELEDLTANTNTQDPFLIGSSKQMRHQSESQGVGLSDKELVSDDEERGTGLEENNQEEQSMDSNLGEA\n" |
| 124 |
|
+ "ASGCESETSVSEDCSGLSSQSDILTTQQRDTMQHNLIKLQQEMAELEAVLEQHGSQPSNSYPSIISDSSALE\n" |
| 125 |
|
+ "DLRNPEQSTSEKAVLTSQKSSEYPISQNPEGLSADKFEVSADSSTSKNKEPGVERSSPSKCPSLDDRWYMHS\n" |
| 126 |
|
+ "CSGSLQNRNYPSQEELIKVVDVEEQQLEESGPHDLTETSYLPRQDLEGTPYLESGISLFSDDPESDPSEDRA\n" |
| 127 |
|
+ "PESARVGNIPSSTSALKVPQLKVAESAQSPAAAHTTDTAGYNAMEESVSREKPELTASTERVNKRMSMVVSG\n" |
| 128 |
|
+ "LTPEEFMLVYKFARKHHITLTNLITEETTHVVMKTDAEFVCERTLKYFLGIAGGKWVVSYFWVTQSIKERKM\n" |
| 129 |
|
+ "LNEHDFEVRGDVVNGRNHQGPKRARESQDRKIFRGLEICCYGPFTNMPTDQLEWMVQLCGASVVKELSSFTL\n" |
| 130 |
|
+ "GTGVHPIVVVQPDAWTEDNGFHAIGQMCEAPVVTREWVLDSVALYQCQELDTYLIPQIPHSHY\n" |
| 131 |
|
+ "", |
| 132 |
|
1, 1863); |
| 133 |
12 |
upSeq.setDescription("Breast cancer type 1 susceptibility protein"); |
| 134 |
12 |
upSeq_nocanonical = new Sequence(upSeq); |
| 135 |
12 |
upSeq.createDatasetSequence(); |
| 136 |
12 |
upSeq.addDBRef(new DBRefEntry("UNIPROT", "0", "P38398", null, true)); |
| 137 |
|
|
| 138 |
12 |
upSeq_nocanonical.createDatasetSequence(); |
| 139 |
|
|
| 140 |
12 |
upSeq_nocanonical.addDBRef(new DBRefEntry("UNIPROT","0","P38398",null,false)); |
| 141 |
|
} |
| 142 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 143 |
12 |
@AfterMethod(alwaysRun = true)... |
| 144 |
|
public void tearDown() throws Exception |
| 145 |
|
{ |
| 146 |
12 |
seq = null; |
| 147 |
12 |
upSeq = null; |
| 148 |
12 |
upSeq_nocanonical = null; |
| 149 |
|
} |
| 150 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (23) |
Complexity: 2 |
Complexity Density: 0.1 |
1PASS
|
|
| 151 |
1 |
@Test(groups = { "Functional" })... |
| 152 |
|
public void populateFilterComboBoxTest() throws InterruptedException |
| 153 |
|
{ |
| 154 |
1 |
TDBeaconsFTSRestClientTest.setMock(); |
| 155 |
1 |
PDBFTSRestClientTest.setMock(); |
| 156 |
|
|
| 157 |
1 |
SequenceI[] selectedSeqs = new SequenceI[] { seq }; |
| 158 |
1 |
StructureChooser sc = new StructureChooser(selectedSeqs, seq, null); |
| 159 |
1 |
ThreadwaitFor(200, sc); |
| 160 |
|
|
| 161 |
|
|
| 162 |
|
|
| 163 |
1 |
sc.populateFilterComboBox(false, false); |
| 164 |
1 |
int optionsSize = sc.getCmbFilterOption().getItemCount(); |
| 165 |
1 |
System.out.println("Items (no data, no cache): "); |
| 166 |
1 |
StringBuilder items = new StringBuilder(); |
| 167 |
3 |
for (int p = 0; p < optionsSize; p++) |
| 168 |
|
{ |
| 169 |
2 |
items.append("- ") |
| 170 |
|
.append(sc.getCmbFilterOption().getItemAt(p).getName()) |
| 171 |
|
.append("\n"); |
| 172 |
|
|
| 173 |
|
} |
| 174 |
|
|
| 175 |
1 |
Assert.assertEquals(items.toString(), optionsSize, 2); |
| 176 |
|
|
| 177 |
1 |
sc.populateFilterComboBox(true, false); |
| 178 |
1 |
optionsSize = sc.getCmbFilterOption().getItemCount(); |
| 179 |
1 |
assertTrue(optionsSize > 3); |
| 180 |
|
|
| 181 |
|
|
| 182 |
1 |
sc.populateFilterComboBox(true, true); |
| 183 |
1 |
assertTrue(sc.getCmbFilterOption().getSelectedItem() != null); |
| 184 |
1 |
FilterOption filterOpt = (FilterOption) sc.getCmbFilterOption() |
| 185 |
|
.getSelectedItem(); |
| 186 |
1 |
assertEquals("Cached Structures", filterOpt.getName()); |
| 187 |
1 |
FTSRestClient |
| 188 |
|
.unMock((FTSRestClient) TDBeaconsFTSRestClient.getInstance()); |
| 189 |
1 |
FTSRestClient.unMock((FTSRestClient) PDBFTSRestClient.getInstance()); |
| 190 |
|
|
| 191 |
|
} |
| 192 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
| 193 |
1 |
@Test(groups = { "Functional" })... |
| 194 |
|
public void displayTDBQueryTest() throws InterruptedException |
| 195 |
|
{ |
| 196 |
1 |
TDBeaconsFTSRestClientTest.setMock(); |
| 197 |
1 |
PDBFTSRestClientTest.setMock(); |
| 198 |
|
|
| 199 |
1 |
SequenceI[] selectedSeqs = new SequenceI[] { upSeq_nocanonical }; |
| 200 |
1 |
StructureChooser sc = new StructureChooser(selectedSeqs, |
| 201 |
|
upSeq_nocanonical, null); |
| 202 |
|
|
| 203 |
1 |
ThreadwaitFor(500, sc); |
| 204 |
|
|
| 205 |
1 |
assertTrue(sc.isCanQueryTDB() && sc.isNotQueriedTDBYet()); |
| 206 |
|
} |
| 207 |
|
|
| |
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
| 208 |
0 |
@Test(groups = { "Network" })... |
| 209 |
|
public void fetchStructuresInfoTest() |
| 210 |
|
{ |
| 211 |
0 |
FTSRestClient |
| 212 |
|
.unMock((FTSRestClient) TDBeaconsFTSRestClient.getInstance()); |
| 213 |
0 |
PDBFTSRestClient.unMock((FTSRestClient) PDBFTSRestClient.getInstance()); |
| 214 |
0 |
SequenceI[] selectedSeqs = new SequenceI[] { seq }; |
| 215 |
0 |
StructureChooser sc = new StructureChooser(selectedSeqs, seq, null); |
| 216 |
|
|
| 217 |
0 |
ThreadwaitFor(2000, sc); |
| 218 |
|
|
| 219 |
0 |
sc.fetchStructuresMetaData(); |
| 220 |
0 |
Collection<FTSData> ss = (Collection<FTSData>) PA.getValue(sc, |
| 221 |
|
"discoveredStructuresSet"); |
| 222 |
0 |
assertNotNull(ss); |
| 223 |
0 |
assertTrue(ss.size() > 0); |
| 224 |
|
} |
| 225 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
| 226 |
1 |
@Test(groups = { "Functional" })... |
| 227 |
|
public void fetchStructuresInfoMockedTest() |
| 228 |
|
{ |
| 229 |
1 |
TDBeaconsFTSRestClientTest.setMock(); |
| 230 |
1 |
PDBFTSRestClientTest.setMock(); |
| 231 |
1 |
SequenceI[] selectedSeqs = new SequenceI[] { upSeq }; |
| 232 |
1 |
StructureChooser sc = new StructureChooser(selectedSeqs, seq, null); |
| 233 |
1 |
ThreadwaitFor(500, sc); |
| 234 |
|
|
| 235 |
1 |
sc.fetchStructuresMetaData(); |
| 236 |
1 |
Collection<FTSData> ss = (Collection<FTSData>) PA.getValue(sc, |
| 237 |
|
"discoveredStructuresSet"); |
| 238 |
1 |
assertNotNull(ss); |
| 239 |
1 |
assertTrue(ss.size() > 0); |
| 240 |
|
} |
| 241 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 4 |
Complexity Density: 1 |
|
| 242 |
3 |
private void ThreadwaitFor(int i, StructureChooser sc)... |
| 243 |
|
{ |
| 244 |
3 |
long timeout = i + System.currentTimeMillis(); |
| 245 |
12 |
while (!sc.isDialogVisible() && timeout > System.currentTimeMillis()) |
| 246 |
|
{ |
| 247 |
9 |
try |
| 248 |
|
{ |
| 249 |
9 |
Thread.sleep(50); |
| 250 |
|
} catch (InterruptedException x) |
| 251 |
|
{ |
| 252 |
|
|
| 253 |
|
} |
| 254 |
|
} |
| 255 |
|
} |
| |
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
| 256 |
1 |
@Test(groups = { "Functional" })... |
| 257 |
|
public void sanitizeSeqNameTest() |
| 258 |
|
{ |
| 259 |
1 |
String name = "ab_cdEF|fwxyz012349"; |
| 260 |
1 |
assertEquals(name, |
| 261 |
|
PDBStructureChooserQuerySource.sanitizeSeqName(name)); |
| 262 |
|
|
| 263 |
|
|
| 264 |
1 |
name = "abcde12[345]fg"; |
| 265 |
1 |
assertEquals("abcde12fg", |
| 266 |
|
PDBStructureChooserQuerySource.sanitizeSeqName(name)); |
| 267 |
|
|
| 268 |
|
|
| 269 |
1 |
name = "ab[cd],.\t£$*!- \\\"@:e"; |
| 270 |
1 |
assertEquals("abcde", |
| 271 |
|
PDBStructureChooserQuerySource.sanitizeSeqName(name)); |
| 272 |
|
|
| 273 |
1 |
name = "abcde12[345a]fg"; |
| 274 |
1 |
assertEquals("abcde12345afg", |
| 275 |
|
PDBStructureChooserQuerySource.sanitizeSeqName(name)); |
| 276 |
|
} |
| 277 |
|
|
| |
|
| 75% |
Uncovered Elements: 3 (12) |
Complexity: 4 |
Complexity Density: 0.67 |
|
| 278 |
8 |
private void setupOSFforSequenceTest(String propsFile) {... |
| 279 |
8 |
Cache.loadProperties( |
| 280 |
8 |
propsFile == null ? "test/jalview/io/testProps.jvprops" |
| 281 |
|
: propsFile); |
| 282 |
|
|
| 283 |
8 |
Jalview.main( |
| 284 |
8 |
propsFile == null ? null : new String[] |
| 285 |
|
{ "--props", propsFile }); |
| 286 |
8 |
if (Desktop.getInstance() != null) |
| 287 |
8 |
Desktop.getInstance().closeAll_actionPerformed(null); |
| 288 |
8 |
JvOptionPane.setInteractiveMode(false); |
| 289 |
8 |
JvOptionPane.setMockResponse(JvOptionPane.OK_OPTION); |
| 290 |
|
|
| 291 |
|
|
| 292 |
|
} |
| |
|
| 94.1% |
Uncovered Elements: 1 (17) |
Complexity: 2 |
Complexity Density: 0.12 |
1PASS
|
|
| 293 |
6 |
@Test(groups = { "Functional" }, dataProvider = "openStructureFileParams")... |
| 294 |
|
public void openStructureFileForSequenceTest(String alfile, String seqid, |
| 295 |
|
String sFilename, TFType tft, String paeFilename, |
| 296 |
|
boolean showRefAnnotations, boolean doXferSettings, |
| 297 |
|
ViewerType viewerType, int seqNum, int annNum, int viewerNum, |
| 298 |
|
String propsFile) |
| 299 |
|
{ |
| 300 |
6 |
setupOSFforSequenceTest(propsFile); |
| 301 |
6 |
FileLoader fileLoader = new FileLoader(true); |
| 302 |
6 |
FileFormatI format = null; |
| 303 |
6 |
File alFile = new File(alfile); |
| 304 |
6 |
try |
| 305 |
|
{ |
| 306 |
6 |
format = new IdentifyFile().identify(alFile, DataSourceType.FILE); |
| 307 |
|
} catch (FileFormatException e1) |
| 308 |
|
{ |
| 309 |
0 |
Assert.fail( |
| 310 |
|
"Unknown file format for '" + alFile.getAbsolutePath() + "'"); |
| 311 |
|
} |
| 312 |
|
|
| 313 |
6 |
AlignFrame af = fileLoader.LoadFileWaitTillLoaded(alFile, |
| 314 |
|
DataSourceType.FILE, format); |
| 315 |
6 |
AlignmentPanel ap = af.alignPanel; |
| 316 |
6 |
Assert.assertNotNull("No alignPanel", ap); |
| 317 |
|
|
| 318 |
6 |
AlignmentI al = ap.getAlignment(); |
| 319 |
6 |
Assert.assertNotNull(al); |
| 320 |
|
|
| 321 |
6 |
SequenceI seq = al.findName(seqid); |
| 322 |
6 |
Assert.assertNotNull("Sequence '" + seqid + "' not found in alignment", |
| 323 |
|
seq); |
| 324 |
|
|
| 325 |
6 |
StructureChooser.openStructureFileForSequence(null, null, ap, seq, |
| 326 |
|
false, sFilename, tft, paeFilename, false, showRefAnnotations, |
| 327 |
|
doXferSettings, viewerType); |
| 328 |
|
|
| 329 |
6 |
OSFforSeqValidate(af, ap, al, seqNum, annNum, viewerNum); |
| 330 |
|
|
| 331 |
|
|
| 332 |
6 |
closeAf(af); |
| 333 |
|
} |
| 334 |
|
|
| |
|
| 0% |
Uncovered Elements: 46 (46) |
Complexity: 7 |
Complexity Density: 0.18 |
3FAIL
|
|
| 335 |
0 |
@Test(groups = { "Functional" }, dataProvider = "openStructureFileMChainParams", singleThreaded=true)... |
| 336 |
|
public void openStructureFileForSequenceMultiChainTest(String alfile, String seqid, |
| 337 |
|
String sFilename, TFType tft, String[] chains, String paeFilename, |
| 338 |
|
boolean showRefAnnotations, boolean doXferSettings, |
| 339 |
|
ViewerType viewerType, int seqNum, int annNum, int viewerNum, |
| 340 |
|
String propsFile) throws IOException |
| 341 |
|
{ |
| 342 |
0 |
setupOSFforSequenceTest(propsFile); |
| 343 |
0 |
FileLoader fileLoader = new FileLoader(true); |
| 344 |
0 |
FileFormatI format = null; |
| 345 |
0 |
File alFile = new File(alfile); |
| 346 |
0 |
try |
| 347 |
|
{ |
| 348 |
0 |
format = new IdentifyFile().identify(alFile, DataSourceType.FILE); |
| 349 |
|
} catch (FileFormatException e1) |
| 350 |
|
{ |
| 351 |
0 |
Assert.fail( |
| 352 |
|
"Unknown file format for '" + alFile.getAbsolutePath() + "'"); |
| 353 |
|
} |
| 354 |
|
|
| 355 |
0 |
AlignFrame af = fileLoader.LoadFileWaitTillLoaded(alFile, |
| 356 |
|
DataSourceType.FILE, format); |
| 357 |
0 |
AlignmentPanel ap = af.alignPanel; |
| 358 |
0 |
Assert.assertNotNull("No alignPanel", ap); |
| 359 |
|
|
| 360 |
0 |
AlignmentI al = ap.getAlignment(); |
| 361 |
0 |
Assert.assertNotNull(al); |
| 362 |
|
|
| 363 |
0 |
SequenceI seq = al.findName(seqid); |
| 364 |
0 |
Assert.assertNotNull("Sequence '" + seqid + "' not found in alignment", |
| 365 |
|
seq); |
| 366 |
|
|
| 367 |
0 |
StructureChooser.openStructureForASequence(null, null, ap, seq, false, sFilename, DataSourceType.FILE, chains, tft, paeFilename, false, showRefAnnotations, doXferSettings, viewerType); |
| 368 |
|
|
| 369 |
|
|
| 370 |
0 |
OSFforSeqValidate(af, ap, al, seqNum, annNum, viewerNum); |
| 371 |
|
|
| 372 |
|
|
| 373 |
0 |
String canonicalFile = null; |
| 374 |
0 |
int found=0; |
| 375 |
0 |
String failedToFind=""; |
| 376 |
0 |
int passes=0; |
| 377 |
0 |
canonicalFile = new File(sFilename).getCanonicalPath(); |
| 378 |
0 |
do |
| 379 |
|
{ |
| 380 |
0 |
owait(125); |
| 381 |
0 |
StructureMapping[] smappings = Desktop.getStructureSelectionManager() |
| 382 |
|
.getMapping(canonicalFile); |
| 383 |
0 |
assertNotNull(smappings); |
| 384 |
0 |
assertTrue(smappings.length >= 1); |
| 385 |
0 |
if (chains != null) |
| 386 |
|
{ |
| 387 |
0 |
found=0; |
| 388 |
0 |
failedToFind=""; |
| 389 |
0 |
assertEquals(smappings.length, chains.length); |
| 390 |
0 |
for (StructureMapping sm : smappings) |
| 391 |
|
{ |
| 392 |
0 |
for (String ch : chains) |
| 393 |
|
{ |
| 394 |
0 |
if (ch.equals(sm.getChain())) |
| 395 |
|
{ |
| 396 |
0 |
found++; |
| 397 |
|
} else { |
| 398 |
0 |
failedToFind+=("Didn't find a mapping for chain '"+sm.getChain()+"'"); |
| 399 |
|
} |
| 400 |
|
} |
| 401 |
|
} |
| 402 |
|
} |
| 403 |
0 |
} while (found<1 && passes++ < 3); |
| 404 |
0 |
if (found<1) |
| 405 |
|
{ |
| 406 |
0 |
fail(failedToFind); |
| 407 |
|
} |
| 408 |
0 |
closeAf(af); |
| 409 |
|
} |
| |
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 410 |
17 |
private void owait(long ms)... |
| 411 |
|
{ |
| 412 |
17 |
try |
| 413 |
|
{ |
| 414 |
17 |
Thread.sleep(ms); |
| 415 |
|
} catch (InterruptedException e) |
| 416 |
|
{ |
| 417 |
|
|
| 418 |
0 |
e.printStackTrace(); |
| 419 |
|
} |
| 420 |
|
|
| 421 |
|
} |
| |
|
| 88.9% |
Uncovered Elements: 4 (36) |
Complexity: 5 |
Complexity Density: 0.18 |
|
| 422 |
8 |
private void OSFforSeqValidate(AlignFrame af, AlignmentPanel ap, AlignmentI al, int seqNum, int annNum, int viewerNum) {... |
| 423 |
|
|
| 424 |
8 |
owait(150); |
| 425 |
8 |
List<SequenceI> seqs = al.getSequences(); |
| 426 |
8 |
Assert.assertNotNull(seqs); |
| 427 |
|
|
| 428 |
8 |
Assert.assertEquals("Wrong number of sequences", seqNum, seqs.size()); |
| 429 |
|
|
| 430 |
8 |
AlignViewportI av = ap.getAlignViewport(); |
| 431 |
8 |
Assert.assertNotNull(av); |
| 432 |
|
|
| 433 |
8 |
AlignmentAnnotation[] aas = al.getAlignmentAnnotation(); |
| 434 |
8 |
int visibleAnn = 0; |
| 435 |
8 |
for (AlignmentAnnotation aa : aas) |
| 436 |
|
{ |
| 437 |
68 |
if (aa.visible) |
| 438 |
68 |
visibleAnn++; |
| 439 |
|
} |
| 440 |
8 |
Assert.assertEquals("Wrong number of viewed annotations", annNum, |
| 441 |
|
visibleAnn); |
| 442 |
|
|
| 443 |
8 |
if (viewerNum > -1) |
| 444 |
|
{ |
| 445 |
8 |
owait(150); |
| 446 |
8 |
List<StructureViewerBase> openViewers = Desktop.getInstance() |
| 447 |
|
.getStructureViewers(ap, null); |
| 448 |
8 |
Assert.assertNotNull(openViewers); |
| 449 |
8 |
int count = 0; |
| 450 |
8 |
int mappedCount = 0; |
| 451 |
8 |
for (StructureViewerBase svb : openViewers) |
| 452 |
|
{ |
| 453 |
5 |
if (svb.isVisible()) { |
| 454 |
5 |
count++; |
| 455 |
5 |
for (SequenceI[] sqm: svb.getBinding().getSequence()) { |
| 456 |
5 |
for (SequenceI sq:sqm) { |
| 457 |
5 |
if (sq!=null) { |
| 458 |
5 |
mappedCount++; |
| 459 |
|
} |
| 460 |
|
} |
| 461 |
|
} |
| 462 |
5 |
assertTrue(mappedCount==1); |
| 463 |
5 |
assertTrue(svb.getBinding().getMappedStructureCount()>0); |
| 464 |
|
} |
| 465 |
|
} |
| 466 |
7 |
Assert.assertEquals("Wrong number of structure viewers opened", |
| 467 |
|
viewerNum, count); |
| 468 |
|
|
| 469 |
|
} |
| 470 |
|
} |
| |
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 471 |
6 |
private void closeAf(AlignFrame af)... |
| 472 |
|
{ |
| 473 |
|
|
| 474 |
6 |
if (af != null) |
| 475 |
|
{ |
| 476 |
6 |
af.setVisible(false); |
| 477 |
6 |
af.dispose(); |
| 478 |
|
} |
| 479 |
|
|
| 480 |
|
} |
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 481 |
1 |
@DataProvider(name = "openStructureFileParams")... |
| 482 |
|
public Object[][] openStructureFileParams() |
| 483 |
|
{ |
| 484 |
|
|
| 485 |
|
|
| 486 |
|
|
| 487 |
|
|
| 488 |
|
|
| 489 |
|
|
| 490 |
|
|
| 491 |
|
|
| 492 |
|
|
| 493 |
|
|
| 494 |
|
|
| 495 |
|
|
| 496 |
|
|
| 497 |
|
|
| 498 |
1 |
return new Object[][] { |
| 499 |
|
|
| 500 |
|
|
| 501 |
|
{ "examples/uniref50.fa", "FER1_SPIOL", |
| 502 |
|
"examples/AlphaFold/AF-P00221-F1-model_v4.cif", TFType.DEFAULT, |
| 503 |
|
"examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json", |
| 504 |
|
true, false, null, 15, 7, 0, null }, |
| 505 |
|
{ "examples/uniref50.fa", "FER1_SPIOL", |
| 506 |
|
"examples/AlphaFold/AF-P00221-F1-model_v4.cif", TFType.PLDDT, |
| 507 |
|
"examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json", |
| 508 |
|
true, false, null, 15, 7, 0, null }, |
| 509 |
|
{ "examples/uniref50.fa", "FER1_SPIOL", |
| 510 |
|
"examples/AlphaFold/AF-P00221-F1-model_v4.cif", TFType.PLDDT, |
| 511 |
|
"examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json", |
| 512 |
|
false, false, null, 15, 4, 0, null }, |
| 513 |
|
{ "examples/uniref50.fa", "FER1_SPIOL", |
| 514 |
|
"examples/AlphaFold/AF-P00221-F1-model_v4.cif", TFType.DEFAULT, |
| 515 |
|
"examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json", |
| 516 |
|
true, false, ViewerType.JMOL, 15, 7, 1, null }, |
| 517 |
|
{ "examples/uniref50.fa", "FER1_SPIOL", |
| 518 |
|
"examples/AlphaFold/AF-P00221-F1-model_v4.cif", TFType.PLDDT, |
| 519 |
|
"examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json", |
| 520 |
|
true, false, ViewerType.JMOL, 15, 7, 1, null }, |
| 521 |
|
{ "examples/uniref50.fa", "FER1_SPIOL", |
| 522 |
|
"examples/AlphaFold/AF-P00221-F1-model_v4.cif", TFType.PLDDT, |
| 523 |
|
"examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json", |
| 524 |
|
false, false, ViewerType.JMOL, 15, 4, 1, null }, }; |
| 525 |
|
} |
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 526 |
1 |
@DataProvider(name = "openStructureFileMChainParams")... |
| 527 |
|
public Object[][] openStructureFileMChainParams() |
| 528 |
|
{ |
| 529 |
|
|
| 530 |
|
|
| 531 |
|
|
| 532 |
|
|
| 533 |
|
|
| 534 |
|
|
| 535 |
|
|
| 536 |
|
|
| 537 |
|
|
| 538 |
|
|
| 539 |
|
|
| 540 |
|
|
| 541 |
|
|
| 542 |
|
|
| 543 |
|
|
| 544 |
1 |
return new Object[][] { |
| 545 |
|
|
| 546 |
|
|
| 547 |
|
{ "examples/testdata/9CFN.lbn", "9CFN|A[1_555]", |
| 548 |
|
"examples/testdata/9CFN.cif", TFType.DEFAULT, |
| 549 |
|
new String[] { "A" }, |
| 550 |
|
null, |
| 551 |
|
true, false, ViewerType.JMOL, 2, 16, 1, null }, |
| 552 |
|
{ "examples/testdata/9CFN.lbn", "9CFN|B[1_555]", |
| 553 |
|
"examples/testdata/9CFN.cif", TFType.DEFAULT, |
| 554 |
|
new String[] { "B" }, |
| 555 |
|
null, |
| 556 |
|
true, false, ViewerType.JMOL, 2, 16, 1, null } |
| 557 |
|
}; |
| 558 |
|
} |
| 559 |
|
|
| 560 |
|
} |