Skip to content

Commit 3a40972

Browse files
committed
Merge remote-tracking branch 'origin/master' into flaky_test_fixed
2 parents 2cbb6c6 + 65ad15f commit 3a40972

File tree

6 files changed

+13
-94
lines changed

6 files changed

+13
-94
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ BioJava 6.0.0 (future release)
1212
* The whole `org.biojava.nbio.structure.rcsb` package, a client for the legacy RCSB PDB APIs (disappearing in Nov 2020)
1313
* The whole `org.biojava.nbio.structure.validation` package
1414
* The `org.biojava.nbio.structure.domain.PDBDomainProvider` class to pull domain definitions from legacy RCSB PDB APIs
15+
* Support for automatically fetching dssp files from RCSB (`org.biojava.nbio.structure.secstruc.DSSPParser.fetch()`)
1516

1617
BioJava 5.4.0
1718
=============

biojava-structure/src/main/java/demo/DemoLoadSecStruc.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.biojava.nbio.structure.StructureException;
2828
import org.biojava.nbio.structure.align.util.AtomCache;
2929
import org.biojava.nbio.structure.io.FileParsingParameters;
30-
import org.biojava.nbio.structure.secstruc.DSSPParser;
3130
import org.biojava.nbio.structure.secstruc.SecStrucCalc;
3231
import org.biojava.nbio.structure.secstruc.SecStrucInfo;
3332
import org.biojava.nbio.structure.secstruc.SecStrucTools;
@@ -64,13 +63,6 @@ public static void main(String[] args) throws IOException,
6463
System.out.println("Author's assignment: ");
6564
printSecStruc(s);
6665

67-
// If the more detailed DSSP prediction is required call this
68-
DSSPParser.fetch(pdbID, s, true);
69-
70-
// Print the assignment residue by residue
71-
System.out.println("DSSP assignment: ");
72-
printSecStruc(s);
73-
7466
// finally use BioJava's built in DSSP-like secondary structure assigner
7567
SecStrucCalc secStrucCalc = new SecStrucCalc();
7668

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,7 @@ public static void calculateDsspSecondaryStructure(Structure bioJavaStruct) {
164164
ssp.calculate(bioJavaStruct, true);
165165
}
166166
catch(StructureException e) {
167-
LOGGER.warn("Could not calculate secondary structure (error {}). Will try to get a DSSP file from the RCSB web server instead.", e.getMessage());
168-
169-
try {
170-
DSSPParser.fetch(bioJavaStruct.getPDBCode(), bioJavaStruct, true); //download from PDB the DSSP result
171-
} catch(Exception bige){
172-
LOGGER.warn("Could not get a DSSP file from RCSB web server. There will not be secondary structure assignment for this structure ({}). Error: {}", bioJavaStruct.getPDBCode(), bige.getMessage());
173-
}
167+
LOGGER.warn("Could not calculate secondary structure (error {}). Secondary structure annotation will be missing.", e.getMessage());
174168
}
175169
}
176170

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

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@
2828
import java.io.InputStreamReader;
2929
import java.io.Reader;
3030
import java.io.StringReader;
31-
import java.net.URL;
3231
import java.util.ArrayList;
3332
import java.util.List;
34-
import java.util.zip.GZIPInputStream;
3533

3634
import org.biojava.nbio.structure.Group;
3735
import org.biojava.nbio.structure.ResidueNumber;
@@ -99,32 +97,6 @@ public static List<SecStrucState> parseFile(String dsspPath,
9997
return generalParse(reader, structure, assign);
10098
}
10199

