Skip to content

Commit 504f3c8

Browse files
committed
adding a parsing performance unit test for mmtf, that compares with pdb format parsing.
1 parent 26a5300 commit 504f3c8

File tree

2 files changed

+2785
-0
lines changed

2 files changed

+2785
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package org.biojava.nbio.structure.io.mmtf;
2+
3+
import org.biojava.nbio.structure.Structure;
4+
import org.biojava.nbio.structure.StructureIO;
5+
import org.biojava.nbio.structure.io.PDBFileParser;
6+
import org.biojava.nbio.structure.io.mmcif.AllChemCompProvider;
7+
import org.biojava.nbio.structure.io.mmcif.ChemCompGroupFactory;
8+
import org.biojava.nbio.structure.io.mmcif.ChemCompProvider;
9+
import org.junit.Test;
10+
import org.rcsb.mmtf.dataholders.MmtfStructure;
11+
import org.rcsb.mmtf.decoder.ReaderUtils;
12+
13+
import java.io.FileInputStream;
14+
import java.io.IOException;
15+
import java.io.InputStream;
16+
import java.nio.file.Files;
17+
import java.nio.file.Path;
18+
import java.nio.file.Paths;
19+
20+
import static org.junit.Assert.assertEquals;
21+
import static org.junit.Assert.assertTrue;
22+
23+
/**
24+
* Created by andreas on 1/9/17.
25+
*/
26+
public class TestMmtfPerformance {
27+
28+
// @Test
29+
// public void test3J3Q() throws IOException{
30+
//
31+
//// AllChemCompProvider cc = new AllChemCompProvider();
32+
//// ChemCompGroupFactory.setChemCompProvider(cc);
33+
//
34+
// long timeS = System.currentTimeMillis();
35+
// ClassLoader classLoader = getClass().getClassLoader();
36+
// Structure structure = MmtfActions.readFromFile((Paths.get(classLoader.getResource("org/biojava/nbio/structure/io/mmtf/3J3Q.mmtf").getPath())));
37+
// assertEquals(structure.getPDBCode(),"3J3Q");
38+
// //assertEquals(structure.getChains().size(),6);
39+
// long timeE = System.currentTimeMillis();
40+
//
41+
// System.out.println("time to load from local file: " + (timeE - timeS) + " ms.");
42+
//
43+
// }
44+
45+
@Test
46+
public void test4CUP() throws IOException{
47+
48+
long timeS = System.currentTimeMillis();
49+
50+
ClassLoader classLoader = getClass().getClassLoader();
51+
Structure structure = MmtfActions.readFromFile((Paths.get(classLoader.getResource("org/biojava/nbio/structure/io/mmtf/4CUP.mmtf").getPath())));
52+
53+
assertEquals(structure.getPDBCode(),"4CUP");
54+
assertEquals(structure.getChains().size(),6);
55+
56+
long timeE = System.currentTimeMillis();
57+
58+
Path path = Paths.get(classLoader.getResource("org/biojava/nbio/structure/io/4cup.pdb").getPath());
59+
60+
InputStream is = Files.newInputStream(path);
61+
62+
PDBFileParser parser = new PDBFileParser();
63+
64+
Structure s = parser.parsePDBFile(is);
65+
66+
long timeF = System.currentTimeMillis();
67+
68+
//todo: add mmcif for comparison
69+
70+
// System.out.println("time to parse mmtf:" + (timeE-timeS));
71+
// System.out.println("time to parse PDB: " + (timeF-timeE));
72+
73+
assertTrue( "It should not be the case, but it is faster to parse a PDB file ("+(timeF -timeE)+" ms.) than MMTF ("+( timeE-timeS)+" ms.)!",( timeF -timeE) > ( timeE-timeS));
74+
75+
}
76+
}

0 commit comments

Comments
 (0)