You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
private NCBIQBlastAlignmentProperties inputProperties = new NCBIQBlastAlignmentProperties();
private NCBIQBlastService service = new NCBIQBlastService();
...
inputProperties.setBlastDatabase("swissprot");
inputProperties.setBlastExpect(Double.parseDouble("1e-10"));
inputProperties.setBlastProgram(BlastProgramEnum.blastp);
inputProperties.setAlignmentOption(BlastAlignmentParameterEnum.ENTREZ_QUERY, "<redacted>"); //Note this redaction is not in my original code.
...
System.out.println("Submitting " + inputSequences.getSize() + " requests");
for(int i=0; i<inputSequences.getSize(); i++)
{
try
{
rids.add(this.service.sendAlignmentRequest(inputSequences.getSequence(i), inputProperties));
}
catch (Exception e)
{
e.printStackTrace();
}
}
Note that "rids" is an ArrayList for storing rid strings and inputSequences is an instance of a class which stores sequence data as String.
When executed, the following error is thrown on each iteration of the for loop:
java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
at org.biojava.nbio.ws.alignment.qblast.NCBIQBlastService.sendAlignmentRequest(NCBIQBlastService.java:223)
Note that this error is not being thrown by my code, but by the NCBIQBlastService module. Going to this point in the code leads to the following block in NCBIQBlastService:
BlastJob job = new BlastJob();
String line;
while ((line = reader.readLine()) != null) {
if (!line.contains("class=\"error\"") && !line.contains("Message ID#")) {
// if there is no error, capture RID and RTOE
if (line.contains("RID = ")) {
String[] arr = line.split("=");
job.setId(arr[1].trim());
} else if (line.contains("RTOE = ")) {
String[] arr = line.split("=");
job.setStartTimestamp(System.currentTimeMillis());
job.setExpectedExecutionTime(Long.parseLong(arr[1].trim()) * 1000);
}
jobs.put(job.getId(), job);
} else {
// handle QBlast error message
// Capture everything to the left of this HTML statement...
String[] tmp = line.split("</p></li></ul>");
// Only the error message is on the right side of this...
String[] moreTmp = tmp[0].split("<p class=\"error\">");
throw new Exception("NCBI QBlast refused this request because: " + moreTmp[1].trim());
}
}
Specifically, the line "throw new Exception("NCBI QBlast refused this request because: " + moreTmp[1].trim());" is throwing the ArrayIndexOutOfBoundsException. Evidently there is something wrong with my request, hence why I'm getting the error handler, but I can't determine what that reason is is because moreTmp[1] is out of moreTmp's bounds (according to the error message it only has one element). Consequently, the exception the code is trying to throw doesn't get thrown and the reason for the refusal of the request is lost.
The text was updated successfully, but these errors were encountered:
FC123321
changed the title
NCBIQBlastService.sendAlignmentRequest
NCBIQBlastService.sendAlignmentRequest | Always throws ArrayIndexOutOfBoundsException
Jun 30, 2022
Thanks for reporting. My guess is that something has changed in the output format and now this always fails. At a minimum, there should be a check for the array length before trying to put it in the message. In any case it seems like a bad idea to have to parse html for this. I guess there's a better way to run blast via an API these days?
I am using BioJava through Maven, using biojava 6.0.5 and biojava-ws 6.0.4 (because trying to use 6.0.5 produces errors):
I'm trying to submit blast requests to NCBI. To do this, I have largely followed this guide:
https://biojava.org/wiki/BioJava:CookBook3:NCBIQBlastService
My relevant code is as follows:
Note that "rids" is an ArrayList for storing rid strings and inputSequences is an instance of a class which stores sequence data as String.
When executed, the following error is thrown on each iteration of the for loop:
Note that this error is not being thrown by my code, but by the NCBIQBlastService module. Going to this point in the code leads to the following block in NCBIQBlastService:
Specifically, the line "throw new Exception("NCBI QBlast refused this request because: " + moreTmp[1].trim());" is throwing the ArrayIndexOutOfBoundsException. Evidently there is something wrong with my request, hence why I'm getting the error handler, but I can't determine what that reason is is because moreTmp[1] is out of moreTmp's bounds (according to the error message it only has one element). Consequently, the exception the code is trying to throw doesn't get thrown and the reason for the refusal of the request is lost.
The text was updated successfully, but these errors were encountered: