Class SequenceAnnotationGenerator
- java.lang.Object
-
- com.biomatters.geneious.publicapi.plugin.SequenceAnnotationGenerator
-
public abstract class SequenceAnnotationGenerator extends java.lang.Object
A SequenceAnnotationGenerator generates annotations on a sequence, set of sequences, or an alignment. Despite its name, a SequenceAnnotationGenerator can also remove annotations, insert/delete/modify residues in a sequence and can modify document field values and notes. Currently, all SequenceAnnotationGenerators are made available from within the SequenceViewer 'Annotated & Predict' drop down menu. A plugin may provide a set of sequence annotation generators viaGeneiousPlugin.getSequenceAnnotationGenerators()
. Here is an example of a SequenceAnnotationGenerator the implements a simple motif finder.public class ExampleSequenceAnnotationGenerator extends SequenceAnnotationGenerator { public GeneiousActionOptions getActionOptions() { return new GeneiousActionOptions("Example Find Motif", "Finds a non-ambiguous motif and creates annotations covering each occurance"). setMainMenuLocation(GeneiousActionOptions.MainMenu.Sequence); } public String getHelp() { return "This plugin shows how to create a simple SequenceAnnotationGenerator by providing a simple implemenation of a Motif finder."; } public Options getOptions(AnnotatedPluginDocument[] documents, SelectionRange selectionRange) throws DocumentOperationException { return new ExampleSequenceAnnotationGeneratorOptions(); // Provides all the options we display to the user. See ExampleSequenceAnnotationGeneratorOptions below for details. } public DocumentSelectionSignature[] getSelectionSignatures() { return new DocumentSelectionSignature[] { new DocumentSelectionSignature(NucleotideSequenceDocument.class,1,1) // This indicates this annotation generator will accept a single nucleotide sequence as input }; } public
For more advanced usage, such as deleting annotations, or modifiying bases/residues, implementList<List<SequenceAnnotation>>
generateAnnotations(AnnotatedPluginDocument[] annotatedPluginDocuments, SelectionRange selectionRange, ProgressListener progressListener, Options _options) throws DocumentOperationException { NucleotideSequenceDocument sequence= (NucleotideSequenceDocument) annotatedPluginDocuments[0].getDocument(); // We can safely access the first element from the array since our selection signature specifies we accept 1 and only 1 document. // And we can safely cast it to a NucleotideSequenceDocument as the selection signature specified that too. ExampleSequenceAnnotationGeneratorOptions options = (ExampleSequenceAnnotationGeneratorOptions) _options; // We can safely cast this to ExampleSequenceAnnotationGeneratorOptions because that is all we ever return from getOptions() String sequenceString=sequence.getSequenceString().toUpperCase();List<SequenceAnnotation> results = new ArrayList<SequenceAnnotation>();
String basesToFind=options.getBasesToFind(); if (basesToFind.length()==0) { throw new DocumentOperationException("Must specify at least 1 base to find"); } int indexToSearchFrom=0; int foundIndex; while((foundIndex=sequenceString.indexOf(basesToFind, indexToSearchFrom))>=0) { final SequenceAnnotationInterval interval = new SequenceAnnotationInterval(foundIndex + 1, foundIndex + basesToFind.length()); SequenceAnnotation annotation=new SequenceAnnotation(options.getAnnotationName(),options.getAnnotationType(),interval); results.add(annotation); indexToSearchFrom=foundIndex+1; } if (options.isAlsoFindReverse()) { String reversedSequenceString = SequenceUtilities.reverseComplement(sequenceString).toString(); indexToSearchFrom = 0; while((foundIndex=reversedSequenceString.indexOf(basesToFind, indexToSearchFrom))>=0) { final SequenceAnnotationInterval interval = new SequenceAnnotationInterval(sequenceString.length()-foundIndex, sequenceString.length()-foundIndex - basesToFind.length()+1); SequenceAnnotation annotation=new SequenceAnnotation(options.getAnnotationName(),options.getAnnotationType(),interval); results.add(annotation); indexToSearchFrom=foundIndex+1; } } return Arrays.asList(results); // Put the results in a single element array since we only operate on a single sequence hence there is only 1 set of results. } private static class ExampleSequenceAnnotationGeneratorOptions extends Options { private final BooleanOption alsoFindReverse; private final StringOption basesToFind; private final StringOption annotationType; private final StringOption annotationName; private ExampleSequenceAnnotationGeneratorOptions() { basesToFind = addStringOption("basesToFind","Bases to find",""); alsoFindReverse = addBooleanOption("alsoFindReverse", "Also find on reverse complement", true); annotationType = addStringOption("annotationType","Annotation type", SequenceAnnotation.TYPE_MOTIF); annotationType.setAdvanced(true); annotationType.setDescription("The type of annotations that will be created on each matching occurnace"); annotationName = addStringOption("annotationName","Annotation name", ""); annotationName.setAdvanced(true); annotationName.setDescription("The name of the annotations that will be created on each matching occurnace"); } public boolean isAlsoFindReverse() { return alsoFindReverse.getValue(); } public String getBasesToFind() { return basesToFind.getValue().toUpperCase(); } public String getAnnotationType() { return annotationType.getValue(); } public String getAnnotationName() { return annotationName.getValue(); } } }generate(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument[], com.biomatters.geneious.publicapi.plugin.SequenceAnnotationGenerator.SelectionRange, jebl.util.ProgressListener, Options)
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SequenceAnnotationGenerator.AnnotationGeneratorResult
Represents the result of a single sequence from calling an annotation generator viagenerate(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument[], com.biomatters.geneious.publicapi.plugin.SequenceAnnotationGenerator.SelectionRange, jebl.util.ProgressListener, Options)
static class
SequenceAnnotationGenerator.AnnotationGeneratorResultOnAlignment
Represents the results of running a generator on a single alignment.static class
SequenceAnnotationGenerator.AnnotationGeneratorResultsOnSingleSequence
An implementation of a List ofSequenceAnnotationGenerator.AnnotationGeneratorResult
where all elements except one are empty results.static class
SequenceAnnotationGenerator.SelectionGrabOption
If any option returned fromgetOptions(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument[], com.biomatters.geneious.publicapi.plugin.SequenceAnnotationGenerator.SelectionRange)
is a SelectionGrabOption then the sequence viewer will interact with the option such that when the user clicks on the button representing this option, the current selection in the sequence viewer is copied to this option value.static class
SequenceAnnotationGenerator.SelectionRange
represents a rectangular selection range in a list of sequences, and also behaves like a Linked List in that it provides a link to the next SelectionRange in a chain of selections (seeSequenceAnnotationGenerator.SelectionRange.getNext()
.static class
SequenceAnnotationGenerator.SingleSequenceResultGenerator
Provides a system for a SequenceAnnotationGenerator to generate results for just a single sequence.
-
Constructor Summary
Constructors Constructor Description SequenceAnnotationGenerator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.util.List<SequenceAnnotationGenerator.AnnotationGeneratorResult>
generate(AnnotatedPluginDocument[] documents, SequenceAnnotationGenerator.SelectionRange selectionRange, jebl.util.ProgressListener progressListener, Options options)
Create annotations (and/or deletes annotations and/or modifies residues and/or modifies field values) on a set of documents.java.util.List<java.util.List<SequenceAnnotation>>
generateAnnotations(AnnotatedPluginDocument[] documents, SequenceAnnotationGenerator.SelectionRange selectionRange, jebl.util.ProgressListener progressListener, Options options)
Deprecated.usegenerate
instead.java.util.List<java.util.List<SequenceAnnotation>>
generateAnnotations(SequenceAnnotationGenerator.SelectionRange selectionRange, jebl.util.ProgressListener progressListener, Options options, AnnotatedPluginDocument... documents)
java.util.List<java.util.List<SequenceAnnotation>>
generateAnnotations(SequenceAnnotationGenerator.SelectionRange selectionRange, jebl.util.ProgressListener progressListener, Options options, java.util.List<AnnotatedPluginDocument> documents)
java.util.List<SequenceAnnotationGenerator.AnnotationGeneratorResultOnAlignment>
generateOnAlignments(AnnotatedPluginDocument[] documents, jebl.util.ProgressListener progressListener, Options options)
Create annotations (and/or deletes annotations and/or modifies residues and/or modifies field values) on a set of alignments.abstract GeneiousActionOptions
getActionOptions()
GeneiousActionOptions contains all the important status information including name, description, icon, where the action is displayed in the interface etc.java.util.List<java.lang.String>
getAnnotationQualifiersToShowAfterNameForRealTimeAnnotations(Options options)
If this is a real time annotation generator (i.e.Options
getGeneralOptions()
Gets some Options that work for this annotation generator when invoked on any set of input sequences.SequenceAnnotationGroup
getGeneratedAnnotationGroup()
Get the types of annotations this generator generates.abstract java.lang.String
getHelp()
Help for this operation in the form of HTML or plain text.java.lang.String
getNameInSequenceViewer()
Specifies whether this annotation generator should appear (and with what name) in the controls on the right-hand side of the sequence viewer and update annotations in real time as the user edits the sequences and/or changes options for this annotation generator.Options
getOptions(AnnotatedPluginDocument[] documents, SequenceAnnotationGenerator.SelectionRange selectionRange)
Provides some options applicable to this annotation generator to the user.Options
getOptions(AnnotatedPluginDocument[] documents, SequenceAnnotationGenerator.SelectionRange selectionRange, boolean compactOptions)
Similar togetOptions(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument[], com.biomatters.geneious.publicapi.plugin.SequenceAnnotationGenerator.SelectionRange)
except that ifcompactOptions==true
then options returned may be more visually compact for rendering in a smaller region, such as in the sequence viewer controls in the case wheregetNameInSequenceViewer()
is not null.Options
getOptions(SequenceAnnotationGenerator.SelectionRange selectionRange, AnnotatedPluginDocument... documents)
Options
getOptions(SequenceAnnotationGenerator.SelectionRange selectionRange, java.util.List<AnnotatedPluginDocument> documents)
abstract DocumentSelectionSignature[]
getSelectionSignatures()
Signatures of set of documents this generator will work on.SequenceAnnotationGenerator.SingleSequenceResultGenerator
getSingleSequenceGenerator(Options options)
Optionally provides an alternative way of generating annotations for large data sets to reduce memory usage.java.lang.String
getUniqueId()
Get a unique identifier for this SequenceAnnotationGenerator.boolean
isSimilarAnnotation(SequenceAnnotation annotationGeneratedByThisGenerator, SequenceAnnotation existingAnnotationOfSameType)
Determines whether an annotation generated by this generator is similar enough to an existing annotation on a sequence such that the generated annotation should not be displayed to the user.boolean
restorePreferenceApplies(int maximumSequenceLength, int numberOfSequences)
Defines whether this generator should remember its preference (and potentially generate annotations as soon as a document is selected) or not.boolean
resultsDependOnAllInputAlignments()
boolean
showDialogIfNoResultsFound()
boolean
usesAnnotationsOnInputSequences()
Returns true if this annotation generator looks at the annotations on input sequences.
-
-
-
Method Detail
-
getActionOptions
public abstract GeneiousActionOptions getActionOptions()
GeneiousActionOptions contains all the important status information including name, description, icon, where the action is displayed in the interface etc.- Returns:
- options for action; must not be null
-
getHelp
public abstract java.lang.String getHelp()
Help for this operation in the form of HTML or plain text. This should give a brief description of any selection signatures this operation can act on and what the effect is. See some of the standard operations in Geneious for examples (eg. Alignment). This text is displayed when the user tries to perform the operation on documents which do not match the selection signature or if the user clicks the help button in the operation's options panel. May return null. An annotation generator that wants to provide more detailed help on how to use it should implementOptions.getOptionsHelp()
on the Options returned fromgetOptions
- Returns:
- the help
- See Also:
Options.getOptionsHelp()
-
getSelectionSignatures
public abstract DocumentSelectionSignature[] getSelectionSignatures()
Signatures of set of documents this generator will work on. A generator does not need to unnecessarily support multiple sequences or alignments. Geneious will automatically build a generator that handles multiple sequences or alignments from a generator that handles only single sequences. If a SequenceAnnotationGenerator accepts multiple contigs or alignments as input then it must implementgenerateOnAlignments(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument[], jebl.util.ProgressListener, Options)
- Returns:
- all supported signatures. Cannot be null
-
getNameInSequenceViewer
public java.lang.String getNameInSequenceViewer()
Specifies whether this annotation generator should appear (and with what name) in the controls on the right-hand side of the sequence viewer and update annotations in real time as the user edits the sequences and/or changes options for this annotation generator. If this method returns a non-null value, this annotation generator may wish to return a non-null value fromgetGeneratedAnnotationGroup()
Any annotation generator visible in the sequence viewer may choose to return aSequenceAnnotationGenerator.SelectionGrabOption
as part of itsgetOptions
to allow the user to option values that represent a range of residues in a sequence.- Returns:
- the name of this as annotation generator if it should appear in the controls on the right-hand side of the sequence viewer. The default implementation returns null meaning it will not appear inside the sequence viewer.
-
isSimilarAnnotation
public boolean isSimilarAnnotation(SequenceAnnotation annotationGeneratedByThisGenerator, SequenceAnnotation existingAnnotationOfSameType)
Determines whether an annotation generated by this generator is similar enough to an existing annotation on a sequence such that the generated annotation should not be displayed to the user. The default implementaion just callsSequenceAnnotation.equals(Object)
.- Parameters:
annotationGeneratedByThisGenerator
- an annotation generated by this annotation generator.existingAnnotationOfSameType
- an annotation that is already on a sequence and has the sameSequenceAnnotation.getType()
as the first annotation.- Returns:
- true if the generated annotation is similar enough to the existing annotation such that the generated annotation should not be displayed to the user (in this case we may display a message informing the user about the number of ignored annotations)
-
getGeneratedAnnotationGroup
public SequenceAnnotationGroup getGeneratedAnnotationGroup()
Get the types of annotations this generator generates. An annotation generator may choose to return null in which case it is free to return annotations of any type.- Returns:
- a group containing the types of annotations this generator generates
-
getOptions
public Options getOptions(AnnotatedPluginDocument[] documents, SequenceAnnotationGenerator.SelectionRange selectionRange) throws com.biomatters.geneious.publicapi.plugin.DocumentOperationException
Provides some options applicable to this annotation generator to the user. This is guaranteed to be called beforegenerate
The user can click "Cancel" at this point andgenerate
will not be called The same Options object will be passed to generateAnnotations if the user clicks "Ok". The necessary values can then be extracted from it. Example 1: Use Options class directly.
public Options getOptions(final AnnotatedPluginDocument[] documents, final SelectionRange selectionRange) throws DocumentOperationException { Options options = new Options(getClass()); options.addOptionBooleanOption("optionName", "text displayed the user", true); return options; } public List<List<SequenceAnnotation>> generateAnnotations(AnnotatedPluginDocument[] documentList, SelectionRange selectionRange, ProgressListener progressListener, Options options) throws DocumentOperationException { boolean checkboxSelected=(Boolean)options.getValue("optionName"); ... }
private static class MyOptions extends Options { private BooleanOption sampleOption; public MyOptions() { sampleOption=addBooleanOption("sampleOption", "text displayed the user", true); } public boolean isSampleOption() { return sampleOption.getValue(); } } public Options getOptions(final AnnotatedPluginDocument[] documents, final SelectionRange selectionRange) throws DocumentOperationException { return new MyOptions(); } public List<List<SequenceAnnotation>> generateAnnotations(AnnotatedPluginDocument[] documentList, SelectionRange selectionRange, ProgressListener progressListener, Options options) throws DocumentOperationException { MyOptions myOptions= (MyOptions) options; // Since an instance of MyOptions is always returned from getOptions, this cast is always valid. boolean sampleOptionSelected = myOptions.isSampleOption(); ... }
Options
. This method may be invoked from either the swing thread or a non-swing thread.- Parameters:
documents
- the documents to generate annotations for. These are provided so that the Options can contain different options depending on the documents. This can be ignored in most cases.selectionRange
- the selected sequences and residues or null if everything is selected. If there are multiple selected ranges they may appear in any order. If you need access to the residue intervals sorted from left to right, useSequenceAnnotationGenerator.SelectionRange.getResidueIntervals()
- Returns:
- options that can be displayed to the user or null if this operation has no options.
- Throws:
com.biomatters.geneious.publicapi.plugin.DocumentOperationException
- if obtaining the options for this annotation generator is unsuccessful for any reason- See Also:
getOptions(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument[], com.biomatters.geneious.publicapi.plugin.SequenceAnnotationGenerator.SelectionRange, boolean)
-
getGeneralOptions
public Options getGeneralOptions() throws com.biomatters.geneious.publicapi.plugin.DocumentOperationException
Gets some Options that work for this annotation generator when invoked on any set of input sequences. Annotation generators should implement getGeneralOptions in order for them to be configurable from Workflows.- Returns:
- some Options suitable for running on any supported set of input documents. This options will never be passed directly to
a generateAnnotations call. Instead, getOptions will be called at runtime and any applicable option values will be copied from the general
options to the specific options using
Options.valuesToXML(String)
andOptions.valuesFromXML(org.jdom.Element)
- Throws:
com.biomatters.geneious.publicapi.plugin.DocumentOperationException
- if this annotation generator does not support general options.- Since:
- API 4.700 (Geneious 7.0.0)
-
getOptions
public Options getOptions(AnnotatedPluginDocument[] documents, SequenceAnnotationGenerator.SelectionRange selectionRange, boolean compactOptions) throws com.biomatters.geneious.publicapi.plugin.DocumentOperationException
Similar togetOptions(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument[], com.biomatters.geneious.publicapi.plugin.SequenceAnnotationGenerator.SelectionRange)
except that ifcompactOptions==true
then options returned may be more visually compact for rendering in a smaller region, such as in the sequence viewer controls in the case wheregetNameInSequenceViewer()
is not null. The default implementation just callsgetOptions(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument[], com.biomatters.geneious.publicapi.plugin.SequenceAnnotationGenerator.SelectionRange)
. This method may be invoked from either the swing thread or a non-swing thread.- Parameters:
documents
- the documents to generate annotations for. These are provided so that the Options can contain different options depending on the documents. This can be ignored in most cases.selectionRange
- the selected sequences and residues or null if everything is selected. If there are multiple selected ranges they may appear in any order. If you need access to the residue intervals sorted from left to right, useSequenceAnnotationGenerator.SelectionRange.getResidueIntervals()
compactOptions
- true to create a more visually compact representation of the options (see above)- Returns:
- options that can be displayed to the user or null if this operation has no options.
- Throws:
com.biomatters.geneious.publicapi.plugin.DocumentOperationException
- if obtaining the options for this annotation generator is unsuccessful for any reason- See Also:
getOptions(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument[], com.biomatters.geneious.publicapi.plugin.SequenceAnnotationGenerator.SelectionRange)
-
getOptions
public final Options getOptions(SequenceAnnotationGenerator.SelectionRange selectionRange, java.util.List<AnnotatedPluginDocument> documents) throws com.biomatters.geneious.publicapi.plugin.DocumentOperationException
A convenience method for callinggetOptions(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument[], com.biomatters.geneious.publicapi.plugin.SequenceAnnotationGenerator.SelectionRange)
This method may be invoked from either the swing thread or a non-swing thread.- Parameters:
selectionRange
- the selected sequences and residues or null if everything is selected.If there are multiple selected ranges they may appear in any order. If you need access to the residue intervals sorted from left to right, useSequenceAnnotationGenerator.SelectionRange.getResidueIntervals()
documents
- the documents to generate annotations for. These are provided so that the Options can contain different options depending on the documents. This can be ignored in most cases.- Returns:
- options that can be displayed to the user or null if this operation has no options.
- Throws:
com.biomatters.geneious.publicapi.plugin.DocumentOperationException
- if the operation is unsuccessful for any reason
-
getOptions
public final Options getOptions(SequenceAnnotationGenerator.SelectionRange selectionRange, AnnotatedPluginDocument... documents) throws com.biomatters.geneious.publicapi.plugin.DocumentOperationException
A convenience method for callinggetOptions(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument[], com.biomatters.geneious.publicapi.plugin.SequenceAnnotationGenerator.SelectionRange)
This method may be invoked from either the swing thread or a non-swing thread.- Parameters:
selectionRange
- the selected sequences and residues or null if everything is selected. If there are multiple selected ranges they may appear in any order. If you need access to the residue intervals sorted from left to right, useSequenceAnnotationGenerator.SelectionRange.getResidueIntervals()
documents
- the documents to generate annotations for. These are provided so that the Options can contain different options depending on the documents. This can be ignored in most cases.- Returns:
- options that can be displayed to the user or null if this operation has no options.
- Throws:
com.biomatters.geneious.publicapi.plugin.DocumentOperationException
- if the operation is unsuccessful for any reason
-
generate
public java.util.List<SequenceAnnotationGenerator.AnnotationGeneratorResult> generate(AnnotatedPluginDocument[] documents, SequenceAnnotationGenerator.SelectionRange selectionRange, jebl.util.ProgressListener progressListener, Options options) throws com.biomatters.geneious.publicapi.plugin.DocumentOperationException
Create annotations (and/or deletes annotations and/or modifies residues and/or modifies field values) on a set of documents. Note: The operation will be run in a non AWT thread. If you need to perform user interface interaction in addition to the options provided in the Options (for example prompting for user input) then you need to place this inside a ThreadUtilities.invokeAndWait() function call. WARNING: Geneious may call this method multiple times simultaneously. Therefore, any implementation should not store its internal state within instance fields.- Parameters:
documents
- the documents to generate annotations for which will matchgetSelectionSignatures()
selectionRange
- the selected sequences and residues or null if everything is selected. If there are multiple selected ranges they may appear in any order. If you need access to the residue intervals sorted from left to right, useSequenceAnnotationGenerator.SelectionRange.getResidueIntervals()
progressListener
- report progress for slow operations. If the progressListener requests that the operation cancels, the operation may choose to throw aDocumentOperationException.Canceled
options
- the options returned fromgetOptions
- Returns:
- a list equal in length to the number of sequences in
documents
. If any of the documents indocuments
are alignments or sequence lists, then the returned list must have an entry for each of those sequences (that matchgetSelectionSignatures()
) within the alignment/sequence list. Furthermore, if the input document is an alignment, the returned list may contain 1 additional entry (at indexSequenceAlignmentDocument.getNumberOfSequences()
) representing annotations for the consensus sequence. Generators on large alignments may choose to return aSequenceAnnotationGenerator.AnnotationGeneratorResultsOnSingleSequence
to allow the calling code to recognize it does not need to iterate over all elements in the returned list - Throws:
com.biomatters.geneious.publicapi.plugin.DocumentOperationException
- when something goes wrong.
-
generateOnAlignments
public java.util.List<SequenceAnnotationGenerator.AnnotationGeneratorResultOnAlignment> generateOnAlignments(AnnotatedPluginDocument[] documents, jebl.util.ProgressListener progressListener, Options options) throws com.biomatters.geneious.publicapi.plugin.DocumentOperationException
Create annotations (and/or deletes annotations and/or modifies residues and/or modifies field values) on a set of alignments. A generator only needs to implement this method if its selection signaturegetSelectionSignatures()
indicates it accepts more than 1 alignment. Most annotation generators should implementgenerate(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument[], com.biomatters.geneious.publicapi.plugin.SequenceAnnotationGenerator.SelectionRange, jebl.util.ProgressListener, Options)
instead. Note: The operation will be run in a non AWT thread. If you need to perform user interface interaction in addition to the options provided in the Options (for example prompting for user input) then you need to place this inside a ThreadUtilities.invokeAndWait() function call. WARNING: Geneious may call this method multiple times simultaneously. Therefore, any implementation should not store its internal state within instance fields. If the generator accepts only 1 alignment but you may need to annotate the consensus sequence, still usegenerate(AnnotatedPluginDocument[], SelectionRange, ProgressListener, Options)
. See the method's documentation for how to indicate the generated annotations should be on the consensus.- Parameters:
documents
- the documents to generate annotations for.progressListener
- report progress for slow operations. If the progressListener requests that the operation cancels, the operation may choose to throw aDocumentOperationException.Canceled
options
- the options returned fromgetOptions
- Returns:
- a list consists of 1 element per alignment in the input documents.
- Throws:
com.biomatters.geneious.publicapi.plugin.DocumentOperationException
- when something goes wrong.- Since:
- API 4.50 (Geneious 5.5.0)
-
generateAnnotations
@Deprecated public java.util.List<java.util.List<SequenceAnnotation>> generateAnnotations(AnnotatedPluginDocument[] documents, SequenceAnnotationGenerator.SelectionRange selectionRange, jebl.util.ProgressListener progressListener, Options options) throws com.biomatters.geneious.publicapi.plugin.DocumentOperationException
Deprecated.usegenerate
instead. Create annotations from a set of documents. Note: The operation will be run in a non AWT thread. If you need to perform user interface interaction in addition to the options provided in the Options (for example prompting for user input) then you need to place this inside a ThreadUtilities.invokeAndWait() function call. WARNING: Geneious may call this method multiple times simultaneously. Therefore, any implementation should not store its internal state within instance fields.
WARNING: The default implementation of this method callsgenerate(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument[], com.biomatters.geneious.publicapi.plugin.SequenceAnnotationGenerator.SelectionRange, jebl.util.ProgressListener, Options)
but returns only the list of annotations, so any tracks, residue additions or deletions, and annotation deletions, and generated documents will not be respected. If you are invoking a SequenceAnnotationGenerator in another plugin, callgenerate(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument[], com.biomatters.geneious.publicapi.plugin.SequenceAnnotationGenerator.SelectionRange, jebl.util.ProgressListener, Options)
instead.- Parameters:
documents
- the documents to generate annotations for. These are provided so that the Options can contain different options depending on the documents. This can be ignored in most cases.selectionRange
- the selected sequences and residues or null if everything is selected.progressListener
- report progress for slow operations. If the progressListener requests that the operation cancels, the operation may choose to throw aDocumentOperationException.Canceled
options
- the options returned fromgetOptions
- Returns:
- a list equal in length to the number of sequences in
documents
. If any of the documents indocuments
are alignments or sequence lists, then the returned list must have an entry for each of those sequences (that matchgetSelectionSignatures()
) within the alignment/sequence list. Furthermore, if the input document is an alignment, the returned list may contain 1 additional entry (at indexSequenceAlignmentDocument.getNumberOfSequences()
) representing annotations for the consensus sequence. - Throws:
com.biomatters.geneious.publicapi.plugin.DocumentOperationException
- when something goes wrong.
-
generateAnnotations
public final java.util.List<java.util.List<SequenceAnnotation>> generateAnnotations(SequenceAnnotationGenerator.SelectionRange selectionRange, jebl.util.ProgressListener progressListener, Options options, AnnotatedPluginDocument... documents) throws com.biomatters.geneious.publicapi.plugin.DocumentOperationException
A convenience method for callinggenerateAnnotations(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument[], com.biomatters.geneious.publicapi.plugin.SequenceAnnotationGenerator.SelectionRange, jebl.util.ProgressListener, Options)
- Parameters:
documents
- the documents to generate annotations for.selectionRange
- the selected sequences and residues or null if everything is selected. If there are multiple selected ranges they may appear in any order. If you need access to the residue intervals sorted from left to right, useSequenceAnnotationGenerator.SelectionRange.getResidueIntervals()
progressListener
- report progress for slow operations. If the progressListener requests that the operation cancels, the operation may choose to throw aDocumentOperationException.Canceled
options
- the options returned fromgetOptions
- Returns:
- a list equal in length to the number of sequences in
documents
. If any of the documents indocuments
are alignments or sequence lists, then the returned list must have an entry for each of those sequences (that matchgetSelectionSignatures()
) within the alignment/sequence list. Furthermore, if the input document is an alignment, the returned list may contain 1 additional entry (at indexSequenceAlignmentDocument.getNumberOfSequences()
) representing annotations for the consensus sequence. - Throws:
com.biomatters.geneious.publicapi.plugin.DocumentOperationException
- when something goes wrong.
-
generateAnnotations
public final java.util.List<java.util.List<SequenceAnnotation>> generateAnnotations(SequenceAnnotationGenerator.SelectionRange selectionRange, jebl.util.ProgressListener progressListener, Options options, java.util.List<AnnotatedPluginDocument> documents) throws com.biomatters.geneious.publicapi.plugin.DocumentOperationException
A convenience method for callinggenerateAnnotations(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument[], com.biomatters.geneious.publicapi.plugin.SequenceAnnotationGenerator.SelectionRange, jebl.util.ProgressListener, Options)
- Parameters:
documents
- the documents to generate annotations for.selectionRange
- the selected sequences and residues or null if everything is selected. If there are multiple selected ranges they may appear in any order. If you need access to the residue intervals sorted from left to right, useSequenceAnnotationGenerator.SelectionRange.getResidueIntervals()
progressListener
- report progress for slow operations. If the progressListener requests that the operation cancels, the operation may choose to throw aDocumentOperationException.Canceled
options
- the options returned fromgetOptions
- Returns:
- a list equal in length to the number of sequences in
documents
. If any of the documents indocuments
are alignments or sequence lists, then the returned list must have an entry for each of those sequences (that matchgetSelectionSignatures()
) within the alignment/sequence list. Furthermore, if the input document is an alignment, the returned list may contain 1 additional entry (at indexSequenceAlignmentDocument.getNumberOfSequences()
) representing annotations for the consensus sequence. - Throws:
com.biomatters.geneious.publicapi.plugin.DocumentOperationException
- when something goes wrong.
-
getUniqueId
public java.lang.String getUniqueId()
Get a unique identifier for this SequenceAnnotationGenerator. This is so thatPluginUtilities.getSequenceAnnotationGenerator(String)
can be used to find this SequenceAnnotationGenerator. A unique identifier may consist of any valid Java identifier characters (seeCharacter.isJavaIdentifierPart(char)
as well as to the space character.- Returns:
- a unique identifier for this SequenceAnnotationGenerator. The default implementation returns the className.
-
usesAnnotationsOnInputSequences
public boolean usesAnnotationsOnInputSequences()
Returns true if this annotation generator looks at the annotations on input sequences. If this method returns false, then this allows the sequence viewer to improve performance by not applying any unsaved annotation changes to a temporary document before invoking the annotation generator. The default implementation returns true.- Returns:
- true if this annotation generator looks at the annotations on input sequences.
- Since:
- API 4.51 (Geneious 5.5.1)
-
getSingleSequenceGenerator
public SequenceAnnotationGenerator.SingleSequenceResultGenerator getSingleSequenceGenerator(Options options)
Optionally provides an alternative way of generating annotations for large data sets to reduce memory usage. Instead of callinggenerate(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument[], com.biomatters.geneious.publicapi.plugin.SequenceAnnotationGenerator.SelectionRange, jebl.util.ProgressListener, Options)
(or one of the variants of it), the caller may request aSequenceAnnotationGenerator.SingleSequenceResultGenerator
which it can invoke for a singleSequenceDocument
. The options are provided now rather than as part ofSequenceAnnotationGenerator.SingleSequenceResultGenerator.generate(com.biomatters.geneious.publicapi.documents.PluginDocument, com.biomatters.geneious.publicapi.plugin.SequenceAnnotationGenerator.SelectionRange, jebl.util.ProgressListener)
so that the implementation can parse them once to improve performance over multiple calls toSequenceAnnotationGenerator.SingleSequenceResultGenerator.generate(com.biomatters.geneious.publicapi.documents.PluginDocument, com.biomatters.geneious.publicapi.plugin.SequenceAnnotationGenerator.SelectionRange, jebl.util.ProgressListener)
getSingleSequenceGenerator is not supported in conjunction withSequenceAnnotationGenerator.AnnotationGeneratorResult.addGeneratedDocument(AnnotatedPluginDocument)
.- Parameters:
options
- some options previously returned fromgetOptions(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument[], com.biomatters.geneious.publicapi.plugin.SequenceAnnotationGenerator.SelectionRange)
(or one of its variants)- Returns:
- a SingleSequenceResultGenerator for generating results on a single sequence at a time or null if this annotation generator doesn't support this functionality
- Since:
- API 4.40 (Geneious 5.4.0)
-
getAnnotationQualifiersToShowAfterNameForRealTimeAnnotations
public java.util.List<java.lang.String> getAnnotationQualifiersToShowAfterNameForRealTimeAnnotations(Options options)
If this is a real time annotation generator (i.e. it returned a non-null name fromgetNameInSequenceViewer()
) then while the sequence viewer is displaying un-applied annotations for this generator, the given qualifiers will also be displayed after the name. For example the "Annotate from Database" shows the transferred similarity after the name of annotations (as long as the similarity setting is under 100%)- Parameters:
options
- the options for this generator, returned fromgetOptions(com.biomatters.geneious.publicapi.plugin.SequenceAnnotationGenerator.SelectionRange, java.util.List)
or a variant getOptions method.- Returns:
- the names of annotation qualifiers to display after the name of the annotation
- Since:
- API 4.600 (Geneious 6.0.0)
-
resultsDependOnAllInputAlignments
public boolean resultsDependOnAllInputAlignments()
- Returns:
- true if when this annotation generator is invoked with
generateOnAlignments(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument[], jebl.util.ProgressListener, Options)
the results produced on one alignment are affected by the properties of other alignments. - Since:
- API 4.801 (Geneious 8.0.1)
-
showDialogIfNoResultsFound
public boolean showDialogIfNoResultsFound()
- Returns:
- true if core Geneious should display a message dialog to the user if this generator returns no results. The default implementation returns true
- Since:
- API 4.810 (Geneious 8.1.0)
-
restorePreferenceApplies
public boolean restorePreferenceApplies(int maximumSequenceLength, int numberOfSequences)
Defines whether this generator should remember its preference (and potentially generate annotations as soon as a document is selected) or not. Whether a generator should restore its preference may depend on the longest selected sequence and number of sequences. The scope of sequences for which the preference gets restored might be defined elsewhere, so even if this method returns true, the preference may not get restored for all sequences the same. E.g. even if this method returns true, the preference for circular sequences might be stored separately from linear sequences.- Parameters:
maximumSequenceLength
- the maximum sequence length of the selected sequencesnumberOfSequences
- the number of selected sequences- Returns:
- true if this generator should remember its preference. The default implementation returns false
- Since:
- API 4.201900 (Geneious 2019.0.0)
-
-