Clover icon

Coverage Report

  1. Project Clover database Mon Nov 11 2024 15:05:32 GMT
  2. Package jalview.structure

File AtomSpecTest.java

 

Code metrics

0
62
2
1
158
110
10
0.16
31
2
5

Classes

Class Line # Actions
AtomSpecTest 29 62 10
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
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.
11    *
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.
16    *
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.
20    */
21    package jalview.structure;
22   
23    import static org.testng.Assert.assertEquals;
24    import static org.testng.Assert.assertNull;
25    import static org.testng.Assert.fail;
26   
27    import org.testng.annotations.Test;
28   
 
29    public class AtomSpecTest
30    {
 
31  0 toggle @Test
32    public void testFromChimeraAtomSpec()
33    {
34  0 AtomSpec as = AtomSpec.fromChimeraAtomspec("#1:12.B");
35  0 assertEquals(as.getModelNumber(), 1);
36  0 assertEquals(as.getPdbResNum(), 12);
37  0 assertEquals(as.getChain(), "B");
38  0 assertNull(as.getPdbFile());
39   
40    // no model - default to zero
41  0 as = AtomSpec.fromChimeraAtomspec(":13.C");
42  0 assertEquals(as.getModelNumber(), 0);
43  0 assertEquals(as.getPdbResNum(), 13);
44  0 assertEquals(as.getChain(), "C");
45  0 assertNull(as.getPdbFile());
46   
47    // model.submodel
48  0 as = AtomSpec.fromChimeraAtomspec("#3.2:15");
49  0 assertEquals(as.getModelNumber(), 3);
50  0 assertEquals(as.getPdbResNum(), 15);
51  0 assertEquals(as.getChain(), "");
52  0 assertNull(as.getPdbFile());
53   
54  0 String spec = "3:12.B";
55  0 try
56    {
57  0 as = AtomSpec.fromChimeraAtomspec(spec);
58  0 fail("Expected exception for " + spec);
59    } catch (IllegalArgumentException e)
60    {
61    // ok
62    }
63   
64  0 spec = "#3:12-14.B";
65  0 try
66    {
67  0 as = AtomSpec.fromChimeraAtomspec(spec);
68  0 fail("Expected exception for " + spec);
69    } catch (IllegalArgumentException e)
70    {
71    // ok
72    }
73   
74  0 spec = "";
75  0 try
76    {
77  0 as = AtomSpec.fromChimeraAtomspec(spec);
78  0 fail("Expected exception for " + spec);
79    } catch (IllegalArgumentException e)
80    {
81    // ok
82    }
83   
84  0 spec = null;
85  0 try
86    {
87  0 as = AtomSpec.fromChimeraAtomspec(spec);
88  0 fail("Expected exception for " + spec);
89    } catch (NullPointerException e)
90    {
91    // ok
92    }
93    }
94   
 
95  0 toggle @Test
96    public void testFromChimeraXAtomSpec()
97    {
98  0 AtomSpec as = AtomSpec.fromChimeraXAtomspec("#1/B:12");
99  0 assertEquals(as.getModelNumber(), 1);
100  0 assertEquals(as.getPdbResNum(), 12);
101  0 assertEquals(as.getChain(), "B");
102  0 assertNull(as.getPdbFile());
103   
104    // no model - default to zero
105  0 as = AtomSpec.fromChimeraXAtomspec("/C:13");
106  0 assertEquals(as.getModelNumber(), 0);
107  0 assertEquals(as.getPdbResNum(), 13);
108  0 assertEquals(as.getChain(), "C");
109  0 assertNull(as.getPdbFile());
110   
111    // model.submodel
112  0 as = AtomSpec.fromChimeraXAtomspec("#3.2/:15");
113  0 assertEquals(as.getModelNumber(), 3);
114  0 assertEquals(as.getPdbResNum(), 15);
115  0 assertEquals(as.getChain(), "");
116  0 assertNull(as.getPdbFile());
117   
118  0 String spec = "3:12.B";
119  0 try
120    {
121  0 as = AtomSpec.fromChimeraXAtomspec(spec);
122  0 fail("Expected exception for " + spec);
123    } catch (IllegalArgumentException e)
124    {
125    // ok
126    }
127   
128  0 spec = "#3:12-14.B";
129  0 try
130    {
131  0 as = AtomSpec.fromChimeraXAtomspec(spec);
132  0 fail("Expected exception for " + spec);
133    } catch (IllegalArgumentException e)
134    {
135    // ok
136    }
137   
138  0 spec = "";
139  0 try
140    {
141  0 as = AtomSpec.fromChimeraXAtomspec(spec);
142  0 fail("Expected exception for " + spec);
143    } catch (IllegalArgumentException e)
144    {
145    // ok
146    }
147   
148  0 spec = null;
149  0 try
150    {
151  0 as = AtomSpec.fromChimeraXAtomspec(spec);
152  0 fail("Expected exception for " + spec);
153    } catch (NullPointerException e)
154    {
155    // ok
156    }
157    }
158    }