X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fstructure%2FAtomSpecTest.java;h=ff6e6cbe866b2ecd77dea941a2bb5301d45ff60c;hb=34567bb79dfa8f163f44c3f3448083fcd145f308;hp=ea53131c7cb30bdb089f8b7b80955d65ea086f8b;hpb=f4a2cccc2d31e80c19af722d57d80591f8c7aa76;p=jalview.git diff --git a/test/jalview/structure/AtomSpecTest.java b/test/jalview/structure/AtomSpecTest.java index ea53131..ff6e6cb 100644 --- a/test/jalview/structure/AtomSpecTest.java +++ b/test/jalview/structure/AtomSpecTest.java @@ -9,23 +9,23 @@ import org.testng.annotations.Test; public class AtomSpecTest { @Test - public void testFromChimeraAtomSpec() + public void testFromChimeraAtomSpec_chimera() { - AtomSpec as = AtomSpec.fromChimeraAtomspec("#1:12.B"); + AtomSpec as = AtomSpec.fromChimeraAtomspec("#1:12.B", false); assertEquals(as.getModelNumber(), 1); assertEquals(as.getPdbResNum(), 12); assertEquals(as.getChain(), "B"); assertNull(as.getPdbFile()); // no model - default to zero - as = AtomSpec.fromChimeraAtomspec(":13.C"); + as = AtomSpec.fromChimeraAtomspec(":13.C", false); assertEquals(as.getModelNumber(), 0); assertEquals(as.getPdbResNum(), 13); assertEquals(as.getChain(), "C"); assertNull(as.getPdbFile()); // model.submodel - as = AtomSpec.fromChimeraAtomspec("#3.2:15"); + as = AtomSpec.fromChimeraAtomspec("#3.2:15", false); assertEquals(as.getModelNumber(), 3); assertEquals(as.getPdbResNum(), 15); assertEquals(as.getChain(), ""); @@ -34,7 +34,7 @@ public class AtomSpecTest String spec = "3:12.B"; try { - as = AtomSpec.fromChimeraAtomspec(spec); + as = AtomSpec.fromChimeraAtomspec(spec, false); fail("Expected exception for " + spec); } catch (IllegalArgumentException e) { @@ -44,7 +44,7 @@ public class AtomSpecTest spec = "#3:12-14.B"; try { - as = AtomSpec.fromChimeraAtomspec(spec); + as = AtomSpec.fromChimeraAtomspec(spec, false); fail("Expected exception for " + spec); } catch (IllegalArgumentException e) { @@ -54,7 +54,7 @@ public class AtomSpecTest spec = ""; try { - as = AtomSpec.fromChimeraAtomspec(spec); + as = AtomSpec.fromChimeraAtomspec(spec, false); fail("Expected exception for " + spec); } catch (IllegalArgumentException e) { @@ -64,7 +64,71 @@ public class AtomSpecTest spec = null; try { - as = AtomSpec.fromChimeraAtomspec(spec); + as = AtomSpec.fromChimeraAtomspec(spec, false); + fail("Expected exception for " + spec); + } catch (NullPointerException e) + { + // ok + } + } + + @Test + public void testFromChimeraAtomSpec_chimeraX() + { + AtomSpec as = AtomSpec.fromChimeraAtomspec("#1/B:12", true); + assertEquals(as.getModelNumber(), 1); + assertEquals(as.getPdbResNum(), 12); + assertEquals(as.getChain(), "B"); + assertNull(as.getPdbFile()); + + // no model - default to zero + as = AtomSpec.fromChimeraAtomspec("/C:13", true); + assertEquals(as.getModelNumber(), 0); + assertEquals(as.getPdbResNum(), 13); + assertEquals(as.getChain(), "C"); + assertNull(as.getPdbFile()); + + // model.submodel + as = AtomSpec.fromChimeraAtomspec("#3.2/:15", true); + assertEquals(as.getModelNumber(), 3); + assertEquals(as.getPdbResNum(), 15); + assertEquals(as.getChain(), ""); + assertNull(as.getPdbFile()); + + String spec = "3:12.B"; + try + { + as = AtomSpec.fromChimeraAtomspec(spec, true); + fail("Expected exception for " + spec); + } catch (IllegalArgumentException e) + { + // ok + } + + spec = "#3:12-14.B"; + try + { + as = AtomSpec.fromChimeraAtomspec(spec, true); + fail("Expected exception for " + spec); + } catch (IllegalArgumentException e) + { + // ok + } + + spec = ""; + try + { + as = AtomSpec.fromChimeraAtomspec(spec, true); + fail("Expected exception for " + spec); + } catch (IllegalArgumentException e) + { + // ok + } + + spec = null; + try + { + as = AtomSpec.fromChimeraAtomspec(spec, true); fail("Expected exception for " + spec); } catch (NullPointerException e) {