Post

1 follower Follow
0
Avatar

Calling an alignment in a test

Hi,

 

 

I'm trying to do some testing and that involves calling an alignment. The same code works in non-test mode.

Also I have other tests in this same test class that work too and note I have the

TestGeneious.initialize();

So it's just the alignment.

Calling an alignment in a test

public List<AnnotatedPluginDocument> align(DefaultNucleotideSequence sequenceA, DefaultNucleotideSequence sequenceB) {
List<AnnotatedPluginDocument> documentsToAlign = Stream.of(DocumentUtilities.createAnnotatedPluginDocument(sequenceA), DocumentUtilities.createAnnotatedPluginDocument(sequenceB)).collect(Collectors.toList());
DocumentOperation alignmentOperation = PluginUtilities.getCategoryOperation(GeneiousActionOptions.Category.Alignment);
List<AnnotatedPluginDocument> alignment = null;
try {
Options alignmentOptions = alignmentOperation.getOptions(documentsToAlign); // Get the options provided by the alignment operation.
alignmentOptions.setValue("operation", "com.biomatters.plugins.translationalign.TranslationAlignmentOperation"); //Translation.
alignmentOptions.setValue("com.biomatters.plugins.translationalign.TranslationAlignmentOperation.alignmentOptions.trans_operation", "Clustal_Alignment_PROTEIN_");
alignment = alignmentOperation.performOperation(documentsToAlign, null, alignmentOptions);
DefaultAlignmentDocument firstAlignedSequence = (DefaultAlignmentDocument) alignment.get(0).getDocumentOrCrash();
List<SequenceDocument> sequencesInImmutableList = firstAlignedSequence.getSequencesInImmutableList();
sequencesInImmutableList.forEach(System.out::println);
} catch (DocumentOperationException e) {
e.printStackTrace();
}
return alignment;

It fails with:

java.lang.RuntimeException: Something needs to have properly initialized the category options

at com.biomatters.geneious.publicapi.plugin.PluginUtilitiesImplementation.getCategoryOperation(PluginUtilitiesImplementation.java:167)
at com.biomatters.geneious.publicapi.plugin.PluginUtilities.getCategoryOperation(PluginUtilities.java:92)
at TestOpt.align(TestOpt.java:75)
at TestOpt.testAlignAndCompare(TestOpt.java:65)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:389)
at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:115)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:167)
at org.junit.jupiter.engine.execution.ThrowableCollector.execute(ThrowableCollector.java:40)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:163)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:110)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:57)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.lambda$execute$3(HierarchicalTestExecutor.java:83)
at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:77)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.lambda$null$2(HierarchicalTestExecutor.java:92)
at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
at java.util.Iterator.forEachRemaining(Iterator.java:116)
at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.lambda$execute$3(HierarchicalTestExecutor.java:92)
at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:77)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.lambda$null$2(HierarchicalTestExecutor.java:92)
at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
at java.util.Iterator.forEachRemaining(Iterator.java:116)
at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.lambda$execute$3(HierarchicalTestExecutor.java:92)
at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:77)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:51)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:43)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:170)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:154)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:90)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:62)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

 

Adrian

Please sign in to leave a comment.

1 comment

0
Avatar

Hi Adrian,

This is happening because none of the alignment operations have been initialised.  An easy way to fix the test is to initialise all the bundled plugins by replacing:
TestGeneious.initialize() with TestGeneious.initializeAllBundledPlugins()

If you want to avoid initialising all of the plugins in your test you can use TestGeneious.initializePlugins("com.biomatters.plugins.clustal.ClustalPlugin", "com.biomatters.plugins.translationalign.TranslationAlignmentPlugin").  You can add any of the plugins you want into that list.

See http://assets.geneious.com/developer/geneious/javadoc/8.0.0/com/biomatters/geneious/publicapi/plugin/TestGeneious.html for more details.

Cheers,
Matthew

Matthew Cheung 0 votes
Comment actions Permalink