From: Jim Procter Date: Mon, 20 Sep 2021 10:13:12 +0000 (+0100) Subject: JAL-3829 allow PDBEntry with file and ID with mismatching case to override one withou... X-Git-Tag: Release_2_11_2_0~34^2~3^2~12 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=3a8dc0dd7261853a53c7e4c3cde1b6d53d0e3e93;p=jalview.git JAL-3829 allow PDBEntry with file and ID with mismatching case to override one without a file --- diff --git a/src/jalview/datamodel/PDBEntry.java b/src/jalview/datamodel/PDBEntry.java index 672a59e..793fbd7 100755 --- a/src/jalview/datamodel/PDBEntry.java +++ b/src/jalview/datamodel/PDBEntry.java @@ -384,21 +384,37 @@ public class PDBEntry return false; // shouldn't happen } - /* - * id has to match (ignoring case) - */ - if (!getId().equalsIgnoreCase(newId)) - { - return false; - } + boolean idMatches = getId().equalsIgnoreCase(newId); /* * Don't update if associated with different structure files */ String newFile = newEntry.getFile(); - if (newFile != null && getFile() != null && !newFile.equals(getFile())) + if (newFile != null && getFile() != null) { - return false; + if (!newFile.equals(getFile())) + { + return false; + } + else + { + // files match. + if (!idMatches) + { + // this shouldn't happen, but could do if the id from the + // file is not the same as the id from the authority that provided + // the file + return false; + } + } + } + else + { + // one has data, one doesn't .. + if (!idMatches) + { + return false; + } // otherwise maybe can update } /* diff --git a/test/jalview/datamodel/PDBEntryTest.java b/test/jalview/datamodel/PDBEntryTest.java index cf4294e..198cde3 100644 --- a/test/jalview/datamodel/PDBEntryTest.java +++ b/test/jalview/datamodel/PDBEntryTest.java @@ -208,7 +208,7 @@ public class PDBEntryTest assertTrue(pdb1.updateFrom(pdb2)); assertEquals(pdb1.getFile(), "filePath"); assertEquals(pdb1.getType(), Type.FILE.toString()); - + assertEquals(pdb1.getChainCode(),"B"); /* * change of file is not allowed */ diff --git a/test/mc_view/PDBChainTest.java b/test/mc_view/PDBChainTest.java index 14ec1e7..0f748ce 100644 --- a/test/mc_view/PDBChainTest.java +++ b/test/mc_view/PDBChainTest.java @@ -68,7 +68,7 @@ public class PDBChainTest { System.out.println("setup"); StructureImportSettings.setShowSeqFeatures(true); - c = new PDBChain("1GAQ", "A", false); + c = new PDBChain("1GAQ", "A"); } @Test(groups = { "Functional" })