From f213422632d268e3a2f334255fa705d8e931866f Mon Sep 17 00:00:00 2001 From: tcofoegbu Date: Thu, 3 Mar 2016 14:46:00 +0000 Subject: [PATCH] JAL-1919 fixed bug causing PDBfile test failure --- src/jalview/api/DBRefEntryI.java | 4 ++++ src/jalview/datamodel/DBRefEntry.java | 15 +++++++++------ src/jalview/datamodel/Sequence.java | 3 ++- src/jalview/io/StructureFile.java | 11 +++-------- test/MCview/PDBfileTest.java | 6 ++++-- 5 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/jalview/api/DBRefEntryI.java b/src/jalview/api/DBRefEntryI.java index b927fa5..9415745 100644 --- a/src/jalview/api/DBRefEntryI.java +++ b/src/jalview/api/DBRefEntryI.java @@ -1,5 +1,7 @@ package jalview.api; +import jalview.datamodel.Mapping; + public interface DBRefEntryI { @@ -69,4 +71,6 @@ public interface DBRefEntryI * @return index of end residue in the source DB */ public int getEndRes(); + + public Mapping getMap(); } diff --git a/src/jalview/datamodel/DBRefEntry.java b/src/jalview/datamodel/DBRefEntry.java index 0b1fb6d..53642b5 100755 --- a/src/jalview/datamodel/DBRefEntry.java +++ b/src/jalview/datamodel/DBRefEntry.java @@ -37,6 +37,7 @@ public class DBRefEntry implements DBRefEntryI } + public DBRefEntry(String source, String version, String accessionId) { this(source, version, accessionId, null); @@ -63,13 +64,14 @@ public class DBRefEntry implements DBRefEntryI this.map = map; } - public DBRefEntry(DBRefEntry entry) + public DBRefEntry(DBRefEntryI entry) { - this( - (entry.source == null ? "" : new String(entry.source)), - (entry.version == null ? "" : new String(entry.version)), - (entry.accessionId == null ? "" : new String(entry.accessionId)), - (entry.map == null ? null : new Mapping(entry.map))); + this((entry.getSource() == null ? "" : new String(entry.getSource())), + (entry.getVersion() == null ? "" : new String( + entry.getVersion())), + (entry.getAccessionId() == null ? "" : new String( + entry.getAccessionId())), + (entry.getMap() == null ? null : new Mapping(entry.getMap()))); } @Override @@ -165,6 +167,7 @@ public class DBRefEntry implements DBRefEntryI } + @Override public Mapping getMap() { return map; diff --git a/src/jalview/datamodel/Sequence.java b/src/jalview/datamodel/Sequence.java index d73b283..a2513ba 100755 --- a/src/jalview/datamodel/Sequence.java +++ b/src/jalview/datamodel/Sequence.java @@ -219,7 +219,8 @@ public class Sequence extends ASequence implements SequenceI initSeqAndName(seq.getName(), seq.getSequence(), seq.getStart(), seq.getEnd()); description = seq.getDescription(); - sourceDBRef = seq.getSourceDBRef(); + sourceDBRef = seq.getSourceDBRef() == null ? null : new DBRefEntry( + seq.getSourceDBRef()); if (seq.getSequenceFeatures() != null) { SequenceFeature[] sf = seq.getSequenceFeatures(); diff --git a/src/jalview/io/StructureFile.java b/src/jalview/io/StructureFile.java index e2b73d1..4ba4c10 100644 --- a/src/jalview/io/StructureFile.java +++ b/src/jalview/io/StructureFile.java @@ -96,16 +96,11 @@ public abstract class StructureFile extends AlignFile sourceDBRef.setStartRes(pdbSequence.getStart()); sourceDBRef.setEndRes(pdbSequence.getEnd()); - // PDBChain objects maintain reference to dataset - - // SequenceI chainseq = pdbSequence.deriveSequence(); - // chainseq.setSourceDBRef(sourceDBRef); - // chainseq.addPDBId(entry); - // chainseq.addDBRef(sourceDBRef); - SequenceI chainseq = chain.sequence; - chainseq.addPDBId(entry); + SequenceI chainseq = pdbSequence.deriveSequence(); chainseq.setSourceDBRef(sourceDBRef); + chainseq.addPDBId(entry); chainseq.addDBRef(sourceDBRef); + seqs.addElement(chainseq); AlignmentAnnotation[] chainannot = chainseq.getAnnotation(); diff --git a/test/MCview/PDBfileTest.java b/test/MCview/PDBfileTest.java index 31c3beb..0fc7d1c 100644 --- a/test/MCview/PDBfileTest.java +++ b/test/MCview/PDBfileTest.java @@ -83,6 +83,8 @@ public class PDBfileTest assertEquals("D", pf.getChains().get(3).id); PDBChain chainA = pf.getChains().get(0); + SequenceI seqA = pf.getSeqs().get(0); + assertEquals(0, chainA.seqstart); // not set assertEquals(0, chainA.seqend); // not set assertEquals(18, chainA.sequence.getStart()); @@ -91,8 +93,8 @@ public class PDBfileTest assertTrue(chainA.sequence.getSequenceAsString().endsWith("WNVEVY")); assertEquals("3W5V|A", chainA.sequence.getName()); assertNull(chainA.sequence.getAnnotation()); - assertEquals(1, chainA.sequence.getAllPDBEntries().size()); - PDBEntry pdb = chainA.sequence.getAllPDBEntries().get(0); + assertEquals(1, seqA.getAllPDBEntries().size()); + PDBEntry pdb = seqA.getAllPDBEntries().get(0); assertEquals("A", pdb.getChainCode()); assertEquals("PDB", pdb.getType()); assertEquals("3W5V", pdb.getId()); -- 1.7.10.2