From 7f7f02ea0804ccff0f891f83b05662ab484cf6f1 Mon Sep 17 00:00:00 2001 From: tcofoegbu Date: Mon, 15 Aug 2016 14:53:58 +0100 Subject: [PATCH] JAL-1919 Added improvement to ensure consistence of annotations parsed via JmolParser vs PDBfile parser and fixed unit tests accordingly --- src/MCview/Atom.java | 2 +- src/jalview/ext/jmol/JmolParser.java | 3 ++- test/MCview/AtomTest.java | 2 +- test/jalview/io/AnnotatedPDBFileInputTest.java | 20 ++++++++++++-------- .../structure/StructureSelectionManagerTest.java | 4 ++-- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/MCview/Atom.java b/src/MCview/Atom.java index ab038a0..fe6a0ac 100755 --- a/src/MCview/Atom.java +++ b/src/MCview/Atom.java @@ -81,7 +81,7 @@ public class Atom chain = str.substring(21, 22); resNumber = Integer.parseInt(str.substring(22, 26).trim()); - resNumIns = str.substring(22, 27); + resNumIns = str.substring(22, 27).trim(); insCode = str.substring(26, 27).charAt(0); this.x = (new Float(str.substring(30, 38).trim()).floatValue()); this.y = (new Float(str.substring(38, 46).trim()).floatValue()); diff --git a/src/jalview/ext/jmol/JmolParser.java b/src/jalview/ext/jmol/JmolParser.java index ea969ff..848e7db 100644 --- a/src/jalview/ext/jmol/JmolParser.java +++ b/src/jalview/ext/jmol/JmolParser.java @@ -217,7 +217,8 @@ public class JmolParser extends StructureFile implements JmolStatusListener curAtom.resNumber = atom.getResno(); curAtom.occupancy = ms.occupancies != null ? ms.occupancies[atom .getIndex()] : Float.valueOf(atom.getOccupancy100()); - curAtom.resNumIns = "" + curAtom.resNumber + curAtom.insCode; + curAtom.resNumIns = ("" + curAtom.resNumber + curAtom.insCode) + .trim(); curAtom.tfactor = atom.getBfactor100() / 100f; curAtom.type = 0; // significantAtoms.add(curAtom); diff --git a/test/MCview/AtomTest.java b/test/MCview/AtomTest.java index 33d332a..21a79fe 100644 --- a/test/MCview/AtomTest.java +++ b/test/MCview/AtomTest.java @@ -42,7 +42,7 @@ public class AtomTest assertEquals("GLN", a.resName); assertEquals("A", a.chain); assertEquals(48, a.resNumber); - assertEquals(" 48 ", a.resNumIns); + assertEquals("48", a.resNumIns); assertEquals(' ', a.insCode); assertEquals(22.290, a.x, 0.00001); assertEquals(8.595, a.y, 0.00001); diff --git a/test/jalview/io/AnnotatedPDBFileInputTest.java b/test/jalview/io/AnnotatedPDBFileInputTest.java index e6019aa..d3d9ff8 100644 --- a/test/jalview/io/AnnotatedPDBFileInputTest.java +++ b/test/jalview/io/AnnotatedPDBFileInputTest.java @@ -68,8 +68,8 @@ public class AnnotatedPDBFileInputTest pdbId = al.getSequenceAt(0).getDatasetSequence().getAllPDBEntries() .get(0).getId(); StructureImportSettings.setDefaultStructureFileFormat("PDB"); - StructureImportSettings - .setDefaultPDBFileParser(StructureParser.JALVIEW_PARSER); + // StructureImportSettings + // .setDefaultPDBFileParser(StructureParser.JALVIEW_PARSER); } @Test(groups = { "Functional" }) @@ -101,7 +101,11 @@ public class AnnotatedPDBFileInputTest { System.out.println("CalcId: " + aa.getCalcId()); + if (StructureImportSettings.getDefaultPDBFileParser().equals( + StructureParser.JALVIEW_PARSER)) + { assertTrue(MCview.PDBfile.isCalcIdForFile(aa, pdbId)); + } } } } @@ -118,9 +122,9 @@ public class AnnotatedPDBFileInputTest SequenceFeature[] sf = al.getSequenceAt(0).getSequenceFeatures(); assertEquals(296, sf.length); assertEquals("RESNUM", sf[0].getType()); - assertEquals("GLU: 19 1gaqA", sf[0].getDescription()); + assertEquals("GLU:19 1gaqA", sf[0].getDescription()); assertEquals("RESNUM", sf[295].getType()); - assertEquals("TYR: 314 1gaqA", sf[295].getDescription()); + assertEquals("TYR:314 1gaqA", sf[295].getDescription()); /* * 1GAQ/B @@ -128,9 +132,9 @@ public class AnnotatedPDBFileInputTest sf = al.getSequenceAt(1).getSequenceFeatures(); assertEquals(98, sf.length); assertEquals("RESNUM", sf[0].getType()); - assertEquals("ALA: 1 1gaqB", sf[0].getDescription()); + assertEquals("ALA:1 1gaqB", sf[0].getDescription()); assertEquals("RESNUM", sf[97].getType()); - assertEquals("ALA: 98 1gaqB", sf[97].getDescription()); + assertEquals("ALA:98 1gaqB", sf[97].getDescription()); /* * 1GAQ/C @@ -138,9 +142,9 @@ public class AnnotatedPDBFileInputTest sf = al.getSequenceAt(2).getSequenceFeatures(); assertEquals(296, sf.length); assertEquals("RESNUM", sf[0].getType()); - assertEquals("GLU: 19 1gaqC", sf[0].getDescription()); + assertEquals("GLU:19 1gaqC", sf[0].getDescription()); assertEquals("RESNUM", sf[295].getType()); - assertEquals("TYR: 314 1gaqC", sf[295].getDescription()); + assertEquals("TYR:314 1gaqC", sf[295].getDescription()); } @Test(groups = { "Functional" }) diff --git a/test/jalview/structure/StructureSelectionManagerTest.java b/test/jalview/structure/StructureSelectionManagerTest.java index 2074fb4..baaa96b 100644 --- a/test/jalview/structure/StructureSelectionManagerTest.java +++ b/test/jalview/structure/StructureSelectionManagerTest.java @@ -138,7 +138,7 @@ public class StructureSelectionManagerTest SequenceFeature sf = pmap.getSeqs().get(0).getSequenceFeatures()[0]; assertEquals("RESNUM", sf.getType()); assertEquals("1gaq", sf.getFeatureGroup()); - assertEquals("GLU: 19 1gaqA", sf.getDescription()); + assertEquals("GLU:19 1gaqA", sf.getDescription()); /* * Verify a RESNUM sequence feature in the StructureSelectionManager mapped @@ -148,6 +148,6 @@ public class StructureSelectionManagerTest sf = map.sequence.getSequenceFeatures()[0]; assertEquals("RESNUM", sf.getType()); assertEquals("1gaq", sf.getFeatureGroup()); - assertEquals("ALA: 1 1gaqB", sf.getDescription()); + assertEquals("ALA:1 1gaqB", sf.getDescription()); } } -- 1.7.10.2