X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fext%2Fjmol%2FJmolParserTest.java;h=f5e637c7355143927726cec759e7f1f3b239232f;hb=136c0793b90b72b928c4d77dc109dd5c644e00d3;hp=f2b32c60cecd8b669adf04494e11f419f1e9a5fc;hpb=8b27085fa7fc5f2877e078421284c2636b85b8c6;p=jalview.git diff --git a/test/jalview/ext/jmol/JmolParserTest.java b/test/jalview/ext/jmol/JmolParserTest.java index f2b32c6..f5e637c 100644 --- a/test/jalview/ext/jmol/JmolParserTest.java +++ b/test/jalview/ext/jmol/JmolParserTest.java @@ -21,6 +21,7 @@ package jalview.ext.jmol; import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.assertTrue; import jalview.bin.Cache; @@ -28,6 +29,7 @@ import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentI; import jalview.datamodel.SequenceI; import jalview.gui.AlignFrame; +import jalview.gui.JvOptionPane; import jalview.io.DataSourceType; import jalview.io.FileLoader; import jalview.structure.StructureImportSettings; @@ -36,6 +38,7 @@ import jalview.structure.StructureImportSettings.StructureParser; import java.util.Vector; import org.jmol.c.STR; +import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -47,6 +50,14 @@ import MCview.PDBfile; */ public class JmolParserTest { + + @BeforeClass(alwaysRun = true) + public void setUpJvOptionPane() + { + JvOptionPane.setInteractiveMode(false); + JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); + } + /* * 1GAQ has been reduced to alpha carbons only * 1QCF is the full PDB file including headers, HETATM etc @@ -86,8 +97,11 @@ public class JmolParserTest @BeforeMethod(alwaysRun = true) public void setUp() { + Cache.loadProperties("test/jalview/io/testProps.jvprops"); Cache.applicationProperties.setProperty("STRUCT_FROM_PDB", Boolean.TRUE.toString()); + Cache.applicationProperties.setProperty("ADD_TEMPFACT_ANN", + Boolean.FALSE.toString()); Cache.applicationProperties.setProperty("ADD_SS_ANN", Boolean.TRUE.toString()); StructureImportSettings.setDefaultStructureFileFormat("PDB"); @@ -113,8 +127,7 @@ public class JmolParserTest { PDBfile mctest = new PDBfile(false, false, false, pdbStr, DataSourceType.FILE); - JmolParser jtest = new JmolParser(false, false, false, pdbStr, - DataSourceType.FILE); + JmolParser jtest = new JmolParser(pdbStr, DataSourceType.FILE); Vector seqs = jtest.getSeqs(), mcseqs = mctest.getSeqs(); assertTrue( @@ -162,7 +175,8 @@ public class JmolParserTest private void checkFirstAAIsAssoc(SequenceI sq) { - assertTrue("No secondary structure assigned for protein sequence.", + assertTrue("No secondary structure assigned for protein sequence for " + + sq.getName(), sq.getAnnotation() != null && sq.getAnnotation().length >= 1 && sq.getAnnotation()[0].hasIcons); assertTrue( @@ -180,12 +194,7 @@ public class JmolParserTest { PDBfile mctest = new PDBfile(false, false, false, pastePDBDataWithChainBreak, DataSourceType.PASTE); - boolean annotFromStructure = false; - boolean localSecondaryStruct = false; - boolean serviceSecondaryStruct = false; - JmolParser jtest = new JmolParser(annotFromStructure, - localSecondaryStruct, serviceSecondaryStruct, - pastePDBDataWithChainBreak, DataSourceType.PASTE); + JmolParser jtest = new JmolParser(pastePDBDataWithChainBreak, DataSourceType.PASTE); Vector seqs = jtest.getSeqs(); Vector mcseqs = mctest.getSeqs(); @@ -207,15 +216,11 @@ public class JmolParserTest { PDBfile mctest = new PDBfile(false, false, false, pdbWithAltLoc, DataSourceType.PASTE); - boolean annotFromStructure = false; - boolean localSecondaryStruct = false; - boolean serviceSecondaryStruct = false; - JmolParser jtest = new JmolParser(annotFromStructure, - localSecondaryStruct, serviceSecondaryStruct, pdbWithAltLoc, + JmolParser jtest = new JmolParser(pdbWithAltLoc, DataSourceType.PASTE); Vector seqs = jtest.getSeqs(); Vector mcseqs = mctest.getSeqs(); - + assertEquals("Failed to find 1 sequence\n", 1, seqs.size()); assertEquals("Failed to find 1 sequence\n", 1, mcseqs.size()); assertEquals("ALC", seqs.get(0).getSequenceAsString()); @@ -252,4 +257,29 @@ public class JmolParserTest assertEquals('H', structCode[4]); assertEquals('E', structCode[5]); } + + @Test(groups = "Functional") + public void testLocalPDBId() throws Exception + { + JmolParser structureData; + /* + * reads a local structure + */ + structureData = new JmolParser("examples/testdata/localstruct.pdb", + DataSourceType.FILE); + assertNotNull(structureData); + /* + * local structure files should yield a false ID based on the filename + */ + assertNotNull(structureData.getId()); + assertEquals(structureData.getId(), "localstruct"); + assertNotNull(structureData.getSeqs()); + /* + * the ID is also the group for features derived from structure data + */ + String featureGroup = structureData.getSeqs().get(0) + .getSequenceFeatures().get(0).featureGroup; + assertNotNull(featureGroup); + assertEquals(featureGroup, "localstruct"); + } }