Skip to content

Commit de9652b

Browse files
committed
Not altering the exceptions in signature, keeping what we had with better logging
1 parent 282bf5b commit de9652b

File tree

1 file changed

+32
-26
lines changed

1 file changed

+32
-26
lines changed

biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/utils/BlastClustReader.java

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@ public BlastClustReader(int sequenceIdentity) {
4949
this.sequenceIdentity = sequenceIdentity;
5050
}
5151

52-
public List<List<String>> getPdbChainIdClusters() throws IOException {
52+
public List<List<String>> getPdbChainIdClusters() {
5353
loadClusters(sequenceIdentity);
5454
return clusters;
5555
}
5656

57-
public Map<String,String> getRepresentatives(String pdbId) throws IOException {
57+
public Map<String,String> getRepresentatives(String pdbId) {
5858
loadClusters(sequenceIdentity);
5959
String pdbIdUc = pdbId.toUpperCase();
6060

61-
Map<String,String> representatives = new LinkedHashMap<String,String>();
61+
Map<String,String> representatives = new LinkedHashMap<>();
6262
for (List<String> cluster: clusters) {
6363
// map fist match to representative
6464
for (String chainId: cluster) {
@@ -71,7 +71,7 @@ public Map<String,String> getRepresentatives(String pdbId) throws IOException {
7171
return representatives;
7272
}
7373

74-
public String getRepresentativeChain(String pdbId, String chainId) throws IOException {
74+
public String getRepresentativeChain(String pdbId, String chainId) {
7575
loadClusters(sequenceIdentity);
7676

7777
String pdbChainId = pdbId.toUpperCase() + "." + chainId;
@@ -84,7 +84,7 @@ public String getRepresentativeChain(String pdbId, String chainId) throws IOExce
8484
return "";
8585
}
8686

87-
public int indexOf(String pdbId, String chainId) throws IOException {
87+
public int indexOf(String pdbId, String chainId) {
8888
loadClusters(sequenceIdentity);
8989

9090
String pdbChainId = pdbId.toUpperCase() + "." + chainId;
@@ -98,7 +98,7 @@ public int indexOf(String pdbId, String chainId) throws IOException {
9898
return -1;
9999
}
100100

101-
public List<List<String>> getPdbChainIdClusters(String pdbId) throws IOException {
101+
public List<List<String>> getPdbChainIdClusters(String pdbId) {
102102
loadClusters(sequenceIdentity);
103103
String pdbIdUpper = pdbId.toUpperCase();
104104

@@ -114,7 +114,7 @@ public List<List<String>> getPdbChainIdClusters(String pdbId) throws IOException
114114
return matches;
115115
}
116116

117-
public List<List<String>> getChainIdsInEntry(String pdbId) throws IOException {
117+
public List<List<String>> getChainIdsInEntry(String pdbId) {
118118
loadClusters(sequenceIdentity);
119119

120120
List<List<String>> matches = new ArrayList<List<String>>();
@@ -138,7 +138,7 @@ public List<List<String>> getChainIdsInEntry(String pdbId) throws IOException {
138138
return matches;
139139
}
140140

141-
private void loadClusters(int sequenceIdentity) throws IOException {
141+
private void loadClusters(int sequenceIdentity) {
142142
// load clusters only once
143143
if (clusters.size() > 0) {
144144
return;
@@ -149,24 +149,30 @@ private void loadClusters(int sequenceIdentity) throws IOException {
149149
return;
150150
}
151151

152-
String urlString = coreUrl + "bc-" + sequenceIdentity + ".out";
153-
URL u = new URL(urlString);
154-
InputStream stream = u.openStream();
155-
156-
if (stream != null) {
157-
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
158-
159-
String line = null;
160-
while ((line = reader.readLine()) != null) {
161-
line = line.replaceAll("_", ".");
162-
List<String> cluster = Arrays.asList(line.split(" "));
163-
clusters.add(cluster);
164-
}
165-
reader.close();
166-
stream.close();
167-
} else {
168-
throw new IOException("Got null stream for URL " + urlString);
169-
}
152+
String urlString = coreUrl + "bc-" + sequenceIdentity + ".out";
153+
154+
try {
155+
156+
URL u = new URL(urlString);
157+
InputStream stream = u.openStream();
158+
159+
if (stream != null) {
160+
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
161+
162+
String line = null;
163+
while ((line = reader.readLine()) != null) {
164+
line = line.replaceAll("_", ".");
165+
List<String> cluster = Arrays.asList(line.split(" "));
166+
clusters.add(cluster);
167+
}
168+
reader.close();
169+
stream.close();
170+
} else {
171+
throw new IOException("Got null stream for URL " + urlString);
172+
}
173+
} catch (IOException e) {
174+
logger.error("Could not get sequence clusters from URL " + urlString + ". Error: " + e.getMessage());
175+
}
170176

171177
}
172178

0 commit comments

Comments
 (0)