|
| 1 | +package org.biojava.nbio.structure.io.cif; |
| 2 | + |
| 3 | +import org.biojava.nbio.structure.Structure; |
| 4 | +import org.biojava.nbio.structure.io.FileParsingParameters; |
| 5 | +import org.biojava.nbio.structure.io.PDBFileParser; |
| 6 | +import org.junit.Test; |
| 7 | + |
| 8 | +import java.io.ByteArrayInputStream; |
| 9 | +import java.io.IOException; |
| 10 | +import java.io.InputStream; |
| 11 | +import java.util.zip.GZIPInputStream; |
| 12 | + |
| 13 | +import static org.junit.Assert.assertEquals; |
| 14 | +import static org.junit.Assert.assertTrue; |
| 15 | + |
| 16 | +public class CifFileSupplierImplTest { |
| 17 | + |
| 18 | + @Test |
| 19 | + public void shouldReadRawPdbOutputtingCifWithEntity() throws IOException { |
| 20 | + InputStream inStream = new GZIPInputStream(this.getClass().getResourceAsStream("/org/biojava/nbio/structure/io/4lup_phaser_output.pdb.gz")); |
| 21 | + |
| 22 | + PDBFileParser pdbpars = new PDBFileParser(); |
| 23 | + FileParsingParameters params = new FileParsingParameters(); |
| 24 | + params.setAlignSeqRes(true); |
| 25 | + pdbpars.setFileParsingParameters(params); |
| 26 | + |
| 27 | + Structure s = pdbpars.parsePDBFile(inStream); |
| 28 | + |
| 29 | + String cifText = CifStructureConverter.toText(s); |
| 30 | + assertTrue(cifText.contains("_entity.type")); |
| 31 | + assertTrue(cifText.contains("_entity_poly.pdbx_seq_one_letter_code_can")); |
| 32 | + |
| 33 | + InputStream inputStream = new ByteArrayInputStream(cifText.getBytes()); |
| 34 | + Structure readStruct = CifStructureConverter.fromInputStream(inputStream); |
| 35 | + |
| 36 | + assertEquals(s.getEntityInfos().size(), readStruct.getEntityInfos().size()); |
| 37 | + for (int i=0; i<s.getEntityInfos().size(); i++) { |
| 38 | + assertEquals(s.getEntityInfos().get(i).getMolId(), readStruct.getEntityInfos().get(i).getMolId()); |
| 39 | + assertEquals(s.getEntityInfos().get(i).getType(), readStruct.getEntityInfos().get(i).getType()); |
| 40 | + } |
| 41 | + |
| 42 | + } |
| 43 | +} |
0 commit comments