Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix ArrayIndexOutOfBoundsException and file validation in CathInstall…
…ation
  • Loading branch information
josemduarte committed Aug 26, 2026
commit 72b5ed10566b87a0d11b7bd81d05b0af34f95997
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,9 @@ private void parseCathDomainList(BufferedReader bufferedReader) throws IOExcepti
// int counter = 0;
while ( (line = bufferedReader.readLine()) != null ) {
if ( line.startsWith("#") ) continue;
if ( line.trim().isEmpty() ) continue;
CathDomain cathDomain = parseCathListFileLine(line);
if ( cathDomain == null ) continue;
// counter++;

String pdbId = cathDomain.getPdbIdAndChain().substring(0,4); // includes chain letter
Expand Down Expand Up @@ -386,7 +388,9 @@ private void parseCathNames(BufferedReader bufferedReader) throws IOException{
//int counter = 0;
while ( (line = bufferedReader.readLine()) != null ) {
if ( line.startsWith("#") ) continue;
if ( line.trim().isEmpty() ) continue;
CathNode cathNode = parseCathNamesFileLine(line);
if ( cathNode == null ) continue;
cathTree.put(cathNode.getNodeId(), cathNode);
}
}
Expand All @@ -413,6 +417,7 @@ private void parseCathDomainDescriptionFile(BufferedReader bufferedReader) throw
StringBuilder sseqs = null;
while ( (line = bufferedReader.readLine()) != null ) {
if ( line.startsWith("#") ) continue;
if ( line.trim().isEmpty() ) continue;
if ( line.startsWith("FORMAT") ) {
cathDescription = new CathDomain();
cathDescription.setFormat( line.substring(10) );
Expand Down Expand Up @@ -504,8 +509,11 @@ private void parseCathDomainDescriptionFile(BufferedReader bufferedReader) throw
}*/

private CathDomain parseCathListFileLine(String line) {
String [] token = line.trim().split("\\s+");
if (token.length < 12) {
Comment thread
aalhossary marked this conversation as resolved.
return null;
}
CathDomain cathDomain = new CathDomain();
String [] token = line.split("\\s+");
cathDomain.setDomainName(token[0]);
cathDomain.setClassId(Integer.parseInt(token[1]));
cathDomain.setArchitectureId(Integer.parseInt(token[2]));
Expand All @@ -522,8 +530,11 @@ private CathDomain parseCathListFileLine(String line) {
}

private CathNode parseCathNamesFileLine(String line) {
String[] token = line.trim().split("\\s+",3);
if (token.length < 3) {
Comment thread
aalhossary marked this conversation as resolved.
return null;
}
CathNode cathNode = new CathNode();
String[] token = line.split("\\s+",3);
cathNode.setNodeId( token[0] );
int idx = token[0].lastIndexOf(".");
if ( idx == -1 ) idx = token[0].length();
Expand All @@ -544,8 +555,8 @@ private void parseCathDomall(BufferedReader bufferedReader) throws IOException{
String line;
while ( ((line = bufferedReader.readLine()) != null) ) {
if ( line.startsWith("#") ) continue;
if ( line.length() == 0 ) continue;
String[] token = line.split("\\s+");
if ( line.trim().isEmpty() ) continue;
String[] token = line.trim().split("\\s+");
String chainId = token[0];
Integer numberOfDomains = Integer.parseInt( token[1].substring(1) );
Integer numberOfFragments = Integer.parseInt( token[2].substring(1) );
Expand Down Expand Up @@ -671,25 +682,25 @@ protected void downloadFileFromRemote(URL remoteURL, File localFile) throws IOEx
private boolean domainDescriptionFileAvailable(){
String fileName = getDomainDescriptionFileName();
File f = new File(fileName);
return f.exists();
return f.exists() && FileDownloadUtils.validateFile(f);
Comment thread
aalhossary marked this conversation as resolved.
}

private boolean domainListFileAvailable(){
String fileName = getDomainListFileName();
File f = new File(fileName);
return f.exists();
return f.exists() && FileDownloadUtils.validateFile(f);
}

private boolean nodeListFileAvailable(){
String fileName = getNodeListFileName();
File f = new File(fileName);
return f.exists();
return f.exists() && FileDownloadUtils.validateFile(f);
}

private boolean domallFileAvailable() {
String fileName = getDomallFileName();
File f= new File(fileName);
return f.exists();
return f.exists() && FileDownloadUtils.validateFile(f);
}

protected void downloadDomainListFile() throws IOException{
Expand Down
Loading