From: Jim Procter Date: Wed, 24 Aug 2016 15:46:30 +0000 (+0100) Subject: JAL-2106 rejig test to minimally verify patch that getPDBEntry can be called on local... X-Git-Tag: Release_2_10_0~47^2~4^2~43^2~15^2^2~8 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=fa6002323c9a80282ac34a3ecba0ee0d5643e130;p=jalview.git JAL-2106 rejig test to minimally verify patch that getPDBEntry can be called on local and dataset sequence --- diff --git a/src/jalview/datamodel/Sequence.java b/src/jalview/datamodel/Sequence.java index a857712..98cd4b2 100755 --- a/src/jalview/datamodel/Sequence.java +++ b/src/jalview/datamodel/Sequence.java @@ -1394,12 +1394,15 @@ public class Sequence extends ASequence implements SequenceI @Override public PDBEntry getPDBEntry(String pdbIdStr) { - if (getDatasetSequence() == null - || getDatasetSequence().getAllPDBEntries() == null) + if (getDatasetSequence() != null) + { + return getDatasetSequence().getPDBEntry(pdbIdStr); + } + if (pdbIds == null) { return null; } - List entries = getDatasetSequence().getAllPDBEntries(); + List entries = getAllPDBEntries(); for (PDBEntry entry : entries) { if (entry.getId().equalsIgnoreCase(pdbIdStr)) diff --git a/test/jalview/datamodel/SequenceTest.java b/test/jalview/datamodel/SequenceTest.java index 71719dd..1fed98b 100644 --- a/test/jalview/datamodel/SequenceTest.java +++ b/test/jalview/datamodel/SequenceTest.java @@ -440,36 +440,54 @@ public class SequenceTest sq.setDescription("Test sequence description.."); sq.setVamsasId("TestVamsasId"); - sq.setSourceDBRef(new DBRefEntry("PDB", "version0", "1TST")); + sq.addDBRef(new DBRefEntry("PDB", "version0", "1TST")); - sq.addDBRef(new DBRefEntry("PDB", "version1", "1Tst")); - sq.addDBRef(new DBRefEntry("PDB", "version2", "2Tst")); - sq.addDBRef(new DBRefEntry("PDB", "version3", "3Tst")); - sq.addDBRef(new DBRefEntry("PDB", "version4", "4Tst")); + sq.addDBRef(new DBRefEntry("PDB", "version1", "1PDB")); + sq.addDBRef(new DBRefEntry("PDB", "version2", "2PDB")); + sq.addDBRef(new DBRefEntry("PDB", "version3", "3PDB")); + sq.addDBRef(new DBRefEntry("PDB", "version4", "4PDB")); sq.addPDBId(new PDBEntry("1PDB", "A", Type.PDB, "filePath/test1")); sq.addPDBId(new PDBEntry("1PDB", "B", Type.PDB, "filePath/test1")); sq.addPDBId(new PDBEntry("2PDB", "A", Type.MMCIF, "filePath/test2")); sq.addPDBId(new PDBEntry("2PDB", "B", Type.MMCIF, "filePath/test2")); + + DBRefEntry pdb1pdb = new DBRefEntry("PDB", "version1", "1PDB"); + DBRefEntry pdb2pdb = new DBRefEntry("PDB", "version1", "2PDB"); + List primRefs = Arrays.asList(new DBRefEntry[] { pdb1pdb, + pdb2pdb }); + sq.getDatasetSequence().addDBRef(pdb1pdb); + sq.getDatasetSequence().addDBRef(pdb2pdb); sq.getDatasetSequence().addDBRef( - new DBRefEntry("PDB", "version1", "1Tst")); - sq.getDatasetSequence().addDBRef( - new DBRefEntry("PDB", "version2", "2Tst")); - sq.getDatasetSequence().addDBRef( - new DBRefEntry("PDB", "version3", "3Tst")); + new DBRefEntry("PDB", "version3", "3PDB")); sq.getDatasetSequence().addDBRef( - new DBRefEntry("PDB", "version4", "4Tst")); - - sq.getDatasetSequence().addPDBId( - new PDBEntry("1PDB", "A", Type.PDB, "filePath/test1")); - sq.getDatasetSequence().addPDBId( - new PDBEntry("1PDB", "B", Type.PDB, "filePath/test1")); + new DBRefEntry("PDB", "version4", "4PDB")); + + PDBEntry pdbe1a=new PDBEntry("1PDB", "A", Type.PDB, "filePath/test1"); + PDBEntry pdbe1b = new PDBEntry("1PDB", "B", Type.PDB, "filePath/test1"); + PDBEntry pdbe2a=new PDBEntry("2PDB", "A", Type.MMCIF, "filePath/test2"); + PDBEntry pdbe2b = new PDBEntry("2PDB", "B", Type.MMCIF, "filePath/test2"); sq.getDatasetSequence().addPDBId( - new PDBEntry("2PDB", "A", Type.MMCIF, "filePath/test2")); + pdbe1a); sq.getDatasetSequence().addPDBId( - new PDBEntry("2PDB", "B", Type.MMCIF, "filePath/test2")); + pdbe1b); + sq.getDatasetSequence().addPDBId(pdbe2a); + sq.getDatasetSequence().addPDBId(pdbe2b); + + /* + * test we added pdb entries to the dataset sequence + */ + Assert.assertEquals(sq.getDatasetSequence().getAllPDBEntries(), Arrays + .asList(new PDBEntry[] { pdbe1a, pdbe1b, pdbe2a, pdbe2b }), + "PDB Entries were not found on dataset sequence."); + /* + * we should recover a pdb entry that is on the dataset sequence via PDBEntry + */ + Assert.assertEquals(pdbe1a, + sq.getDatasetSequence().getPDBEntry("1PDB"), + "PDB Entry '1PDB' not found on dataset sequence via getPDBEntry."); ArrayList annotsList = new ArrayList(); System.out.println(">>>>>> " + sq.getSequenceAsString().length()); annotsList.add(new Annotation("A", "A", 'X', 0.1f));