102-
/**
103-
* Fetch and parse the DSSP file of the specified pdb code
104-
* from the PDB web server and return the secondary structure
105-
* annotation as a List of {@link SecStrucState} objects.
106-
*
107-
* @param pdb path to the DSSP file to parse
108-
* @param structure Structure object associated to the dssp
109-
* @param assign assigns the SS to the structure if true
110-
* @return a List of SS annotation objects
111-
* @throws StructureException
112-
* @throws IOException
113-
*/
114-
public static List<SecStrucState> fetch(String pdb,
115-
Structure structure, boolean assign)
116-
throws IOException, StructureException {
117-
118-
URL url = new URL("http://files.rcsb.org/dssp/" +
119-
pdb.toLowerCase().substring(1, 3) + "/" +
120-
pdb.toLowerCase() + "/" +
121-
pdb.toLowerCase() + ".dssp.gz");
122-
InputStream in = new GZIPInputStream(url.openStream());
123-
Reader read = new InputStreamReader(in);
124-
BufferedReader reader = new BufferedReader(read);
125-
return generalParse(reader, structure, assign);
126-
}
127-
128100
/**
129101
* Parse a DSSP format String and return the secondary structure
130102
* annotation as a List of {@link SecStrucState} objects.
@@ -183,16 +155,16 @@ private static List<SecStrucState> generalParse(BufferedReader reader,
183155

184156
//Parse the Bridge partners - TODO parallel or antiparallel?
185157
String bp = line.substring(25,29).trim();
186-
if (bp != "") {
158+
if (!bp.equals("")) {
187159
BetaBridge bb = new BetaBridge(
188-
index, Integer.valueOf(bp), BridgeType.parallel);
160+
index, Integer.parseInt(bp), BridgeType.parallel);
189161
ss.addBridge(bb);
190162
} else logger.warn("Unable to parse beta Bridge for resn "+index);
191163

192164
bp = line.substring(29,33).trim();
193-
if (bp != "") {
165+
if (!bp.equals("")) {
194166
BetaBridge bb = new BetaBridge(
195-
index, Integer.valueOf(bp), BridgeType.parallel);
167+
index, Integer.parseInt(bp), BridgeType.parallel);
196168
ss.addBridge(bb);
197169
} else logger.warn("Unable to parse beta Bridge for resn "+index);
198170

@@ -203,7 +175,7 @@ private static List<SecStrucState> generalParse(BufferedReader reader,
203175
int b = a + 8;
204176

205177
String val = line.substring(a,b).trim();
206-
if (val == "") {
178+
if (val.equals("")) {
207179
logger.warn("Unable to parse energy for resn "+index);
208180
continue;
209181
}
@@ -212,7 +184,7 @@ private static List<SecStrucState> generalParse(BufferedReader reader,
212184

213185
int partner = Integer.parseInt(p[0]);
214186
if (partner != 0) partner += index;
215-
double energy = Double.valueOf(p[1]) * 1000.0;
187+
double energy = Double.parseDouble(p[1]) * 1000.0;
216188

217189
switch(i){
218190
case 0:
@@ -236,15 +208,15 @@ private static List<SecStrucState> generalParse(BufferedReader reader,
236208

237209
//Angle properties
238210
String val = line.substring(91,97).trim();
239-
if (val != "") ss.setKappa(Float.valueOf(val));
211+
if (!val.equals("")) ss.setKappa(Float.parseFloat(val));
240212
else logger.warn("Unable to parse kappa for resn "+index);
241213

242214
val = line.substring(103,109).trim();
243-
if (val != "") ss.setPhi(Float.valueOf(val));
215+
if (!val.equals("")) ss.setPhi(Float.parseFloat(val));
244216
else logger.warn("Unable to parse phi for resn "+index);
245217

246218
val = line.substring(109,116).trim();
247-
if (val != "") ss.setPsi(Float.valueOf(val));
219+
if (!val.equals("")) ss.setPsi(Float.parseFloat(val));
248220
else logger.warn("Unable to parse psi for resn "+index);
249221

250222
if (assign) parent.setProperty(Group.SEC_STRUC, ss);

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

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
package org.biojava.nbio.structure;
2222

2323
import org.biojava.nbio.core.util.FlatFileCache;
24-
import org.biojava.nbio.structure.io.LocalPDBDirectory;
2524
import org.biojava.nbio.structure.io.mmcif.DownloadChemCompProvider;
2625
import org.biojava.nbio.structure.io.mmcif.model.ChemComp;
2726
import org.junit.Test;
@@ -47,39 +46,6 @@ public void testProtectedIDs(){
4746
assertEquals(cc.getId(), id);
4847
}
4948

50-
@Test
51-
public void testRedirectWorks() {
52-
// since August 2017, RCSB is redirecting:
53-
// http://rcsb.org/pdb/files/ligand/HEM.cif ----> http://files.org/ligands/HEM.cif
54-
// see #703
55-
56-
File file = new File(DownloadChemCompProvider.getLocalFileName("HEM"));
57-
file.delete();
58-
59-
DownloadChemCompProvider prov = new DownloadChemCompProvider();
60-
61-
DownloadChemCompProvider.serverBaseUrl = "http://www.rcsb.org/pdb/files/ligand/";
62-
63-
ChemComp cc = prov.getChemComp("HEM");
64-
65-
//System.out.println(file.toString());
66-
67-
assertTrue(file.exists());
68-
69-
// just in case the we did get garbage, let's clean up
70-
file.delete();
71-
72-
// very important: we have a memory cache of files, we need to reset it not to pollute the cache for later tests
73-
FlatFileCache.clear();
74-
75-
assertNotNull(cc);
76-
77-
assertNotNull(cc.getName());
78-
79-
// reset to default URL or otherwise we could affect other tests
80-
DownloadChemCompProvider.serverBaseUrl = DownloadChemCompProvider.DEFAULT_SERVER_URL;
81-
}
82-
8349
@Test
8450
public void testWeDontCacheGarbage() {
8551
// see #703

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,7 @@ public void testDSSPParser() throws IOException, StructureException {
5656
List<SecStrucState> file = DSSPParser.parseInputStream(new GZIPInputStream(
5757
this.getClass().getResourceAsStream("/org/biojava/nbio/structure/secstruc/"+name+".dssp.gz")), s, false);
5858

59-
// Test fetching from PDB
60-
List<SecStrucState> pdb = DSSPParser.fetch(name, s, false);
61-
62-
// Test predicting, writting and parsing back
59+
// Test predicting, writing and parsing back
6360
SecStrucCalc sec = new SecStrucCalc();
6461
List<SecStrucState> pred = sec.calculate(s, false);
6562

@@ -68,13 +65,10 @@ public void testDSSPParser() throws IOException, StructureException {
6865

6966
assertTrue(
7067
"SS assignment lengths do not match",
71-
file.size() == pdb.size()
72-
&& pred.size() == parseBack.size()
68+
pred.size() == parseBack.size()
7369
&& pred.size() == file.size());
7470

7571
for (int i = 0; i < file.size(); i++) {
76-
assertEquals("SS assignment position " + (i + 1)
77-
+ " does not match", file.get(i), pdb.get(i));
7872
assertEquals("SS assignment position " + (i + 1)
7973
+ " does not match", pred.get(i), parseBack.get(i));
8074
assertEquals("SS assignment position " + (i + 1)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy