|
| 1 | +package org.biojava.nbio.structure.io.mmcif; |
| 2 | + |
| 3 | +import static org.junit.Assert.assertEquals; |
| 4 | + |
| 5 | +import java.io.IOException; |
| 6 | +import org.biojava.nbio.structure.PDBHeader; |
| 7 | +import org.biojava.nbio.structure.Structure; |
| 8 | +import org.biojava.nbio.structure.StructureException; |
| 9 | +import org.biojava.nbio.structure.StructureIO; |
| 10 | +import org.biojava.nbio.structure.align.util.AtomCache; |
| 11 | +import org.junit.Ignore; |
| 12 | +import org.junit.Test; |
| 13 | + |
| 14 | +/** |
| 15 | + * Test parsing header information from MmCif files. |
| 16 | + * |
| 17 | + * @author Anthony Bradley |
| 18 | + * @author Aleix Lafita |
| 19 | + * |
| 20 | + */ |
| 21 | +public class TestParseMmcifHeader { |
| 22 | + |
| 23 | + /** |
| 24 | + * Test we can parse R-work and R-free effectively. |
| 25 | + */ |
| 26 | + @Test |
| 27 | + public void testRfactors() throws IOException, StructureException { |
| 28 | + |
| 29 | + AtomCache atomCache = new AtomCache(); |
| 30 | + atomCache.setUseMmCif(true); |
| 31 | + |
| 32 | + Structure structure = atomCache.getStructure("4cup"); |
| 33 | + |
| 34 | + PDBHeader pdbHeader = structure.getPDBHeader(); |
| 35 | + // Check they are the same |
| 36 | + assertEquals(pdbHeader.getRfree(), 0.2078f, 0.000001f); |
| 37 | + assertEquals(pdbHeader.getRwork(), 0.1763f, 0.000001f); |
| 38 | + |
| 39 | + } |
| 40 | + |
| 41 | + /** |
| 42 | + * Test parsing dates from MMCIF file version 4. |
| 43 | + */ |
| 44 | + @Test |
| 45 | + public void testDatesV4() throws IOException, StructureException { |
| 46 | + |
| 47 | + ClassLoader classLoader = this.getClass().getClassLoader(); |
| 48 | + String file4 = classLoader.getResource("org/biojava/nbio/structure/io/mmcif/1stp_v4.cif").getPath(); |
| 49 | + |
| 50 | + Structure s = StructureIO.getStructure(file4); |
| 51 | + |
| 52 | + // The latest modified year should be 2011 |
| 53 | + assertEquals(s.getPDBHeader().getModDate().getYear() + 1900, 2011); |
| 54 | + |
| 55 | + // The release date should be october 1992 |
| 56 | + assertEquals(s.getPDBHeader().getRelDate().getMonth() + 1, 10); |
| 57 | + assertEquals(s.getPDBHeader().getRelDate().getYear() + 1900, 1992); |
| 58 | + |
| 59 | + // The deposition date should be march 1992 |
| 60 | + assertEquals(s.getPDBHeader().getDepDate().getMonth() + 1, 3); |
| 61 | + assertEquals(s.getPDBHeader().getDepDate().getYear() + 1900, 1992); |
| 62 | + |
| 63 | + } |
| 64 | + |
| 65 | + /** |
| 66 | + * Test parsing dates from MMCIF file version 5. |
| 67 | + */ |
| 68 | + @Test @Ignore |
| 69 | + public void testDatesV5() throws IOException, StructureException { |
| 70 | + |
| 71 | + ClassLoader classLoader = this.getClass().getClassLoader(); |
| 72 | + String file4 = classLoader.getResource("org/biojava/nbio/structure/io/mmcif/1stp_v5.cif").getPath(); |
| 73 | + |
| 74 | + Structure s = StructureIO.getStructure(file4); |
| 75 | + |
| 76 | + // The latest modified year should be 2011 |
| 77 | + assertEquals(s.getPDBHeader().getModDate().getYear() + 1900, 2011); |
| 78 | + |
| 79 | + // The release date should be october 1992 |
| 80 | + assertEquals(s.getPDBHeader().getRelDate().getMonth() + 1, 10); |
| 81 | + assertEquals(s.getPDBHeader().getRelDate().getYear() + 1900, 1992); |
| 82 | + |
| 83 | + // The deposition date should be march 1992 |
| 84 | + assertEquals(s.getPDBHeader().getDepDate().getMonth() + 1, 3); |
| 85 | + assertEquals(s.getPDBHeader().getDepDate().getYear() + 1900, 1992); |
| 86 | + |
| 87 | + |
| 88 | + } |
| 89 | + |
| 90 | +} |
0 commit comments