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.
23 import static org.testng.AssertJUnit.assertEquals;
25 import org.testng.Assert;
26 import org.testng.annotations.Test;
32 * Test the constructor that parses a PDB file format ATOM line. Fields are in
33 * fixed column positions
35 @Test(groups = { "Functional" })
36 public void testStringConstructor()
39 "ATOM 349 NE2 GLN A 48 22.290 8.595 17.680 1.00 14.30 N");
40 assertEquals(349, a.atomIndex);
41 assertEquals("NE", a.name);
42 assertEquals("GLN", a.resName);
43 assertEquals("A", a.chain);
44 assertEquals(48, a.resNumber);
45 assertEquals("48", a.resNumIns);
46 assertEquals(' ', a.insCode);
47 assertEquals(22.290, a.x, 0.00001);
48 assertEquals(8.595, a.y, 0.00001);
49 assertEquals(17.680, a.z, 0.00001);
50 assertEquals(1f, a.occupancy, 0.00001);
51 assertEquals(14.3, a.tfactor, 0.00001);
55 * Test the case where occupancy and temp factor are blank - should default to
58 @Test(groups = { "Functional" })
59 public void testStringConstructor_blankOccupancyTempFactor()
62 "ATOM 349 NE2 GLN A 48 22.290 8.595 17.680 N");
63 assertEquals(1f, a.occupancy, 0.00001);
64 assertEquals(1f, a.tfactor, 0.00001);
68 * Parsing non-numeric data as Atom throws an exception
70 @Test(groups = { "Functional" })
71 public void testStringConstructor_malformed()
76 "ATOM 34N NE2 GLN A 48 22.290 8.595 17.680 1.00 14.30 N");
77 Assert.fail("Expected exception");
78 } catch (NumberFormatException e)