Skip to content

Commit 3c92046

Browse files
committed
Now doing dssp tests from local resources
1 parent 5951780 commit 3c92046

File tree

11 files changed

+30
-5
lines changed

11 files changed

+30
-5
lines changed

biojava-structure/src/main/java/org/biojava/nbio/structure/secstruc/DSSPParser.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,25 @@ public class DSSPParser {
5858
private static final Logger logger =
5959
LoggerFactory.getLogger(DSSPParser.class);
6060

61+
/**
62+
* Parse a DSSP output file and return the secondary structure
63+
* annotation as a List of {@link SecStrucState} objects.
64+
*
65+
* @param dsspIs an InputStream to a DSSP file
66+
* @param structure Structure object associated to the dssp
67+
* @param assign assigns the SS to the structure if true
68+
* @return a List of SS annotation objects
69+
* @throws StructureException
70+
* @throws IOException
71+
*/
72+
public static List<SecStrucState> parseInputStream(InputStream dsspIs,
73+
Structure structure, boolean assign)
74+
throws IOException, StructureException {
75+
76+
BufferedReader reader = new BufferedReader(new InputStreamReader(dsspIs));
77+
return generalParse(reader, structure, assign);
78+
}
79+
6180
/**
6281
* Parse a DSSP output file and return the secondary structure
6382
* annotation as a List of {@link SecStrucState} objects.

biojava-structure/src/test/java/org/biojava/nbio/structure/TestURLIdentifier.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public void testURLParameters() throws StructureException, IOException {
101101
assertEquals("wrong length for chainName=A", 94, StructureTools.getRepresentativeAtomArray(reduced).length);
102102

103103
try {
104-
url = new URL("http://www.rcsb.org/pdb/files/1B8G.pdb.gz");
104+
url = new URL("https://files.rcsb.org/download/1B8G.pdb.gz");
105105
id = new URLIdentifier(url);
106106

107107
full = id.loadStructure(cache);

biojava-structure/src/test/java/org/biojava/nbio/structure/secstruc/TestDSSPParser.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.io.IOException;
2424
import java.util.Arrays;
2525
import java.util.List;
26+
import java.util.zip.GZIPInputStream;
2627

2728
import org.biojava.nbio.structure.Structure;
2829
import org.biojava.nbio.structure.StructureException;
@@ -56,7 +57,8 @@ public void testDSSPParser() throws IOException, StructureException {
5657
"src/test/resources/" + name + ".dssp", s, false);
5758

5859
// Test fetching from PDB
59-
List<SecStrucState> pdb = DSSPParser.fetch(name, s, false);
60+
List<SecStrucState> pdb = DSSPParser.parseInputStream(new GZIPInputStream(
61+
this.getClass().getResourceAsStream("/org/biojava/nbio/structure/secstruc/"+name+".dssp.gz")), s, false);
6062

6163
// Test predicting, writting and parsing back
6264
SecStrucCalc sec = new SecStrucCalc();

biojava-structure/src/test/java/org/biojava/nbio/structure/secstruc/TestSecStrucCalc.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.io.IOException;
2424
import java.util.Arrays;
2525
import java.util.List;
26+
import java.util.zip.GZIPInputStream;
2627

2728
import org.biojava.nbio.structure.Structure;
2829
import org.biojava.nbio.structure.StructureException;
@@ -66,7 +67,8 @@ public void testSecStrucPred() throws StructureException, IOException {
6667
List<SecStrucState> biojava = sec.calculate(structure, true);
6768

6869
//Download the original DSSP implementation output
69-
List<SecStrucState> dssp = DSSPParser.fetch(name, structure, false);
70+
List<SecStrucState> dssp = DSSPParser.parseInputStream(new GZIPInputStream(
71+
this.getClass().getResourceAsStream("/org/biojava/nbio/structure/secstruc/"+name+".dssp.gz")), structure, false);
7072

7173
assertEquals("SS assignment lengths do not match",
7274
biojava.size(), dssp.size()*structure.nrModels());
@@ -103,8 +105,10 @@ public void testMultiModelPred() throws StructureException, IOException {
103105
List<SecStrucState> biojava = sec.calculate(structure, true);
104106

105107
// Download the original DSSP implementation output
106-
List<SecStrucState> dssp = DSSPParser.fetch(pdbId,cache.getStructure(pdbId), false);
107-
dssp.addAll(DSSPParser.fetch(pdbIdTwo, cache.getStructure(pdbIdTwo), false));
108+
List<SecStrucState> dssp = DSSPParser.parseInputStream(new GZIPInputStream(
109+
this.getClass().getResourceAsStream("/org/biojava/nbio/structure/secstruc/"+pdbId+".dssp.gz")),cache.getStructure(pdbId), false);
110+
dssp.addAll(DSSPParser.parseInputStream(new GZIPInputStream(
111+
this.getClass().getResourceAsStream("/org/biojava/nbio/structure/secstruc/"+pdbIdTwo+".dssp.gz")), cache.getStructure(pdbIdTwo), false));
108112

109113
assertEquals("SS assignment lengths do not match",
110114
biojava.size(), dssp.size());
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)