From: gmungoc Date: Fri, 28 Apr 2017 09:06:58 +0000 (+0100) Subject: JAL-2434 use a constant for StructureMapping.NO_CHAIN (space) X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;ds=sidebyside;h=27a5a96f40f4721c9b9024938547a997dbf16cf4;p=jalview.git JAL-2434 use a constant for StructureMapping.NO_CHAIN (space) --- diff --git a/examples/testdata/phyre2results/56da5616b4559c93/c1krhA_.1.fasta b/examples/testdata/phyre2results/56da5616b4559c93/c1krhA_.16.fasta similarity index 100% rename from examples/testdata/phyre2results/56da5616b4559c93/c1krhA_.1.fasta rename to examples/testdata/phyre2results/56da5616b4559c93/c1krhA_.16.fasta diff --git a/src/jalview/structure/AtomSpec.java b/src/jalview/structure/AtomSpec.java index f20cd31..54e2261 100644 --- a/src/jalview/structure/AtomSpec.java +++ b/src/jalview/structure/AtomSpec.java @@ -88,8 +88,12 @@ public class AtomSpec throw new IllegalArgumentException(spec); } - String chainId = dotPos == -1 ? "" : residueChain.substring(dotPos + 1); - + String chainId = dotPos == -1 ? " " : residueChain + .substring(dotPos + 1); + if (chainId.length() == 0) + { + chainId = " "; + } return new AtomSpec(modelId, chainId, resNum, 0); } diff --git a/src/jalview/structure/StructureMapping.java b/src/jalview/structure/StructureMapping.java index 40789ed..d6eb1eb 100644 --- a/src/jalview/structure/StructureMapping.java +++ b/src/jalview/structure/StructureMapping.java @@ -29,6 +29,12 @@ import java.util.List; public class StructureMapping { + /** + * Space character constant, recommended for consistent representation when no + * chain specified + */ + public static String NO_CHAIN = " "; + String mappingDetails; SequenceI sequence; @@ -243,8 +249,4 @@ public class StructureMapping return mappingDetails; } - public HashMap getMapping() - { - return mapping; - } } diff --git a/src/jalview/structure/StructureSelectionManager.java b/src/jalview/structure/StructureSelectionManager.java index c91317e..d1593df 100644 --- a/src/jalview/structure/StructureSelectionManager.java +++ b/src/jalview/structure/StructureSelectionManager.java @@ -454,7 +454,7 @@ public class StructureSelectionManager { if (targetChainId.trim().length() == 0) { - targetChainId = " "; + targetChainId = StructureMapping.NO_CHAIN; } else { @@ -474,7 +474,7 @@ public class StructureSelectionManager */ int max = -10; AlignSeq maxAlignseq = null; - String maxChainId = " "; + String maxChainId = StructureMapping.NO_CHAIN; // space PDBChain maxChain = null; boolean first = true; for (PDBChain chain : pdb.getChains()) @@ -602,7 +602,8 @@ public class StructureSelectionManager .getString("status.obtaining_mapping_with_phyre2_template_alignment")); String fastaFile = getPhyre2FastaFileFor(pdbFile); StructureMapping phyre2ModelMapping = new Phyre2Client(pdb) - .getStructureMapping(seq, pdbFile, fastaFile, " "); + .getStructureMapping(seq, pdbFile, fastaFile, + StructureMapping.NO_CHAIN); seqToStrucMapping.add(phyre2ModelMapping); maxChain.makeExactMapping(maxAlignseq, seq); maxChain.transferRESNUMFeatures(seq, null); diff --git a/test/jalview/structure/AtomSpecTest.java b/test/jalview/structure/AtomSpecTest.java index ea53131..2494555 100644 --- a/test/jalview/structure/AtomSpecTest.java +++ b/test/jalview/structure/AtomSpecTest.java @@ -28,7 +28,7 @@ public class AtomSpecTest as = AtomSpec.fromChimeraAtomspec("#3.2:15"); assertEquals(as.getModelNumber(), 3); assertEquals(as.getPdbResNum(), 15); - assertEquals(as.getChain(), ""); + assertEquals(as.getChain(), StructureMapping.NO_CHAIN); // space assertNull(as.getPdbFile()); String spec = "3:12.B"; diff --git a/test/jalview/ws/sifts/SiftsClientTest.java b/test/jalview/ws/sifts/SiftsClientTest.java index fc07749..fc59241 100644 --- a/test/jalview/ws/sifts/SiftsClientTest.java +++ b/test/jalview/ws/sifts/SiftsClientTest.java @@ -42,6 +42,8 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import junit.extensions.PA; + import org.testng.Assert; import org.testng.FileAssert; import org.testng.annotations.AfterTest; @@ -417,16 +419,19 @@ groups = { "Network" }, // Can't do Assert.assertEquals(strucMapping.getMapping(), expectedMapping); // because this fails in our version of TestNG - Assert.assertEquals(strucMapping.getMapping().size(), + Map mapping = (Map) PA.getValue( + strucMapping, "mapping"); + Assert.assertEquals( + mapping.size(), expectedMapping.size()); Iterator> it = expectedMapping.entrySet() .iterator(); while (it.hasNext()) { Map.Entry pair = it.next(); - Assert.assertTrue(strucMapping.getMapping() + Assert.assertTrue(mapping .containsKey(pair.getKey())); - Assert.assertEquals(strucMapping.getMapping().get(pair.getKey()), + Assert.assertEquals(mapping.get(pair.getKey()), pair.getValue()); } }