|
1 | 1 | package org.biojava.nbio.structure.io;
|
2 | 2 |
|
3 |
| -import static org.junit.Assert.*; |
| 3 | +import static org.junit.Assert.assertEquals; |
4 | 4 |
|
5 | 5 | import java.io.ByteArrayInputStream;
|
6 | 6 | import java.io.IOException;
|
7 | 7 | import java.io.InputStream;
|
8 | 8 |
|
9 | 9 | import org.biojava.nbio.structure.Structure;
|
10 | 10 | import org.biojava.nbio.structure.StructureException;
|
11 |
| -import org.biojava.nbio.structure.StructureIO; |
12 |
| -import org.biojava.nbio.structure.align.util.AtomCache; |
13 | 11 | import org.junit.Test;
|
14 | 12 |
|
15 | 13 | public class TestDBRefParsing {
|
16 |
| - @Test |
17 |
| - public void test2W6E() throws IOException, StructureException { |
18 |
| - |
19 |
| - // an entry with a title in multiple lines in PDB file |
20 |
| - |
21 |
| - AtomCache cache = new AtomCache(); |
22 |
| - |
23 |
| - StructureIO.setAtomCache(cache); |
24 |
| - |
25 |
| - cache.setUseMmCif(false); |
26 |
| - Structure sPdb = StructureIO.getStructure("2W6E"); |
27 |
| - // System.out.println(sPdb.getName()); |
28 |
| - System.out.println(sPdb.getDBRefs().get(0).toPDB()); |
29 |
| - } |
30 | 14 |
|
31 | 15 | @Test
|
32 |
| - public void testShortLine() throws IOException,StructureException{ |
| 16 | + public void testShortLine() throws IOException, StructureException { |
33 | 17 | String shortLine = "DBREF 2W6E A -42 510 UNP P19483 ATPA1_BOVIN 1 553";
|
34 | 18 | InputStream is = new ByteArrayInputStream(shortLine.getBytes());
|
35 | 19 | PDBFileParser pdbPars = new PDBFileParser();
|
36 | 20 | Structure s;
|
37 |
| - try{ |
38 |
| - s=pdbPars.parsePDBFile(is); |
39 |
| - }catch (Exception e){ |
| 21 | + try { |
| 22 | + s = pdbPars.parsePDBFile(is); |
| 23 | + } catch (Exception e) { |
40 | 24 | is.close();
|
41 | 25 | throw new AssertionError("Unable to process truncated DBRef line");
|
42 | 26 | }
|
43 |
| - |
44 |
| - |
45 |
| - is = new ByteArrayInputStream(String.format("%1$-80s", shortLine).getBytes()); |
| 27 | + is = new ByteArrayInputStream(String.format("%1$-80s", shortLine) |
| 28 | + .getBytes()); |
46 | 29 | Structure ref = pdbPars.parsePDBFile(is);
|
47 | 30 | is.close();
|
48 | 31 | assertEquals(ref.getDBRefs().get(0), s.getDBRefs().get(0));
|
49 | 32 | }
|
| 33 | + |
| 34 | + @Test |
| 35 | + public void testToPdbLength() throws IOException { |
| 36 | + String shortLine = "DBREF 2W6E A -42 510 UNP P19483 ATPA1_BOVIN 1 553"; |
| 37 | + InputStream is = new ByteArrayInputStream(shortLine.getBytes()); |
| 38 | + PDBFileParser pdbPars = new PDBFileParser(); |
| 39 | + Structure s; |
| 40 | + try { |
| 41 | + s = pdbPars.parsePDBFile(is); |
| 42 | + } catch (Exception e) { |
| 43 | + is.close(); |
| 44 | + throw new AssertionError("Unable to process truncated DBRef line"); |
| 45 | + } |
| 46 | + //Make sure that the record is true to the input |
| 47 | + assertEquals(shortLine, s.getDBRefs().get(0).toPDB().trim()); |
| 48 | + //And is padded to the correct lenght |
| 49 | + assertEquals(80, s.getDBRefs().get(0).toPDB().length()); |
| 50 | + } |
50 | 51 | }
|
0 commit comments