2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.structure;
23 import static org.testng.Assert.assertEquals;
24 import static org.testng.Assert.assertNull;
25 import static org.testng.Assert.fail;
27 import org.testng.annotations.Test;
29 public class AtomSpecTest
32 public void testFromChimeraAtomSpec()
34 AtomSpec as = AtomSpec.fromChimeraAtomspec("#1:12.B");
35 assertEquals(as.getModelNumber(), 1);
36 assertEquals(as.getPdbResNum(), 12);
37 assertEquals(as.getChain(), "B");
38 assertNull(as.getPdbFile());
40 // no model - default to zero
41 as = AtomSpec.fromChimeraAtomspec(":13.C");
42 assertEquals(as.getModelNumber(), 0);
43 assertEquals(as.getPdbResNum(), 13);
44 assertEquals(as.getChain(), "C");
45 assertNull(as.getPdbFile());
48 as = AtomSpec.fromChimeraAtomspec("#3.2:15");
49 assertEquals(as.getModelNumber(), 3);
50 assertEquals(as.getPdbResNum(), 15);
51 assertEquals(as.getChain(), "");
52 assertNull(as.getPdbFile());
54 String spec = "3:12.B";
57 as = AtomSpec.fromChimeraAtomspec(spec);
58 fail("Expected exception for " + spec);
59 } catch (IllegalArgumentException e)
67 as = AtomSpec.fromChimeraAtomspec(spec);
68 fail("Expected exception for " + spec);
69 } catch (IllegalArgumentException e)
77 as = AtomSpec.fromChimeraAtomspec(spec);
78 fail("Expected exception for " + spec);
79 } catch (IllegalArgumentException e)
87 as = AtomSpec.fromChimeraAtomspec(spec);
88 fail("Expected exception for " + spec);
89 } catch (NullPointerException e)
96 public void testFromChimeraXAtomSpec()
98 AtomSpec as = AtomSpec.fromChimeraXAtomspec("#1/B:12");
99 assertEquals(as.getModelNumber(), 1);
100 assertEquals(as.getPdbResNum(), 12);
101 assertEquals(as.getChain(), "B");
102 assertNull(as.getPdbFile());
104 // no model - default to zero
105 as = AtomSpec.fromChimeraXAtomspec("/C:13");
106 assertEquals(as.getModelNumber(), 0);
107 assertEquals(as.getPdbResNum(), 13);
108 assertEquals(as.getChain(), "C");
109 assertNull(as.getPdbFile());
112 as = AtomSpec.fromChimeraXAtomspec("#3.2/:15");
113 assertEquals(as.getModelNumber(), 3);
114 assertEquals(as.getPdbResNum(), 15);
115 assertEquals(as.getChain(), "");
116 assertNull(as.getPdbFile());
118 String spec = "3:12.B";
121 as = AtomSpec.fromChimeraXAtomspec(spec);
122 fail("Expected exception for " + spec);
123 } catch (IllegalArgumentException e)
131 as = AtomSpec.fromChimeraXAtomspec(spec);
132 fail("Expected exception for " + spec);
133 } catch (IllegalArgumentException e)
141 as = AtomSpec.fromChimeraXAtomspec(spec);
142 fail("Expected exception for " + spec);
143 } catch (IllegalArgumentException e)
151 as = AtomSpec.fromChimeraXAtomspec(spec);
152 fail("Expected exception for " + spec);
153 } catch (NullPointerException e)