robot
robot copied to clipboard
Template ArrayIndexOutOfBoundsException error
Hello Robot Dev team, I've encountered the following ArrayIndexOutOfBoundsException error while using ROBOT template.
I've simplified the template and command causing the issue down the to following template tsv file:
| ontology ID | label | parent class |
|---|---|---|
| ID | AL rdfs:label@en | SC % |
| BSM:0030002 | chain |
and I'm running the command:
robot template --template biology/robot_templates/ecology.tsv -i ../bcodmont-edit.owl --prefix "BSM:http://purl.obolibrary.org/obo/BSM_" -o biology/robot_templates/ecology.owl -vvv
Where the template input file -i can be found from here
The error message is:
2021-02-14 14:35:31,034 DEBUG org.semanticweb.owlapi.utilities.Injector - Loading file META-INF/services/org.semanticweb.owlapi.model.OWLOntologyIRIMapper
2021-02-14 14:35:31,034 DEBUG org.semanticweb.owlapi.utilities.Injector - No files found for META-INF/services/org.semanticweb.owlapi.model.OWLOntologyIRIMapper
2021-02-14 14:35:31,034 DEBUG org.semanticweb.owlapi.utilities.Injector - Injecting values [[]] on method public void uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.setIRIMappers(java.util.Set).
2021-02-14 14:35:31,757 WARN org.obolibrary.robot.IOHelper - Could not create IRI for class
2021-02-14 14:35:31,757 WARN org.obolibrary.robot.IOHelper -
2021-02-14 14:35:31,760 DEBUG org.obolibrary.robot.ExceptionHelper - Malformed exception message: -1
-1
java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.ArrayList.elementData(ArrayList.java:422)
at java.util.ArrayList.get(ArrayList.java:435)
at org.obolibrary.robot.Template.addIndividualAxioms(Template.java:1802)
at org.obolibrary.robot.Template.processRow(Template.java:789)
at org.obolibrary.robot.Template.generateOutputOntology(Template.java:377)
at org.obolibrary.robot.TemplateOperation.template(TemplateOperation.java:184)
at org.obolibrary.robot.TemplateCommand.execute(TemplateCommand.java:148)
at org.obolibrary.robot.CommandManager.executeCommand(CommandManager.java:248)
at org.obolibrary.robot.CommandManager.execute(CommandManager.java:192)
at org.obolibrary.robot.CommandManager.main(CommandManager.java:139)
at org.obolibrary.robot.CommandLineInterface.main(CommandLineInterface.java:60)
I'm running the lastest version of robot:
I'm surprised by this as I've used template in the same fashion many times without issues. Note that when I run the exact same thing without the label in the template tsv file it compiles.
Thanks for the detailed report. My first guess is that the final row in your TSV file ends with "chain" and doesn't have a trailing tab. So when the row is split into tabs we only have an array of two cells instead of three. If I'm right, adding a tab will fix the problem. That case is pretty common and ROBOT should handle it gracefully but maybe we're not.
Can you confirm my guess?
Here's a screenshot of the file using atom's regex selector selecting for tab characters
As you can see there is a trailing tab.
It's strange because with other strings in that same position the template does compile e.g.:
Hi @kaiiam - I am attempting to recreate this issue, here is the input file I used (showing tabs):

