From 449fb0be731c9283e9cad076a03fe730aeb2095a Mon Sep 17 00:00:00 2001 From: tcofoegbu Date: Tue, 17 May 2016 12:11:06 +0100 Subject: [PATCH] JAL-1270 Fixed anntatedPDBFileInputTest and updated implementation for testDeriveSequence_existingDataset method in SequenceTest --- src/jalview/io/StructureFile.java | 24 ++++------- test/jalview/datamodel/SequenceTest.java | 66 ++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 15 deletions(-) diff --git a/src/jalview/io/StructureFile.java b/src/jalview/io/StructureFile.java index 3a7419c..af5a1fa 100644 --- a/src/jalview/io/StructureFile.java +++ b/src/jalview/io/StructureFile.java @@ -26,6 +26,7 @@ public abstract class StructureFile extends AlignFile private String id; private String dbRefType; + /** * set to true to add derived sequence annotations (temp factor read from * file, or computed secondary structure) to the alignment @@ -117,14 +118,11 @@ public abstract class StructureFile extends AlignFile sourceDBRef.setSource(DBRefSource.PDB); sourceDBRef.setStartRes(pdbSequence.getStart()); sourceDBRef.setEndRes(pdbSequence.getEnd()); - - SequenceI chainseq = pdbSequence.deriveSequence(); - chainseq.setSourceDBRef(sourceDBRef); - chainseq.addPDBId(entry); - chainseq.addDBRef(sourceDBRef); - + pdbSequence.setSourceDBRef(sourceDBRef); + pdbSequence.addPDBId(entry); + pdbSequence.addDBRef(sourceDBRef); + SequenceI chainseq = pdbSequence; seqs.addElement(chainseq); - AlignmentAnnotation[] chainannot = chainseq.getAnnotation(); if (chainannot != null && visibleChainAnnotation) @@ -185,8 +183,7 @@ public abstract class StructureFile extends AlignFile @SuppressWarnings("unchecked") protected void replaceAndUpdateChains(List prot, - AlignmentI al, - String pep, boolean b) + AlignmentI al, String pep, boolean b) { List> replaced = AlignSeq .replaceMatchingSeqsWith(seqs, annotations, prot, al, pep, @@ -259,8 +256,7 @@ public abstract class StructureFile extends AlignFile } @SuppressWarnings({ "unchecked", "rawtypes" }) - private void processWithJmolParser(List prot) - throws Exception + private void processWithJmolParser(List prot) throws Exception { try { @@ -268,13 +264,11 @@ public abstract class StructureFile extends AlignFile Class cl = Class.forName("jalview.ext.jmol.JmolParser"); if (cl != null) { - final Constructor constructor = cl -.getConstructor(new Class[] { + final Constructor constructor = cl.getConstructor(new Class[] { boolean.class, boolean.class, boolean.class, FileParse.class }); final Object[] args = new Object[] { visibleChainAnnotation, predictSecondaryStructure, externalSecondaryStructure, - new FileParse(getDataName(), - type) }; + new FileParse(getDataName(), type) }; StructureViewSettings.setShowSeqFeatures(false); StructureViewSettings.setVisibleChainAnnotation(false); diff --git a/test/jalview/datamodel/SequenceTest.java b/test/jalview/datamodel/SequenceTest.java index ab11c09..03c4a96 100644 --- a/test/jalview/datamodel/SequenceTest.java +++ b/test/jalview/datamodel/SequenceTest.java @@ -30,10 +30,12 @@ import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals; import jalview.datamodel.PDBEntry.Type; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Vector; +import org.testng.Assert; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -397,7 +399,71 @@ public class SequenceTest sq.setStart(3); sq.setEnd(4); + sq.setDescription("Test sequence description.."); + sq.setVamsasId("TestVamsasId"); + sq.setSourceDBRef(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.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")); + + sq.getDatasetSequence().addDBRef( + new DBRefEntry("PDB", "version1", "1Tst")); + sq.getDatasetSequence().addDBRef( + new DBRefEntry("PDB", "version2", "2Tst")); + sq.getDatasetSequence().addDBRef( + new DBRefEntry("PDB", "version3", "3Tst")); + 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")); + sq.getDatasetSequence().addPDBId( + new PDBEntry("2PDB", "A", Type.MMCIF, "filePath/test2")); + sq.getDatasetSequence().addPDBId( + new PDBEntry("2PDB", "B", Type.MMCIF, "filePath/test2")); + + ArrayList annotsList = new ArrayList(); + System.out.println(">>>>>> " + sq.getSequenceAsString().length()); + annotsList.add(new Annotation("A", "A", 'X', 0.1f)); + annotsList.add(new Annotation("A", "A", 'X', 0.1f)); + Annotation[] annots = annotsList.toArray(new Annotation[0]); + sq.addAlignmentAnnotation(new AlignmentAnnotation("Test annot", + "Test annot description", annots)); + sq.getDatasetSequence().addAlignmentAnnotation( + new AlignmentAnnotation("Test annot", "Test annot description", + annots)); + Assert.assertEquals(sq.getDescription(), "Test sequence description.."); + Assert.assertEquals(sq.getDBRefs().length, 4); + Assert.assertEquals(sq.getAllPDBEntries().size(), 4); + Assert.assertNotNull(sq.getAnnotation()); + Assert.assertEquals(sq.getAnnotation()[0].annotations.length, 2); + Assert.assertEquals(sq.getDatasetSequence().getDBRefs().length, 4); + Assert.assertEquals(sq.getDatasetSequence().getAllPDBEntries().size(), + 4); + Assert.assertNotNull(sq.getDatasetSequence().getAnnotation()); + Sequence derived = (Sequence) sq.deriveSequence(); + + Assert.assertEquals(derived.getDescription(), + "Test sequence description.."); + Assert.assertEquals(derived.getDBRefs().length, 4); + Assert.assertEquals(derived.getAllPDBEntries().size(), 4); + Assert.assertNotNull(derived.getAnnotation()); + Assert.assertEquals(derived.getAnnotation()[0].annotations.length, 2); + Assert.assertEquals(derived.getDatasetSequence().getDBRefs().length, 4); + Assert.assertEquals(derived.getDatasetSequence().getAllPDBEntries() + .size(), 4); + Assert.assertNotNull(derived.getDatasetSequence().getAnnotation()); + assertEquals("CD", derived.getSequenceAsString()); assertSame(sq.getDatasetSequence(), derived.getDatasetSequence()); -- 1.7.10.2