X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fgui%2FStructureChooserTest.java;h=b4eaf68f737d4d2b72d8e054b06cfbbcb561398c;hb=0788111a588187a04dd0d254d70b055274cf2c9d;hp=b74baf19ddf436bb479d4be93d6fe8bf8f4bdbac;hpb=c71453f1c7de4cc250700c1b6dd39d061982e794;p=jalview.git diff --git a/test/jalview/gui/StructureChooserTest.java b/test/jalview/gui/StructureChooserTest.java index b74baf1..b4eaf68 100644 --- a/test/jalview/gui/StructureChooserTest.java +++ b/test/jalview/gui/StructureChooserTest.java @@ -24,15 +24,23 @@ import static org.testng.Assert.assertEquals; import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.assertTrue; +import java.io.File; import java.util.Collection; +import java.util.List; import java.util.Vector; import org.junit.Assert; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; +import org.testng.annotations.DataProvider; import org.testng.annotations.Test; +import jalview.api.AlignViewportI; +import jalview.bin.Cache; +import jalview.bin.Jalview; +import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.AlignmentI; import jalview.datamodel.DBRefEntry; import jalview.datamodel.PDBEntry; import jalview.datamodel.Sequence; @@ -43,8 +51,15 @@ import jalview.fts.service.pdb.PDBFTSRestClient; import jalview.fts.service.pdb.PDBFTSRestClientTest; import jalview.fts.service.threedbeacons.TDBeaconsFTSRestClient; import jalview.fts.threedbeacons.TDBeaconsFTSRestClientTest; +import jalview.gui.StructureViewer.ViewerType; import jalview.gui.structurechooser.PDBStructureChooserQuerySource; +import jalview.io.DataSourceType; +import jalview.io.FileFormatException; +import jalview.io.FileFormatI; +import jalview.io.FileLoader; +import jalview.io.IdentifyFile; import jalview.jbgui.FilterOption; +import jalview.structure.StructureImportSettings.TFType; import junit.extensions.PA; @Test(singleThreaded = true) @@ -259,4 +274,140 @@ public class StructureChooserTest assertEquals("abcde12345afg", PDBStructureChooserQuerySource.sanitizeSeqName(name)); } + + @Test(groups = { "Functional" }, dataProvider = "openStructureFileParams") + public void openStructureFileForSequenceTest(String alfile, String seqid, + String sFilename, TFType tft, String paeFilename, + boolean showRefAnnotations, boolean doXferSettings, + ViewerType viewerType, int seqNum, int annNum, int viewerNum, + String propsFile) + { + Cache.loadProperties( + propsFile == null ? "test/jalview/io/testProps.jvprops" + : propsFile); + + Jalview.main( + propsFile == null ? null : new String[] + { "--props", propsFile }); + if (Desktop.instance != null) + Desktop.instance.closeAll_actionPerformed(null); + JvOptionPane.setInteractiveMode(false); + JvOptionPane.setMockResponse(JvOptionPane.OK_OPTION); + + FileLoader fileLoader = new FileLoader(true); + FileFormatI format = null; + File alFile = new File(alfile); + try + { + format = new IdentifyFile().identify(alFile, DataSourceType.FILE); + } catch (FileFormatException e1) + { + Assert.fail( + "Unknown file format for '" + alFile.getAbsolutePath() + "'"); + } + + AlignFrame af = fileLoader.LoadFileWaitTillLoaded(alFile, + DataSourceType.FILE, format); + AlignmentPanel ap = af.alignPanel; + Assert.assertNotNull("No alignPanel", ap); + + AlignmentI al = ap.getAlignment(); + Assert.assertNotNull(al); + + SequenceI seq = al.findName(seqid); + Assert.assertNotNull("Sequence '" + seqid + "' not found in alignment", + seq); + + StructureChooser.openStructureFileForSequence(null, null, ap, seq, + false, sFilename, tft, paeFilename, false, showRefAnnotations, + doXferSettings, viewerType); + + List seqs = al.getSequences(); + Assert.assertNotNull(seqs); + + Assert.assertEquals("Wrong number of sequences", seqNum, seqs.size()); + + AlignViewportI av = ap.getAlignViewport(); + Assert.assertNotNull(av); + + AlignmentAnnotation[] aas = al.getAlignmentAnnotation(); + int visibleAnn = 0; + for (AlignmentAnnotation aa : aas) + { + if (aa.visible) + visibleAnn++; + } + Assert.assertEquals("Wrong number of viewed annotations", annNum, + visibleAnn); + + if (viewerNum > -1) + { + try + { + Thread.sleep(100); + } catch (InterruptedException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + List openViewers = Desktop.instance + .getStructureViewers(ap, null); + Assert.assertNotNull(openViewers); + Assert.assertEquals("Wrong number of structure viewers opened", + viewerNum, openViewers.size()); + } + + if (af != null) + { + af.setVisible(false); + af.dispose(); + } + } + + @DataProvider(name = "openStructureFileParams") + public Object[][] openStructureFileParams() + { + /* + String alFile, + String seqid, + String structureFilename, + TFType tft, + String paeFilename, + boolean showRefAnnotations, + boolean doXferSettings, // false for Commands + ViewerType viewerType, + int seqNum, + int annNum, + int viewerNum, + String propsFile + */ + return new Object[][] { + /* + */ + { "examples/uniref50.fa", "FER1_SPIOL", + "examples/AlphaFold/AF-P00221-F1-model_v4.cif", TFType.DEFAULT, + "examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json", + true, false, null, 15, 7, 0, null }, + { "examples/uniref50.fa", "FER1_SPIOL", + "examples/AlphaFold/AF-P00221-F1-model_v4.cif", TFType.PLDDT, + "examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json", + true, false, null, 15, 7, 0, null }, + { "examples/uniref50.fa", "FER1_SPIOL", + "examples/AlphaFold/AF-P00221-F1-model_v4.cif", TFType.PLDDT, + "examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json", + false, false, null, 15, 4, 0, null }, + { "examples/uniref50.fa", "FER1_SPIOL", + "examples/AlphaFold/AF-P00221-F1-model_v4.cif", TFType.DEFAULT, + "examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json", + true, false, ViewerType.JMOL, 15, 7, 1, null }, + { "examples/uniref50.fa", "FER1_SPIOL", + "examples/AlphaFold/AF-P00221-F1-model_v4.cif", TFType.PLDDT, + "examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json", + true, false, ViewerType.JMOL, 15, 7, 1, null }, + { "examples/uniref50.fa", "FER1_SPIOL", + "examples/AlphaFold/AF-P00221-F1-model_v4.cif", TFType.PLDDT, + "examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json", + false, false, ViewerType.JMOL, 15, 4, 1, null }, }; + } + }