I ran the following command:
robot template \
--prefix "BSM:http://purl.obolibrary.org/obo/BSM_" \
--template test.tsv \
--output test.owl
... and did not run into this error. I also tried it without the last trailing tab and it seemed to work OK. Could you send me the input file you're using as well? I'd like to try and get everything the same.
Thanks for the quick response the file is here https://github.com/BCODMO/bcodmont/blob/main/src/ontology/BCODMO_SM/biology/robot_templates/ecology_working.tsv
Hey sorry for raising all this, NOW it is working for me. Using the exact same commands and file etc ... I wonder if there might be a java issue on my computer or something like that. Sorry to bother everyone here. Thanks @beckyjackson for the quick follow up.
Hey @beckyjackson sorry to bug you but I'm running into this issue again I asked James about it at office hours, he said maybe ask you again. Last time I eventually worked I might have done something like sequentially deleted one line at a time in the template file to get it to compile. But it's back to not working. Original
2021-07-05 17:43:11,570 INFO org.obolibrary.robot.TemplateHelper - Parsing expression: PCO:0000000
2021-07-05 17:43:11,629 INFO org.obolibrary.robot.TemplateHelper - Parsing expression: BSM:0030001
2021-07-05 17:43:11,632 INFO org.obolibrary.robot.TemplateHelper - Parsing expression: ENVO:00000150
2021-07-05 17:43:11,636 DEBUG org.obolibrary.robot.ExceptionHelper - Malformed exception message: -1
-1
java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.ArrayList.elementData(ArrayList.java:422)
at java.util.ArrayList.get(ArrayList.java:435)
at org.obolibrary.robot.Template.addIndividualAxioms(Template.java:1802)
at org.obolibrary.robot.Template.processRow(Template.java:789)
at org.obolibrary.robot.Template.generateOutputOntology(Template.java:377)
at org.obolibrary.robot.TemplateOperation.template(TemplateOperation.java:184)
at org.obolibrary.robot.TemplateCommand.execute(TemplateCommand.java:148)
at org.obolibrary.robot.CommandManager.executeCommand(CommandManager.java:248)
at org.obolibrary.robot.CommandManager.execute(CommandManager.java:192)
at org.obolibrary.robot.CommandManager.main(CommandManager.java:139)
at org.obolibrary.robot.CommandLineInterface.main(CommandLineInterface.java:60)
command is
robot template --template biology/robot_templates/ecology.tsv -i ../bcodmont-edit.owl --prefix "RO:http://purl.obolibrary.org/obo/RO_" --prefix "ENVO:http://purl.obolibrary.org/obo/ENVO_" --prefix "PCO:http://purl.obolibrary.org/obo/PCO_" --prefix "BSM:http://purl.obolibrary.org/obo/BSM_" --ontology-iri "http://purl.obolibrary.org/BCODMO_SM/biology/robot_templates/ecology.owl" -o biology/robot_templates/ecology.owl
source tsv file can be found: here
Sorry to bug you again with this.
@kaiiam showed this to me on Zoom. Everything seemed right but the command failed with this error. He's using ROBOT 1.8.1. I just tried this on my machine (also with 1.8.1) and the command succeeded. So I don't know what's going on here.
Thanks for trying James, I just tried on another computer, (a cloud VM) and it fails with a similar issue:
2021-07-05 12:18:35,595 DEBUG org.obolibrary.robot.ExceptionHelper - Missing exception ID: Index -1 out of bounds for length 19
Index -1 out of bounds for length 19
java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 19
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
at java.base/java.util.Objects.checkIndex(Objects.java:372)
at java.base/java.util.ArrayList.get(ArrayList.java:459)
at org.obolibrary.robot.Template.addIndividualAxioms(Template.java:1802)
at org.obolibrary.robot.Template.processRow(Template.java:789)
at org.obolibrary.robot.Template.generateOutputOntology(Template.java:377)
at org.obolibrary.robot.TemplateOperation.template(TemplateOperation.java:184)
at org.obolibrary.robot.TemplateCommand.execute(TemplateCommand.java:148)
at org.obolibrary.robot.CommandManager.executeCommand(CommandManager.java:248)
at org.obolibrary.robot.CommandManager.execute(CommandManager.java:192)
at org.obolibrary.robot.CommandManager.main(CommandManager.java:139)
at org.obolibrary.robot.CommandLineInterface.main(CommandLineInterface.java:60)
something is wrong with row 7 of the template. Cant figure out what it is.
collection of organisms colony chain BSM:0030002 chain BSM:0030001 NCIT:C41207 Two or more conspecific individuals connected together in a linear fashion. Perhaps something to add to ENVO or PCO. http://bcodmo/sm#biology http://bcodmo/sm#ecology
Something about the chain value.
So if you delete the chain label from the label column in row 7 the error goes away. The mystery does not. You can also rename it the chain x and it will work..
Yes thanks @matentzn, I remember the first time I had this issue I had found that same thing it was literally the string chain. When I now run it with chain it works. 🤷