From 09da3ad08ff2e25e67e3f4a08ae4644660eebd72 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Mon, 6 Oct 2014 12:24:14 +0100 Subject: [PATCH] JAL-654 format and refactor test demonstrating PDB secondary structure on alignment not properly linked to alignment sequence --- test/jalview/ext/jmol/PDBFileWithJmolTest.java | 52 ++++++++++++++++-------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/test/jalview/ext/jmol/PDBFileWithJmolTest.java b/test/jalview/ext/jmol/PDBFileWithJmolTest.java index ef14287..d561acb 100644 --- a/test/jalview/ext/jmol/PDBFileWithJmolTest.java +++ b/test/jalview/ext/jmol/PDBFileWithJmolTest.java @@ -40,17 +40,23 @@ import org.junit.Test; public class PDBFileWithJmolTest { String[] testFile = new String[] - { "./examples/1GAQ.txt" }; // , "./examples/DNMT1_MOUSE.pdb" }; + { "./examples/1GAQ.txt" }; // , + + // "./examples/DNMT1_MOUSE.pdb" + // }; @Test - public void testAlignmentLoader() throws Exception - { - for (String f:testFile) { + public void testAlignmentLoader() throws Exception + { + for (String f : testFile) + { FileLoader fl = new jalview.io.FileLoader(false); - AlignFrame af = fl.LoadFileWaitTillLoaded(f, AppletFormatAdapter.FILE); + AlignFrame af = fl + .LoadFileWaitTillLoaded(f, AppletFormatAdapter.FILE); validateSecStrRows(af.getViewport().getAlignment()); } - } + } + @Test public void testFileParser() throws Exception { @@ -76,26 +82,36 @@ public class PDBFileWithJmolTest private void validateSecStrRows(AlignmentI al) { - if (!al.isNucleotide()) { for (SequenceI asq : al.getSequences()) { SequenceI sq = asq; - while (sq.getDatasetSequence()!=null && sq.getAnnotation()==null) + boolean hasDs = false; + while (sq.getDatasetSequence() != null + && sq.getAnnotation() == null) { - sq = asq.getDatasetSequence(); + sq = sq.getDatasetSequence(); + hasDs = true; + } + checkFirstAAIsAssoc(sq); + if (hasDs) + { + // also verify if alignment sequence has annotation on it + // that is correctly mapped + checkFirstAAIsAssoc(asq); } - assertTrue( - "No secondary structure assigned for protein sequence.", - sq.getAnnotation() != null - && sq.getAnnotation().length >= 1 - && sq.getAnnotation()[0].hasIcons); - assertTrue( - "Secondary structure not associated for sequence " - + sq.getName(), - sq.getAnnotation()[0].sequenceRef == sq); } } } + + private void checkFirstAAIsAssoc(SequenceI sq) + { + assertTrue("No secondary structure assigned for protein sequence.", + sq.getAnnotation() != null && sq.getAnnotation().length >= 1 + && sq.getAnnotation()[0].hasIcons); + assertTrue( + "Secondary structure not associated for sequence " + + sq.getName(), sq.getAnnotation()[0].sequenceRef == sq); + } } -- 1.7.10.2