X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fext%2Fjmol%2FJmolParserTest.java;h=f5e637c7355143927726cec759e7f1f3b239232f;hb=e4f893546d61b043b3381c9548f0cfbf7084fd78;hp=8788609149b4f1cec7ff80f5a00230a9017d4427;hpb=ce6f02a53c98e51cb96533d40db5f94d1bfea00a;p=jalview.git diff --git a/test/jalview/ext/jmol/JmolParserTest.java b/test/jalview/ext/jmol/JmolParserTest.java index 8788609..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,13 +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; @@ -46,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 @@ -93,6 +105,8 @@ public class JmolParserTest Cache.applicationProperties.setProperty("ADD_SS_ANN", Boolean.TRUE.toString()); StructureImportSettings.setDefaultStructureFileFormat("PDB"); + StructureImportSettings + .setDefaultPDBFileParser(StructureParser.JALVIEW_PARSER); } @Test(groups = { "Functional" }) @@ -101,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()); } } @@ -113,8 +126,8 @@ public class JmolParserTest for (String pdbStr : testFile) { PDBfile mctest = new PDBfile(false, false, false, pdbStr, - AppletFormatAdapter.FILE); - JmolParser jtest = new JmolParser(pdbStr, AppletFormatAdapter.FILE); + 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( @@ -179,10 +193,8 @@ public class JmolParserTest public void testParse_missingResidues() throws Exception { PDBfile mctest = new PDBfile(false, false, false, - pastePDBDataWithChainBreak, - AppletFormatAdapter.PASTE); - JmolParser jtest = new JmolParser(pastePDBDataWithChainBreak, - AppletFormatAdapter.PASTE); + pastePDBDataWithChainBreak, DataSourceType.PASTE); + JmolParser jtest = new JmolParser(pastePDBDataWithChainBreak, DataSourceType.PASTE); Vector seqs = jtest.getSeqs(); Vector mcseqs = mctest.getSeqs(); @@ -203,12 +215,12 @@ public class JmolParserTest public void testParse_alternativeResidues() throws Exception { PDBfile mctest = new PDBfile(false, false, false, pdbWithAltLoc, - AppletFormatAdapter.PASTE); + DataSourceType.PASTE); JmolParser jtest = new JmolParser(pdbWithAltLoc, - AppletFormatAdapter.PASTE); + 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()); @@ -245,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"); + } }