From: gmungoc Date: Mon, 23 Apr 2018 10:26:58 +0000 (+0100) Subject: JAL-2952 set negative TempFactor values as AlignmentAnnotation.graphMin X-Git-Tag: Release_2_10_4~34 X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=commitdiff_plain;h=440874286dccfd6bb9ed668ef6b6599714bbe57f JAL-2952 set negative TempFactor values as AlignmentAnnotation.graphMin --- diff --git a/src/MCview/PDBChain.java b/src/MCview/PDBChain.java index 29b994e..904a860 100755 --- a/src/MCview/PDBChain.java +++ b/src/MCview/PDBChain.java @@ -45,11 +45,11 @@ public class PDBChain public String id; - public Vector bonds = new Vector(); + public Vector bonds = new Vector<>(); - public Vector atoms = new Vector(); + public Vector atoms = new Vector<>(); - public Vector residues = new Vector(); + public Vector residues = new Vector<>(); public int offset; @@ -343,12 +343,13 @@ public class PDBChain boolean deoxyn = false; boolean nucleotide = false; StringBuilder seq = new StringBuilder(256); - Vector resFeatures = new Vector(); - Vector resAnnotation = new Vector(); - int i, iSize = atoms.size() - 1; + Vector resFeatures = new Vector<>(); + Vector resAnnotation = new Vector<>(); + int iSize = atoms.size() - 1; int resNumber = -1; char insCode = ' '; - for (i = 0; i <= iSize; i++) + + for (int i = 0; i <= iSize; i++) { Atom tmp = atoms.elementAt(i); resNumber = tmp.resNumber; @@ -362,7 +363,7 @@ public class PDBChain offset = resNumber; } - Vector resAtoms = new Vector(); + Vector resAtoms = new Vector<>(); // Add atoms to a vector while the residue number // remains the same as the first atom's resNumber (res) while ((resNumber == res) && (ins == insCode) && (i < atoms.size())) @@ -469,7 +470,8 @@ public class PDBChain if (StructureImportSettings.isShowSeqFeatures()) { - for (i = 0, iSize = resFeatures.size(); i < iSize; i++) + iSize = resFeatures.size(); + for (int i = 0; i < iSize; i++) { sequence.addSequenceFeature(resFeatures.elementAt(i)); resFeatures.setElementAt(null, i); @@ -478,20 +480,20 @@ public class PDBChain if (visibleChainAnnotation) { Annotation[] annots = new Annotation[resAnnotation.size()]; - float max = 0; - for (i = 0, iSize = annots.length; i < iSize; i++) + float max = 0f; + float min = 0f; + iSize = annots.length; + for (int i = 0; i < iSize; i++) { annots[i] = resAnnotation.elementAt(i); - if (annots[i].value > max) - { - max = annots[i].value; - } + max = Math.max(max, annots[i].value); + min = Math.min(min, annots[i].value); resAnnotation.setElementAt(null, i); } AlignmentAnnotation tfactorann = new AlignmentAnnotation( "Temperature Factor", "Temperature Factor for " + pdbid + id, - annots, 0, max, AlignmentAnnotation.LINE_GRAPH); + annots, min, max, AlignmentAnnotation.LINE_GRAPH); tfactorann.setSequenceRef(sequence); sequence.addAlignmentAnnotation(tfactorann); } diff --git a/test/MCview/PDBChainTest.java b/test/MCview/PDBChainTest.java index defcdbc..533c0af 100644 --- a/test/MCview/PDBChainTest.java +++ b/test/MCview/PDBChainTest.java @@ -91,7 +91,7 @@ public class PDBChainTest a3.resName = "ASP"; a3.resNumber = 41; - Vector v = new Vector(); + Vector v = new Vector<>(); v.add(new Bond(a1, a2)); v.add(new Bond(a2, a3)); v.add(new Bond(a3, a1)); @@ -234,7 +234,7 @@ public class PDBChainTest @Test(groups = { "Functional" }) public void testMakeResidueList_noAnnotation() { - Vector atoms = new Vector(); + Vector atoms = new Vector<>(); c.atoms = atoms; c.isNa = true; atoms.add(makeAtom(4, "N", "MET")); @@ -292,7 +292,7 @@ public class PDBChainTest @Test(groups = { "Functional" }) public void testMakeResidueList_withTempFactor() { - Vector atoms = new Vector(); + Vector atoms = new Vector<>(); c.atoms = atoms; atoms.add(makeAtom(4, "N", "MET")); atoms.get(atoms.size() - 1).tfactor = 1f; @@ -307,7 +307,7 @@ public class PDBChainTest atoms.add(makeAtom(5, "CA", "LYS")); atoms.get(atoms.size() - 1).tfactor = 9f; atoms.add(makeAtom(6, "O", "LEU")); - atoms.get(atoms.size() - 1).tfactor = 4f; + atoms.get(atoms.size() - 1).tfactor = -4f; atoms.add(makeAtom(6, "N", "LEU")); atoms.get(atoms.size() - 1).tfactor = 5f; atoms.add(makeAtom(6, "CA", "LEU")); @@ -320,7 +320,7 @@ public class PDBChainTest /* * Verify annotations; note the tempFactor is read from the first atom in - * each residue i.e. we expect values 1, 7, 4 for the residues + * each residue i.e. we expect values 1, 7, -4 for the residues */ AlignmentAnnotation[] ann = c.sequence.getAnnotation(); assertEquals(1, ann.length); @@ -328,12 +328,12 @@ public class PDBChainTest assertEquals("Temperature Factor for 1gaqA", ann[0].description); assertSame(c.sequence, ann[0].sequenceRef); assertEquals(AlignmentAnnotation.LINE_GRAPH, ann[0].graph); - assertEquals(0f, ann[0].graphMin, 0.001f); + assertEquals(-4f, ann[0].graphMin, 0.001f); assertEquals(7f, ann[0].graphMax, 0.001f); assertEquals(3, ann[0].annotations.length); assertEquals(1f, ann[0].annotations[0].value, 0.001f); assertEquals(7f, ann[0].annotations[1].value, 0.001f); - assertEquals(4f, ann[0].annotations[2].value, 0.001f); + assertEquals(-4f, ann[0].annotations[2].value, 0.001f); } /** @@ -344,7 +344,7 @@ public class PDBChainTest public void testMakeCaBondList() { c.isNa = true; - Vector atoms = new Vector(); + Vector atoms = new Vector<>(); c.atoms = atoms; atoms.add(makeAtom(4, "N", "MET")); atoms.add(makeAtom(4, "CA", "MET")); @@ -375,7 +375,7 @@ public class PDBChainTest public void testMakeCaBondList_nucleotide() { c.isNa = false; - Vector atoms = new Vector(); + Vector atoms = new Vector<>(); c.atoms = atoms; atoms.add(makeAtom(4, "N", "G")); atoms.add(makeAtom(4, "P", "G")); @@ -406,7 +406,7 @@ public class PDBChainTest @Test(groups = { "Functional" }) public void testMakeExactMapping() { - Vector atoms = new Vector(); + Vector atoms = new Vector<>(); c.atoms = atoms; atoms.add(makeAtom(4, "N", "MET")); atoms.add(makeAtom(4, "CA", "MET"));