Importing a NucleotideSequenceDocument for tests
Hi,
I am trying to import a document (manually exported from Geneious) and cast the result to a `NucleotideSequenceDocument` for use in unit tests. Here is what I have so far:
private static NucleotideSequenceDocument seqDocumentChr22;
public static NucleotideSequenceDocument getSeqDocumentChr22()
throws IOException, DocumentImportException, DocumentOperationException {
TestGeneious.initialize();
TestGeneious.initializeAllPlugins();
if(seqDocumentChr22 == null) {
List<AnnotatedPluginDocument> annotatedPluginDocs =
PluginUtilities.importDocuments(new File("~/GRCh38_chr22.geneious"), ProgressListener.EMPTY);
seqDocumentChr22 = (NucleotideSequenceDocument) annotatedPluginDocs.get(0).getDocument();
}
return seqDocumentChr22;
}
This is the error I am getting:
java.lang.NullPointerException
at com.biomatters.geneious.publicapi.documents.NoteTypeStorage.c(NoteTypeStorage.java:458)
at com.biomatters.geneious.publicapi.documents.NoteTypeStorage.a(NoteTypeStorage.java:331)
at com.biomatters.geneious.publicapi.documents.NoteTypeStorage.a(NoteTypeStorage.java:425)
at com.biomatters.geneious.publicapi.documents.NoteTypeStorage.setNoteType(NoteTypeStorage.java:379)
at com.biomatters.geneious.publicapi.documents.DocumentNoteUtilities.setNoteType(DocumentNoteUtilities.java:103)
at com.biomatters.geneious.publicapi.documents.NoteTypeStorage.b(NoteTypeStorage.java:82)
at com.biomatters.geneious.publicapi.documents.NoteTypeStorage.a(NoteTypeStorage.java:64)
at com.biomatters.geneious.publicapi.documents.NoteTypeStorage.setNoteType(NoteTypeStorage.java:372)
at com.biomatters.iseek.application.LocalDatabaseExporterImporter.a(LocalDatabaseExporterImporter.java:1060)
at com.biomatters.iseek.application.LocalDatabaseExporterImporter$SpecialRepositoryImportingListener.elementMatched(LocalDatabaseExporterImporter.java:1829)
at com.biomatters.iseek.application.bq.handleElement(LocalDatabaseExporterImporter.java:1474)
at com.biomatters.geneious.publicapi.utilities.xml.FilteredSaxHandler.endElement(FilteredSaxHandler.java:98)
at com.bluecast.xml.Piccolo.reportEndTag(Piccolo.java:1094)
at com.bluecast.xml.PiccoloLexer.parseCloseTagNS(PiccoloLexer.java:2174)
at com.bluecast.xml.PiccoloLexer.parseTagNS(PiccoloLexer.java:1357)
at com.bluecast.xml.PiccoloLexer.parseXMLNS(PiccoloLexer.java:1291)
at com.bluecast.xml.PiccoloLexer.parseXML(PiccoloLexer.java:1259)
at com.bluecast.xml.PiccoloLexer.yylex(PiccoloLexer.java:4721)
at com.bluecast.xml.Piccolo.yylex(Piccolo.java:1290)
at com.bluecast.xml.Piccolo.yyparse(Piccolo.java:1400)
at com.bluecast.xml.Piccolo.parse(Piccolo.java:714)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:517)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:916)
at com.biomatters.geneious.publicapi.utilities.xml.FastSaxBuilder.build(FastSaxBuilder.java:93)
at com.biomatters.iseek.application.LocalDatabaseExporterImporter.a(LocalDatabaseExporterImporter.java:1488)
at com.biomatters.iseek.application.LocalDatabaseExporterImporter.a(LocalDatabaseExporterImporter.java:2105)
at com.biomatters.iseek.application.LocalDatabaseExporterImporter.b(LocalDatabaseExporterImporter.java:2036)
at com.biomatters.iseek.application.LocalDatabaseExporterImporter.a(LocalDatabaseExporterImporter.java:1955)
at com.biomatters.iseek.application.GeneiousFileImporter.a(GeneiousFileImporter.java:66)
at com.biomatters.iseek.plugin.fileimport.E.a(Importage.java:97)
at com.biomatters.iseek.plugin.fileimport.FileImporterManager.a(FileImporterManager.java:793)
at com.biomatters.iseek.plugin.fileimport.FileImporterManager.a(FileImporterManager.java:759)
at com.biomatters.iseek.plugin.fileimport.FileImporterManager.a(FileImporterManager.java:714)
at com.biomatters.iseek.plugin.fileimport.FileImporterManager.a(FileImporterManager.java:867)
at com.biomatters.geneious.publicapi.plugin.PluginUtilitiesImplementation.importDocuments(PluginUtilitiesImplementation.java:57)
at com.biomatters.geneious.publicapi.plugin.PluginUtilities.importDocuments(PluginUtilities.java:420)
at com.primemedicine.testutil.TestUtil.getSeqDocumentChr22(TestUtil.java:26)
at com.primemedicine.annotation.TestContiguousCds.testGetTranscribedSequence(TestContiguousCds.java:26)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:725)
at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:214)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:210)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:66)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:95)
at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:91)
at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:60)
at org.eclipse.jdt.internal.junit5.runner.JUnit5TestReference.run(JUnit5TestReference.java:98)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:529)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:756)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
What is the right way to do this? Thank you!
-
Official comment
Hi Pam,
We think we've identified that the problem is coming from two things:
- The test is running in a different working directory than what the other plugins normally run in.
- The geneious file which you want to import contains a note.
These things combined are we believe causing the failure, the best way to fix this is to change the run configuration. In IntelliJ, this can be done via the Edit Configurations menu and ensuring that the Working Directory setting is set to $MODULE_DIR$\..\GeneiousFiles which is the same value that the other example plugins use. Here is a picture which may help:
-
Hi Pam,
Unfortunately we can't see an obvious solution as we can't reproduce the problem on our end but here are some possible things to try and see if that fixes the problem for you.
- Try add this ServiceUtilities line after the following 2 lines
TestGeneious.initialize();
TestGeneious.initializeAllPlugins();ServiceUtilities.waitForGeneiousServiceInitializationToComplete();
- Instead of using both TestGeneious.initialize() and
TestGeneious.initializeAllPlugins(), try using only TestGeneious.initializeAllPlugins()
Let us know if that works for you and if not, we are happy to dive a bit deeper into what's going wrong.
Cheers,
Tom0 - Try add this ServiceUtilities line after the following 2 lines
-
Hi Tom,
Thanks for your help! With these two updates, I am still getting the same `NullPointerException`.
Is there perhaps another way to read a `.geneious` file into a `NucleotideSequenceDocument`?
Thanks,
Pam
0 -
Updating the working directory solved it. Thank you!
0
Please sign in to leave a comment.
Comments
4 comments