|
24 | 24 |
|
25 | 25 | import java.io.InputStream;
|
26 | 26 | import java.io.StringReader;
|
| 27 | +import java.util.ArrayList; |
27 | 28 | import java.util.Collection;
|
28 | 29 | import java.util.Iterator;
|
| 30 | +import java.util.List; |
29 | 31 |
|
30 | 32 | import org.junit.Assert;
|
31 | 33 | import org.junit.BeforeClass;
|
@@ -251,18 +253,24 @@ public IChemFile getChemFile(String filename) throws Exception {
|
251 | 253 | }
|
252 | 254 |
|
253 | 255 | public IChemFile getChemFile(ISimpleChemObjectReader reader) throws Exception {
|
254 |
| - return getChemFile(reader, false); |
| 256 | + return getChemFile(reader, false, false); |
255 | 257 | }
|
256 | 258 |
|
257 | 259 | public IChemFile getChemFile(String filename, boolean useRebond) throws Exception {
|
258 | 260 | InputStream ins = this.getClass().getResourceAsStream(filename);
|
259 |
| - return getChemFile(new PDBReader(ins), useRebond); |
| 261 | + return getChemFile(new PDBReader(ins), useRebond, false); |
260 | 262 | }
|
261 | 263 |
|
262 |
| - public IChemFile getChemFile(ISimpleChemObjectReader reader, boolean useRebond) throws Exception { |
| 264 | + public IChemFile getChemFile(String filename, boolean useRebond, boolean useHetAtmDict) throws Exception { |
| 265 | + InputStream ins = this.getClass().getResourceAsStream(filename); |
| 266 | + return getChemFile(new PDBReader(ins), useRebond, useHetAtmDict); |
| 267 | + } |
| 268 | + |
| 269 | + public IChemFile getChemFile(ISimpleChemObjectReader reader, boolean useRebond, boolean useHetAtmDict) throws Exception { |
263 | 270 | Assert.assertNotNull(reader);
|
264 | 271 |
|
265 | 272 | reader.getSetting("UseRebondTool").setSetting(String.valueOf(useRebond));
|
| 273 | + reader.getSetting("UseHetDictionary").setSetting(String.valueOf(useHetAtmDict)); |
266 | 274 |
|
267 | 275 | IChemFile chemFile = (IChemFile) reader.read(new ChemFile());
|
268 | 276 | Assert.assertNotNull(chemFile);
|
@@ -417,6 +425,32 @@ public void test1TOH() throws Exception {
|
417 | 425 | testObjectCountsChemFile(chemFile, 1, 1, 1, 2804, 1, 325, 23);
|
418 | 426 | }
|
419 | 427 |
|
| 428 | + public void assertHetAtmTypes(IChemFile chemFile, |
| 429 | + String resName, |
| 430 | + String ... expected) |
| 431 | + { |
| 432 | + List<String> actual = new ArrayList<>(); |
| 433 | + for (IAtomContainer mol : ChemFileManipulator.getAllAtomContainers(chemFile)) { |
| 434 | + for (IAtom atom : mol.atoms()) { |
| 435 | + if (((IPDBAtom)atom).getResName().equals(resName)) |
| 436 | + actual.add(atom.getAtomTypeName()); |
| 437 | + } |
| 438 | + } |
| 439 | + Assert.assertArrayEquals("Unexpected HETATOM types for res=" + resName + " was=" + actual, |
| 440 | + expected, actual.toArray(new String[0])); |
| 441 | + } |
| 442 | + |
| 443 | + @Test |
| 444 | + public void test3PTY() throws Exception { |
| 445 | + String filename = "3PTY.pdb"; |
| 446 | + IChemFile chemFile = getChemFile(filename, false, true); |
| 447 | + testObjectCountsChemFile(chemFile, 1, 1, 1, 2258, 1, 284, 32); |
| 448 | + assertHetAtmTypes(chemFile, |
| 449 | + "AFO", |
| 450 | + "C.sp3", "O.sp3", "C.sp3", "O.sp3", "C.sp3", "O.sp3", "C.sp3", "O.sp3", "C.sp3", "O.sp3", |
| 451 | + "C.sp3", "C.sp3", "C.sp3", "C.sp3", "C.sp3", "C.sp3", "C.sp3", "C.sp3"); |
| 452 | + } |
| 453 | + |
420 | 454 | @Category(SlowTest.class)
|
421 | 455 | @Test
|
422 | 456 | public void test1CKV() throws Exception {
|
|
0 commit comments