X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fext%2Fjmol%2FJmolParserTest.java;h=f5e637c7355143927726cec759e7f1f3b239232f;hb=e4f893546d61b043b3381c9548f0cfbf7084fd78;hp=a68f7c85f31bf8231c545fc5272a9ef958d9e67e;hpb=8a693367d8a0f6113d21248993ca4e0355b32659;p=jalview.git diff --git a/test/jalview/ext/jmol/JmolParserTest.java b/test/jalview/ext/jmol/JmolParserTest.java index a68f7c8..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,12 +29,16 @@ import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentI; import jalview.datamodel.SequenceI; import jalview.gui.AlignFrame; -import jalview.io.AppletFormatAdapter; +import jalview.gui.JvOptionPane; +import jalview.io.DataSourceType; import jalview.io.FileLoader; +import jalview.structure.StructureImportSettings; +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; @@ -45,16 +50,25 @@ 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 */ String[] testFile = new String[] { "./examples/1GAQ.txt", - "./test/jalview/ext/jmol/1xyz.pdb" }; + "./test/jalview/ext/jmol/1xyz.pdb", + "./test/jalview/ext/jmol/1qcf.pdb" }; //@formatter:off // a modified and very cut-down extract of 4UJ4 - String pdbWithChainBreak = + String pastePDBDataWithChainBreak = "HEADER TRANSPORT PROTEIN 08-APR-15 4UJ4\n" + // chain B has missing residues; these should all go in the same sequence: "ATOM 1909 CA VAL B 358 21.329 -19.739 -67.740 1.00201.05 C\n" + @@ -83,10 +97,16 @@ 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"); + StructureImportSettings + .setDefaultPDBFileParser(StructureParser.JALVIEW_PARSER); } @Test(groups = { "Functional" }) @@ -95,8 +115,7 @@ public class JmolParserTest for (String f : testFile) { FileLoader fl = new jalview.io.FileLoader(false); - AlignFrame af = fl - .LoadFileWaitTillLoaded(f, AppletFormatAdapter.FILE); + AlignFrame af = fl.LoadFileWaitTillLoaded(f, DataSourceType.FILE); validateSecStrRows(af.getViewport().getAlignment()); } } @@ -107,9 +126,8 @@ public class JmolParserTest for (String pdbStr : testFile) { PDBfile mctest = new PDBfile(false, false, false, pdbStr, - AppletFormatAdapter.FILE); - JmolParser jtest = new JmolParser(false, false, false, pdbStr, - jalview.io.AppletFormatAdapter.FILE); + DataSourceType.FILE); + JmolParser jtest = new JmolParser(pdbStr, DataSourceType.FILE); Vector seqs = jtest.getSeqs(), mcseqs = mctest.getSeqs(); assertTrue( @@ -127,6 +145,7 @@ public class JmolParserTest validateSecStrRows(al); } } + } private void validateSecStrRows(AlignmentI al) @@ -156,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( @@ -172,15 +192,9 @@ public class JmolParserTest @Test(groups = { "Functional" }) public void testParse_missingResidues() throws Exception { - PDBfile mctest = new PDBfile(false, false, false, pdbWithChainBreak, - AppletFormatAdapter.PASTE); - boolean annotFromStructure = false; - boolean localSecondaryStruct = false; - boolean serviceSecondaryStruct = false; - JmolParser jtest = new JmolParser(annotFromStructure, - localSecondaryStruct, serviceSecondaryStruct, - pdbWithChainBreak, - jalview.io.AppletFormatAdapter.PASTE); + PDBfile mctest = new PDBfile(false, false, false, + pastePDBDataWithChainBreak, DataSourceType.PASTE); + JmolParser jtest = new JmolParser(pastePDBDataWithChainBreak, DataSourceType.PASTE); Vector seqs = jtest.getSeqs(); Vector mcseqs = mctest.getSeqs(); @@ -201,16 +215,12 @@ public class JmolParserTest public void testParse_alternativeResidues() throws Exception { PDBfile mctest = new PDBfile(false, false, false, pdbWithAltLoc, - AppletFormatAdapter.PASTE); - boolean annotFromStructure = false; - boolean localSecondaryStruct = false; - boolean serviceSecondaryStruct = false; - JmolParser jtest = new JmolParser(annotFromStructure, - localSecondaryStruct, serviceSecondaryStruct, pdbWithAltLoc, - jalview.io.AppletFormatAdapter.PASTE); + DataSourceType.PASTE); + 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()); @@ -247,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"); + } }