From b8f13fd9ac44853d6510eac85edb60b117dc4620 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Wed, 13 May 2015 10:39:33 +0100 Subject: [PATCH] JAL-1712 fixes/tests for Castor binding of EMBL XML / show flanking region --- src/jalview/datamodel/PDBEntry.java | 2 +- src/jalview/io/AlignFile.java | 34 +++++++++++------------- test/jalview/analysis/AlignmentUtilsTests.java | 13 ++++----- test/jalview/io/AnnotatedPDBFileInputTest.java | 22 +++++++-------- 4 files changed, 32 insertions(+), 39 deletions(-) diff --git a/src/jalview/datamodel/PDBEntry.java b/src/jalview/datamodel/PDBEntry.java index 98c78fc..36ffdf3 100755 --- a/src/jalview/datamodel/PDBEntry.java +++ b/src/jalview/datamodel/PDBEntry.java @@ -131,7 +131,7 @@ public class PDBEntry } public void setType(PDBEntry.Type type) { - this.type = type.toString(); + this.type = type == null ? null : type.toString(); } public String getType() diff --git a/src/jalview/io/AlignFile.java b/src/jalview/io/AlignFile.java index b2f8b2b..5d8a297 100755 --- a/src/jalview/io/AlignFile.java +++ b/src/jalview/io/AlignFile.java @@ -20,6 +20,13 @@ */ package jalview.io; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.List; +import java.util.Vector; + import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; @@ -28,13 +35,6 @@ import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; import jalview.util.MessageManager; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.List; -import java.util.Vector; - /** * DOCUMENT ME! * @@ -188,7 +188,7 @@ public abstract class AlignFile extends FileParse for (int i = 0; i < seqs.size(); i++) { - s[i] = (SequenceI) seqs.elementAt(i); + s[i] = seqs.elementAt(i); } return s; @@ -212,7 +212,7 @@ public abstract class AlignFile extends FileParse * Rna.GetBasePairsFromAlignmentAnnotation(annotations.elementAt(i)); * Rna.HelixMap(pairArray); */ - AlignmentAnnotation an = (AlignmentAnnotation) annotations + AlignmentAnnotation an = annotations .elementAt(i); an.validateRangeAndDisplay(); al.addAnnotation(an); @@ -287,8 +287,8 @@ public abstract class AlignFile extends FileParse */ protected void initData() { - seqs = new Vector(); - annotations = new Vector(); + seqs = new Vector(); + annotations = new Vector(); seqGroups = new ArrayList(); parseCalled=false; } @@ -301,7 +301,7 @@ public abstract class AlignFile extends FileParse */ protected void setSeqs(SequenceI[] s) { - seqs = new Vector(); + seqs = new Vector(); for (int i = 0; i < s.length; i++) { @@ -361,13 +361,13 @@ public abstract class AlignFile extends FileParse /** * vector of String[] treeName, newickString pairs */ - Vector newickStrings = null; + Vector newickStrings = null; protected void addNewickTree(String treeName, String newickString) { if (newickStrings == null) { - newickStrings = new Vector(); + newickStrings = new Vector(); } newickStrings.addElement(new String[] { treeName, newickString }); @@ -375,11 +375,7 @@ public abstract class AlignFile extends FileParse protected int getTreeCount() { - if (newickStrings == null) - { - return 0; - } - return newickStrings.size(); + return newickStrings == null ? 0 : newickStrings.size(); } } diff --git a/test/jalview/analysis/AlignmentUtilsTests.java b/test/jalview/analysis/AlignmentUtilsTests.java index 6c06955..02955f1 100644 --- a/test/jalview/analysis/AlignmentUtilsTests.java +++ b/test/jalview/analysis/AlignmentUtilsTests.java @@ -195,9 +195,7 @@ public class AlignmentUtilsTests * Expand the subsequence to the full sequence abcDEFghi */ AlignmentI expanded = AlignmentUtils.expandContext(al, -1); - // FIXME expandContext adds an unnecessary gap; need tests to cover all - // cases for which 'maxOffset' is computed - assertEquals("-abcDEFghi", expanded.getSequenceAt(0) + assertEquals("abcDEFghi", expanded.getSequenceAt(0) .getSequenceAsString()); /* @@ -215,13 +213,12 @@ public class AlignmentUtilsTests assertNull(ann.annotations[0]); assertNull(ann.annotations[1]); assertNull(ann.annotations[2]); - assertNull(ann.annotations[3]); - assertEquals(4, ann.annotations[4].value, 0.001); - assertEquals(5, ann.annotations[5].value, 0.001); - assertEquals(6, ann.annotations[6].value, 0.001); + assertEquals(4, ann.annotations[3].value, 0.001); + assertEquals(5, ann.annotations[4].value, 0.001); + assertEquals(6, ann.annotations[5].value, 0.001); + assertNull(ann.annotations[6]); assertNull(ann.annotations[7]); assertNull(ann.annotations[8]); - assertNull(ann.annotations[9]); /* * sequence position mappings should be unchanged diff --git a/test/jalview/io/AnnotatedPDBFileInputTest.java b/test/jalview/io/AnnotatedPDBFileInputTest.java index 29d5549..6a61d2c 100644 --- a/test/jalview/io/AnnotatedPDBFileInputTest.java +++ b/test/jalview/io/AnnotatedPDBFileInputTest.java @@ -4,6 +4,14 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; + +import java.io.File; + +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.PDBEntry; @@ -14,14 +22,6 @@ import jalview.gui.Desktop; import jalview.structure.StructureMapping; import jalview.structure.StructureSelectionManager; -import java.io.File; -import java.util.Vector; - -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - public class AnnotatedPDBFileInputTest { @@ -38,8 +38,8 @@ public class AnnotatedPDBFileInputTest AlignFrame af = loader.LoadFileWaitTillLoaded(pdbStr, FormatAdapter.FILE); al = af.getViewport().getAlignment(); - pdbId = ((PDBEntry) al.getSequenceAt(0).getDatasetSequence().getPDBId() - .get(0)).getId(); + pdbId = al.getSequenceAt(0).getDatasetSequence().getPDBId() + .get(0).getId(); } @Test @@ -194,7 +194,7 @@ public class AnnotatedPDBFileInputTest } assertNotNull(sq.getPDBId()); assertEquals("Expected only one PDB ID", sq.getPDBId().size(), 1); - for (PDBEntry pdbentry : (Vector) sq.getPDBId()) + for (PDBEntry pdbentry : sq.getPDBId()) { System.err.println("PDB Entry " + pdbentry.getId() + " " + pdbentry.getFile()); -- 1.7.10.2