From 141eaf3859dbd8304fe664b37ef81848353406e0 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Thu, 25 Aug 2016 20:53:46 +0100 Subject: [PATCH] JAL-2106 tighten DBRefEntry primary seq test for PDB --- src/jalview/datamodel/Sequence.java | 9 ++++++++- test/jalview/datamodel/SequenceTest.java | 32 ++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/jalview/datamodel/Sequence.java b/src/jalview/datamodel/Sequence.java index 620bcc1..bb63466 100755 --- a/src/jalview/datamodel/Sequence.java +++ b/src/jalview/datamodel/Sequence.java @@ -1450,7 +1450,14 @@ public class Sequence extends ASequence implements SequenceI DBRefUtils.getCanonicalName(ref.getSource()))) { // PDB dbrefs imply there should be a PDBEntry associated - if (getPDBEntry(ref.getAccessionId()) != null) + // TODO: tighten PDB dbrefs + // formally imply Jalview has actually downlaoded and + // parsed the pdb file. That means there should be a cached file + // handle on the PDBEntry, and a real mapping between sequence and + // extracted sequence from PDB file + PDBEntry pdbentry = getPDBEntry(ref.getAccessionId()); + if (pdbentry != null && pdbentry.getType() != null + && pdbentry.getType().equalsIgnoreCase("PDB")) { primaries.add(ref); } diff --git a/test/jalview/datamodel/SequenceTest.java b/test/jalview/datamodel/SequenceTest.java index fcd24dd..3ad309e 100644 --- a/test/jalview/datamodel/SequenceTest.java +++ b/test/jalview/datamodel/SequenceTest.java @@ -452,8 +452,10 @@ public class SequenceTest DBRefEntry pdb1pdb = new DBRefEntry("PDB", "version1", "1PDB"); DBRefEntry pdb2pdb = new DBRefEntry("PDB", "version1", "2PDB"); - List primRefs = Arrays.asList(new DBRefEntry[] { pdb1pdb, - pdb2pdb }); + + //FIXME pdb2pdb's matching PDBEntry has Type.MMCIF - but 2.10 only has PDBEntry with type==PDB to indicate ID is a real PDB entry + + List primRefs = Arrays.asList(new DBRefEntry[] { pdb1pdb }); sq.getDatasetSequence().addDBRef(pdb1pdb); sq.getDatasetSequence().addDBRef(pdb2pdb); @@ -763,4 +765,30 @@ public class SequenceTest assertSame(dbref3, sq.getDBRefs()[2]); assertEquals("3", dbref2.getVersion()); } + + @Test(groups = { "Functional" }) + public void testGetPrimaryDBRefs() + { + /* + * test PDB relationships for for getPrimaryDBRefs + */ + SequenceI seq = new Sequence("aseq", "ASDF"); + DBRefEntry upentry = new DBRefEntry("UNIPROT", "0", "1qip"); + // primary - uniprot + seq.addDBRef(upentry); + // primary - type is PDB + DBRefEntry pdbentry = new DBRefEntry("PDB", "0", "1qip"); + seq.addDBRef(pdbentry); + // not primary - type of PDBEntry is not PDB + seq.addDBRef(new DBRefEntry("PDB", "0", "1AAA")); + // not primary - no PDBEntry + seq.addDBRef(new DBRefEntry("PDB", "0", "1DDD")); + seq.addPDBId(new PDBEntry("1QIP", null, Type.PDB, null)); + seq.addPDBId(new PDBEntry("1AAA", null, null, null)); + assertTrue("Couldn't find simple primary reference (UNIPROT)", seq + .getPrimaryDBRefs().contains(upentry)); + assertTrue("Couldn't find expected PDB primary reference", seq + .getPrimaryDBRefs().contains(pdbentry)); + assertEquals(2, seq.getPrimaryDBRefs().size()); + } } -- 1.7.10.2