Skip to content

Commit 9afde8f

Browse files
committed
Fixing test and clean up
1 parent 3d0274b commit 9afde8f

2 files changed

Lines changed: 8 additions & 51 deletions

File tree

biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmtf/MmtfUtils.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,6 @@ public static void addSeqRes(Chain modelChain, String sequence) {
516516

517517
group = getSeqResGroup(singleLetterCode, chainType);
518518
addGroupAtId(seqResGroups, group, i);
519-
seqResGroups.set(i, group);
520519
}
521520
}
522521

biojava-structure/src/test/java/org/biojava/nbio/structure/io/mmtf/TestMmtfPerformance.java

Lines changed: 8 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -44,54 +44,14 @@ public class TestMmtfPerformance {
4444

4545
private static final int NUMBER_OF_REPEATS = 10;
4646

47-
// Returns the contents of the file in a byte array.
48-
public static byte[] getBytesFromFile(File file) throws IOException {
49-
// Get the size of the file
50-
long length = file.length();
51-
52-
// You cannot create an array using a long type.
53-
// It needs to be an int type.
54-
// Before converting to an int type, check
55-
// to ensure that file is not larger than Integer.MAX_VALUE.
56-
if (length > Integer.MAX_VALUE) {
57-
// File is too large
58-
throw new IOException("File is too large!");
59-
}
60-
61-
// Create the byte array to hold the data
62-
byte[] bytes = new byte[(int)length];
63-
64-
// Read in the bytes
65-
int offset = 0;
66-
int numRead = 0;
67-
68-
InputStream is = new FileInputStream(file);
69-
try {
70-
while (offset < bytes.length
71-
&& (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
72-
offset += numRead;
73-
}
74-
} finally {
75-
is.close();
76-
}
77-
78-
// Ensure all the bytes have been read in
79-
if (offset < bytes.length) {
80-
throw new IOException("Could not completely read file "+file.getName());
81-
}
82-
return bytes;
83-
}
84-
85-
static String convertStreamToString(java.io.InputStream is) {
47+
private static String convertStreamToString(java.io.InputStream is) {
8648
try (
8749
java.util.Scanner s = new java.util.Scanner(is)){
8850
return s.useDelimiter("\\A").hasNext() ? s.next() : "";
8951
}
90-
9152
}
9253

93-
94-
public byte[] getByteArrayFromInputStream(InputStream is) throws IOException {
54+
private byte[] getByteArrayFromInputStream(InputStream is) throws IOException {
9555
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
9656

9757
int nRead;
@@ -104,7 +64,6 @@ public byte[] getByteArrayFromInputStream(InputStream is) throws IOException {
10464
buffer.flush();
10565

10666
return buffer.toByteArray();
107-
10867
}
10968

11069
@Test
@@ -128,31 +87,30 @@ public void test3HBX() throws Exception{
12887

12988
byte[] mmtfdata = getByteArrayFromInputStream(new GZIPInputStream((mmtfURL.openStream())));
13089

90+
// first make sure chemcomp cache is warmed up (chemcomp files are parsed). Like that we count the parsing time without the influence of chemcomp parsing
91+
MmtfActions.readFromInputStream(new ByteArrayInputStream(mmtfdata));
92+
parser.parsePDBFile(new ByteArrayInputStream(pdbBytes));
93+
13194
for ( int i =0 ; i< NUMBER_OF_REPEATS ; i++) {
13295

13396
long mmtfStart = System.nanoTime();
13497
MmtfActions.readFromInputStream(new ByteArrayInputStream(mmtfdata));
13598
long mmtfEnd = System.nanoTime();
13699

137-
138-
139100
long pdbStart = System.nanoTime();
140101
parser.parsePDBFile(new ByteArrayInputStream(pdbBytes));
141102
long pdbEnd = System.nanoTime();
142103

143104
totalTimePDB += (pdbEnd - pdbStart);
144105

145-
146106
totalTimeMMTF += (mmtfEnd-mmtfStart);
147107
}
148108

149-
150109
long timePDB = (totalTimePDB/NUMBER_OF_REPEATS);
151110
long timeMMTF = (totalTimeMMTF/NUMBER_OF_REPEATS);
152111

153-
154-
logger.warn("average time to parse mmtf: " + timeMMTF/(1000*1000) + " ms.");
155-
logger.warn("average time to parse PDB : " + timePDB/(1000*1000) + " ms. ");
112+
logger.info("average time to parse mmtf: " + timeMMTF/(1000*1000) + " ms.");
113+
logger.info("average time to parse PDB : " + timePDB/(1000*1000) + " ms. ");
156114

157115
assertTrue( "It should not be the case, but it is faster to parse a PDB file ("+timePDB+" ns.) than MMTF ("+( timeMMTF)+" ns.)!",( timePDB) > ( timeMMTF));
158116

0 commit comments

Comments
 (0)