X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fext%2Fjmol%2FJmolParserTest.java;h=b2d32532610abfad8cce58400be5a21dc9fe0a8d;hb=62cdf4a06bef088c02f81c66ab2fe0bc3264e321;hp=2a501a7539f477930833299a3fdb3d5e357541c2;hpb=63bb86fb2312c426063e8cd79de4685c05c4bc35;p=jalview.git diff --git a/test/jalview/ext/jmol/JmolParserTest.java b/test/jalview/ext/jmol/JmolParserTest.java index 2a501a7..b2d3253 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; @@ -30,6 +31,8 @@ import jalview.datamodel.SequenceI; import jalview.gui.AlignFrame; import jalview.io.AppletFormatAdapter; import jalview.io.FileLoader; +import jalview.structure.StructureImportSettings; +import jalview.structure.StructureImportSettings.StructureParser; import java.util.Vector; @@ -49,13 +52,13 @@ public class JmolParserTest * 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/1QCF.pdb" }; // , - String[] testFile = new String[] { "./examples/testdata/1qcf.cif" }; // , + String[] testFile = new String[] { "./examples/1GAQ.txt", + "./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" + @@ -84,10 +87,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" }) @@ -109,8 +118,7 @@ public class JmolParserTest { PDBfile mctest = new PDBfile(false, false, false, pdbStr, AppletFormatAdapter.FILE); - JmolParser jtest = new JmolParser(pdbStr, - jalview.io.AppletFormatAdapter.FILE); + JmolParser jtest = new JmolParser(pdbStr, AppletFormatAdapter.FILE); Vector seqs = jtest.getSeqs(), mcseqs = mctest.getSeqs(); assertTrue( @@ -128,6 +136,7 @@ public class JmolParserTest validateSecStrRows(al); } } + } private void validateSecStrRows(AlignmentI al) @@ -157,7 +166,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( @@ -173,10 +183,10 @@ public class JmolParserTest @Test(groups = { "Functional" }) public void testParse_missingResidues() throws Exception { - PDBfile mctest = new PDBfile(false, false, false, pdbWithChainBreak, + PDBfile mctest = new PDBfile(false, false, false, + pastePDBDataWithChainBreak, AppletFormatAdapter.PASTE); + JmolParser jtest = new JmolParser(pastePDBDataWithChainBreak, AppletFormatAdapter.PASTE); - JmolParser jtest = new JmolParser(pdbWithChainBreak, - jalview.io.AppletFormatAdapter.PASTE); Vector seqs = jtest.getSeqs(); Vector mcseqs = mctest.getSeqs(); @@ -199,10 +209,10 @@ public class JmolParserTest PDBfile mctest = new PDBfile(false, false, false, pdbWithAltLoc, AppletFormatAdapter.PASTE); JmolParser jtest = new JmolParser(pdbWithAltLoc, - jalview.io.AppletFormatAdapter.PASTE); + AppletFormatAdapter.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()); @@ -239,4 +249,30 @@ 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", + AppletFormatAdapter.FILE); + assertNotNull(structureData); + /* + * local structure files should yield a false ID based on the filename + */ + assertNotNull(structureData.getId()); + assertEquals(structureData.getId(), "localstruct.pdb"); + assertNotNull(structureData.getSeqs()); + /* + * the ID is also the group for features derived from structure data + */ + assertNotNull(structureData.getSeqs().get(0).getSequenceFeatures()[0].featureGroup); + assertEquals( + structureData.getSeqs().get(0).getSequenceFeatures()[0].featureGroup, + "localstruct.pdb"); + + } }