Class PluginUtilities
- java.lang.Object
-
- com.biomatters.geneious.publicapi.plugin.PluginUtilities
-
public final class PluginUtilities extends java.lang.Object
Provides various functionality to access other installed plug-ins. For example, exporting, importing, performing sequence alignment, and accessing annotation generators.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PluginUtilities.WritableDatabaseServicesListener
A listener used for notifying when root WritableDatabaseServices are added or removed in Geneious.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
LOCAL_DATABASE_SERVICE_UNIQUE_ID
The unique ID of the local database root "Local" service.static java.lang.String
SEARCH_RESULTS_SERVICE_UNIQUE_ID
The unique ID of the local database root "Searches" service.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addWritableDatabaseServiceRootListener(PluginUtilities.WritableDatabaseServicesListener listener)
Add a listener to be notificed when root WritableDatabaseServices are added or removed.static DocumentSelectionOption.FolderOrDocuments
displayDocumentSearchDialog(java.lang.String preferenceKey, DocumentSearchCache searchCache, java.util.Set<DocumentType> documentTypes, DocumentFilter documentFilter, java.lang.String documentTypeDescription, java.util.List<AnnotatedPluginDocument> extraDocuments, DocumentSelectionOption.FolderOrDocuments initialSelection, java.util.List<DocumentField> fieldsToDisplay, boolean allowMultipleSelection, boolean showUseAllButton, javax.swing.JComponent owner)
Display a dialog allowing the user to choose document(s) from their local database (or connected shared databases).static SequenceAlignmentDocument
doAlignment(java.util.List<SequenceDocument> sequences, jebl.util.ProgressListener progressListener)
Prompts the user to perform an alignment using any of the available alignment plugins.static void
exportDocuments(java.io.File file, AnnotatedPluginDocument... documentsToExport)
Exports these documents to this file in a format suitable for the given file's extension.static void
exportDocumentsInGeneiousFormat(java.io.File outputFile, boolean useCompression, AnnotatedPluginDocument... documents)
Exports the given documents in Geneious format (zip compressed), to the given file.static void
exportDocumentsInGeneiousFormat(java.io.File outputFile, jebl.util.ProgressListener progressListener, AnnotatedPluginDocument... documents)
Exports the given documents in Geneious format (zip compressed), to the given file.static void
exportDocumentsInGeneiousFormat(java.io.File outputFile, jebl.util.ProgressListener progressListener, Geneious.MajorVersion minimumVersionToTryToMakeCompatibleWith, Geneious.MajorVersion minimumVersionMustBeCompatibleWith, Geneious.MajorVersion minimumVersionToNotWarnAboutDataLossWhenImporting, java.util.List<AnnotatedPluginDocument> documents)
Exports the given documents in Geneious format (zip compressed), to the given file.static void
exportDocumentsInGeneiousFormat(java.io.OutputStream outputStream, jebl.util.ProgressListener progressListener, AnnotatedPluginDocument... documents)
Exports the given documents in Geneious format (zip compressed), to the given output stream.static java.util.List<GeneiousPlugin>
getActiveGeneiousPlugins()
static DocumentOperation
getAlignmentOperation(java.lang.String uniqueIdPrefix, SequenceDocument.Alphabet alphabet)
Get aDocumentOperation
representation of anAlignmentOperation
.static java.util.List<Assembler>
getAssemblers()
Get a list of allAssembler
s provided by all currently installed plugins.static DocumentOperation
getCategoryOperation(GeneiousActionOptions.Category category)
Get the category operation that includes all other operations in this category.static java.lang.Class
getClass(java.lang.String className)
Find a class by name in Geneious or in any installed plugin.static DatabaseFolderImporter
getDatabaseFolderImporter(java.lang.String uniqueID)
get the DatabaseFolderImporter with the given unique ID.static DocumentFileExporter
getDocumentFileExporter(java.lang.String uniqueID)
get the DocumentFileExporter with the given unique ID.static java.util.List<DocumentFileExporter>
getDocumentFileExporters()
Get everyDocumentFileExporter
provided by any plugin.static DocumentFileImporter
getDocumentFileImporter(java.lang.String uniqueID)
get the DocumentFileImporter with the given unique ID.static DocumentFileImporter
getDocumentFileImporterForSingleFile(java.io.File file)
This method returns the document importer that will be used for importing the single file provided.static java.util.List<DocumentFileImporter>
getDocumentFileImporters()
Get everyDocumentFileImporter
provided by any plugin.static DocumentOperation
getDocumentOperation(java.lang.String uniqueID)
get the DocumentOperation with the given unique ID.static java.util.List<DocumentOperation>
getDocumentOperations()
Get a list of allDocumentOperation
s provided by all currently installed plugins.static java.util.List<DocumentViewerFactory>
getDocumentViewerFactories(AnnotatedPluginDocument... documents)
Get a list ofDocumentViewerFactories
provided by all currently installed plugins or optionally restrict the returned list to those that can view a given set of documents.static GeneiousService
getGeneiousService(java.lang.String uniqueID)
Get access to any standard GeneiousService or any 3rd party GeneiousService.static java.util.List<GeneiousService>
getGeneiousServices()
Returns all installed GeneiousServices.static GeneiousPlugin
getPluginForAssembler(Assembler assembler)
static GeneiousPlugin
getPluginForDocumentOperation(DocumentOperation operation)
Get theGeneiousPlugin
that provides a givenDocumentOperation
viaGeneiousPlugin.getDocumentOperations()
static GeneiousPlugin
getPluginForSequenceAnnotationGenerator(SequenceAnnotationGenerator sequenceAnnotationGenerator)
Get theGeneiousPlugin
that provides a givenSequenceAnnotationGenerator
viaGeneiousPlugin.getSequenceAnnotationGenerators()
static SequenceAnnotationGenerator
getSequenceAnnotationGenerator(java.lang.String uniqueID)
get the SequenceAnnotationGenerator with the given unique ID.static java.util.List<SequenceAnnotationGenerator>
getSequenceAnnotationGenerators()
Get a list of allSequenceAnnotationGenerator
s provided by all currently installed pluginsstatic java.util.List<SequenceGraphFactory>
getSequenceGraphFactories()
Get a list of allSequenceGraphFactories
provided by all currently installed pluginsstatic java.util.List<SequenceViewerExtension.Factory>
getSequenceViewerExtensionFactories()
Get a list of allSequenceViewerExtension.Factories
provided by all currently installed pluginsstatic java.util.List<TreeViewerExtension.Factory>
getTreeViewerExtensionFactories()
Get a list of allTreeViewerExtension.Factories
provided by all currently installed pluginsstatic java.util.List<WritableDatabaseService>
getWritableDatabaseServiceRoots()
Returns the root services of all installed WritableDatabaseServices.static java.util.List<AnnotatedPluginDocument>
importDocuments(java.io.File file, java.util.Map<java.lang.String,java.lang.String> extraOptions, jebl.util.ProgressListener progress)
Imports documents from a file into an in memory list.static java.util.List<AnnotatedPluginDocument>
importDocuments(java.io.File file, jebl.util.ProgressListener progress)
Imports documents from a file into an in memory list.static java.util.List<AnnotatedPluginDocument>
importDocumentsToDatabase(java.io.File file, WritableDatabaseService destination, jebl.util.ProgressListener progress)
Imports documents from a file into a database.static void
installPluginSilently(java.io.File pluginFile)
Installs and activates a plugin without providing any feedback to the userstatic boolean
isConfiguringScript()
static boolean
isRunningFromScript()
static void
removeWritableDatabaseServiceRootListener(PluginUtilities.WritableDatabaseServicesListener listener)
Remove a listener previously added usingaddLocalDatabaseSevicesListener
static void
setConfiguringScript(boolean configuringScript)
Sets whether or not the current thread is configuring a script.static void
setRunningFromScript(boolean runningFromScript)
Sets whether or not the current thread is running from a script.
-
-
-
Field Detail
-
SEARCH_RESULTS_SERVICE_UNIQUE_ID
public static final java.lang.String SEARCH_RESULTS_SERVICE_UNIQUE_ID
The unique ID of the local database root "Searches" service. UsegetGeneiousService(String)
to get the service. Note: In Geneious R7 and later, the "Searches" service is no longer used. Search results are now saved in a sub-folder of the query sequence.- Since:
- API 4.50 (Geneious 5.5.0)
- See Also:
- Constant Field Values
-
LOCAL_DATABASE_SERVICE_UNIQUE_ID
public static final java.lang.String LOCAL_DATABASE_SERVICE_UNIQUE_ID
The unique ID of the local database root "Local" service. UsegetGeneiousService(String)
to get the service.- Since:
- API 4.50 (Geneious 5.5.0)
- See Also:
- Constant Field Values
-
-
Method Detail
-
getSequenceAnnotationGenerators
public static java.util.List<SequenceAnnotationGenerator> getSequenceAnnotationGenerators()
Get a list of allSequenceAnnotationGenerator
s provided by all currently installed plugins- Returns:
- a list of all
SequenceAnnotationGenerator
s provided by all currently installed plugins
-
getDocumentOperations
public static java.util.List<DocumentOperation> getDocumentOperations()
Get a list of allDocumentOperation
s provided by all currently installed plugins. Note that categorised operations (such as alignment and tree building) are combined into a single operation. To find the combined alignment operation, you would use returned element in the list which hasDocumentOperation.getActionOptions()
.getCategory()
==Category.Alignment
.- Returns:
- a list of all
DocumentOperation
s provided by all currently installed plugins
-
getAssemblers
public static java.util.List<Assembler> getAssemblers()
Get a list of allAssembler
s provided by all currently installed plugins.- Returns:
- a list of all
Assembler
s provided by all currently installed plugins - Since:
- API 4.14 (Geneious 5.1)
-
getCategoryOperation
public static DocumentOperation getCategoryOperation(GeneiousActionOptions.Category category)
Get the category operation that includes all other operations in this category. e.g. alignment or tree building. This may be null if no such category operation exists.- Returns:
- the category operation that includes all other operations in this category. e.g. alignment or tree building, or null
-
getSequenceGraphFactories
public static java.util.List<SequenceGraphFactory> getSequenceGraphFactories()
Get a list of allSequenceGraphFactories
provided by all currently installed plugins- Returns:
- a list of all
SequenceGraphFactories
provided by all currently installed plugins
-
getTreeViewerExtensionFactories
public static java.util.List<TreeViewerExtension.Factory> getTreeViewerExtensionFactories()
Get a list of allTreeViewerExtension.Factories
provided by all currently installed plugins- Returns:
- a list of all
TreeViewerExtension.Factories
provided by all currently installed plugins
-
getSequenceViewerExtensionFactories
public static java.util.List<SequenceViewerExtension.Factory> getSequenceViewerExtensionFactories()
Get a list of allSequenceViewerExtension.Factories
provided by all currently installed plugins- Returns:
- a list of all
SequenceViewerExtension.Factories
provided by all currently installed plugins - Since:
- API 4.60 (Geneious 5.6.0)
-
getDocumentViewerFactories
public static java.util.List<DocumentViewerFactory> getDocumentViewerFactories(AnnotatedPluginDocument... documents)
Get a list ofDocumentViewerFactories
provided by all currently installed plugins or optionally restrict the returned list to those that can view a given set of documents. The returned list will be sorted in order of decreasing viewer precedence.- Parameters:
documents
- optionally restrict the list of returned factories to only those that can view these documents. Use no documents to get all viewer factories.- Returns:
- a list of
DocumentViewerFactories
provided by all currently installed plugins
-
displayDocumentSearchDialog
public static DocumentSelectionOption.FolderOrDocuments displayDocumentSearchDialog(java.lang.String preferenceKey, DocumentSearchCache searchCache, java.util.Set<DocumentType> documentTypes, DocumentFilter documentFilter, java.lang.String documentTypeDescription, java.util.List<AnnotatedPluginDocument> extraDocuments, DocumentSelectionOption.FolderOrDocuments initialSelection, java.util.List<DocumentField> fieldsToDisplay, boolean allowMultipleSelection, boolean showUseAllButton, javax.swing.JComponent owner)
Display a dialog allowing the user to choose document(s) from their local database (or connected shared databases).- Parameters:
preferenceKey
- a preferences key used for storing the most recently viewed folder and expanded folders.searchCache
- theDocumentSearchCache
searching the documents the user will choose from. Should be null if it isn't feasible to cache all documents of these types in memory. For example, primers can be cached, but SequenceDocuments should not be.documentTypes
- the document types the user will choose their documents from. If searchCache!=null, then this must be the types that correspond to the search cache.documentFilter
- An optional filter to further reject documents even if they are one of the provided documentTypes. May be null to perform no additional filteringdocumentTypeDescription
- An optional description of what the documentTypes and documentFilter accept. For example "linear nucleotide sequences". May be null in which case this implementation will choose an reasonable descriptionextraDocuments
- a list of extra documents (not present in any connected databases) to also display in the dialoginitialSelection
- documents or folder that should be selected initially, may be nullfieldsToDisplay
- a list ofDocumentFields
which will be displayed in columns in the dialog. If the list is null, then one will be created from the fields present on the documents.allowMultipleSelection
- true if the user can select multiple documents at onceshowUseAllButton
- if true, a "Use All" button will be displayed in the dialog which will cause this method to return an empty list when clicked. If false, this method will never return an empty listowner
- the owner component for the dialog- Returns:
- null if the user clicked cancel, the list of documents they selected if they clicked ok
- Since:
- API 4.810 (Geneious 8.1.0)
-
getGeneiousService
public static GeneiousService getGeneiousService(java.lang.String uniqueID)
Get access to any standard GeneiousService or any 3rd party GeneiousService. You can then search these from within your own plugin. The following uniqueIDs are used for standard Geneious services:- LocalDocuments
- LocalDocuments/myfolder1/myfolder2
- SearchResults
- UniProt
- NCBI
- NCBI_genome
- NCBI_nucleotide_gbc
- NCBI_popset_gbc
- NCBI_protein_gpc
- NCBI_pubmed
- NCBI_structure
- NCBI_BLAST
- NCBI_blastp
- NCBI_blastn
- NCBI_blastx
- NCBI_tblastn
- NCBI_tblastx
- rootService
- BMCollaboration
- BMCollaboration_account@domain
- BMCollaboration_account@domain_contact@domain
- BMCollaboration_account@domain_contact@domain_folderName
- BMCollaboration_account@domain_contact@domain_folderName_folderName
for (GeneiousService service : PluginUtilities.getGeneiousServices()) { System.out.println(service.getUniqueID()); }
- Parameters:
uniqueID
- a unique ID as described above or the unique ID returned from anyGeneiousService.getUniqueID()
- Returns:
- the GeneiousService or null if it's not found (for example, not currently installed) or null if it is unavailable (e.g. it has not finished initializing, or it is restricted because there is no active license)
Most GeneiousServices are
DatabaseServices
, so you can usually cast the return type to that.
-
getDocumentOperation
public static DocumentOperation getDocumentOperation(java.lang.String uniqueID)
get the DocumentOperation with the given unique ID. To view a list of all DocumentOperation unique IDs, you can callDocumentOperation.getUniqueId()
on each of the results returned fromgetDocumentOperations()
e.g.
for (DocumentOperation operation : PluginUtilities.getDocumentOperations())
A
System.out.println("Operation: "+operation.getUniqueId());DocumentOperation
version of anAlignmentOperation
can be retrieved from this method by passing in the unique id prefix (AlignmentOperation.getUniqueIdPrefix()
) of the alignment operation with either "_NUCLEOTIDE_" or "_PROTEIN_" on the end depending on which sequence type you wish to align. eg."Geneious_NUCLEOTIDE_"
,"Clustal_Alignment_PROTEIN_"
or"MUSCLE_PROTEIN_"
.- Parameters:
uniqueID
- a unique ID as described above or the unique ID returned from anyDocumentOperation.getUniqueId()
- Returns:
- the DocumentOperation or null if it's not found (for example, not currently installed).
-
getAlignmentOperation
public static DocumentOperation getAlignmentOperation(java.lang.String uniqueIdPrefix, SequenceDocument.Alphabet alphabet)
Get aDocumentOperation
representation of anAlignmentOperation
. To determine the unique IDs of AlignmentOperations, you can callDocumentOperation.getUniqueId()
and look for IDs ending with "with_sequence_type_in_name". The unique ID prefix is the section before "with_sequence_type_in_name" and the alphabet suffix (_NUCLEOTIDE_ or _PROTEIN_). Examples foruniqueIdPrefix
:- Geneious
- MUSCLE
- MAFFT (Downloadable plugin)
- Parameters:
uniqueIdPrefix
- the uniqueIdPrefix returned fromAlignmentOperation.getUniqueIdPrefix()
alphabet
- alphabet of the sequences that need to be aligned- Returns:
- a DocumentOperation representation of an AlignmentOperation for aligning the given alphabet. Null if the alignment operation isn't found or if the given alphabet is not supported.
- Since:
- API 4.14 (Geneious 5.1)
-
getSequenceAnnotationGenerator
public static SequenceAnnotationGenerator getSequenceAnnotationGenerator(java.lang.String uniqueID)
get the SequenceAnnotationGenerator with the given unique ID. To view a list of all SequenceAnnotationGenerator unique IDs, you can callSequenceAnnotationGenerator.getUniqueId()
on each of the results returned fromgetSequenceAnnotationGenerators()
- Parameters:
uniqueID
- a unique ID as described above or the unique ID returned from anySequenceAnnotationGenerator.getUniqueId()
- Returns:
- the SequenceAnnotationGenerator or null if it's not found (for example, not currently installed).
-
getDocumentFileImporter
public static DocumentFileImporter getDocumentFileImporter(java.lang.String uniqueID)
get the DocumentFileImporter with the given unique ID. To view a list of all DocumentFileImporter unique IDs, you can callDocumentFileImporter.getUniqueId()
on each of the results returned fromgetDocumentFileImporters()
- Parameters:
uniqueID
- a unique ID as described above or the unique ID returned from anyDocumentFileImporter.getUniqueId()
- Returns:
- the DocumentFileImporter or null if it's not found (for example, not currently installed).
-
getDocumentFileExporter
public static DocumentFileExporter getDocumentFileExporter(java.lang.String uniqueID)
get the DocumentFileExporter with the given unique ID. To view a list of all DocumentFileExporter unique IDs, you can callDocumentFileExporter.getUniqueId()
on each of the results returned fromgetDocumentFileExporters()
- Parameters:
uniqueID
- a unique ID as described above or the unique ID returned from anyDocumentFileExporter.getUniqueId()
- Returns:
- the DocumentFileExporter or null if it's not found (for example, not currently installed).
-
getDatabaseFolderImporter
public static DatabaseFolderImporter getDatabaseFolderImporter(java.lang.String uniqueID)
get the DatabaseFolderImporter with the given unique ID.- Parameters:
uniqueID
- a unique ID as described above or the unique ID returned from anyDatabaseFolderImporter.getUniqueId()
- Returns:
- the DatabaseFolderImporter or null if it's not found (for example, not currently installed)
- Since:
- API 4.201920 (Geneious Prime 2019.2.0)
-
getGeneiousServices
public static java.util.List<GeneiousService> getGeneiousServices()
Returns all installed GeneiousServices. This includes all parent and child services. Alternately you can find a single GeneiousService by ID usinggetGeneiousService(String)
. Note, unlikegetGeneiousService(String)
this method returns services that are currently unavailable (e.g. have not finished initializing or are restricted and there is no active license).- Returns:
- a list of all installed GeneiousServices
-
getWritableDatabaseServiceRoots
public static java.util.List<WritableDatabaseService> getWritableDatabaseServiceRoots()
Returns the root services of all installed WritableDatabaseServices. This includes the local database root folder, the search results root folder, and any shared Database root folders.- Returns:
- the root services of all installed WritableDatabaseServices. This includes the local database root folder, the search results root folder, and any shared Database root folders.
-
addWritableDatabaseServiceRootListener
public static void addWritableDatabaseServiceRootListener(PluginUtilities.WritableDatabaseServicesListener listener)
Add a listener to be notificed when root WritableDatabaseServices are added or removed. A root WritableDatabaseServices is an WritableDatabaseService that is not a child service of another WritableDatabaseService. (i.e. when the list that would be returned fromgetWritableDatabaseServiceRoots()
has changed).- Parameters:
listener
- the listener to be notified when root WritableDatabaseServices are added or removed.- See Also:
removeWritableDatabaseServiceRootListener(com.biomatters.geneious.publicapi.plugin.PluginUtilities.WritableDatabaseServicesListener)
-
removeWritableDatabaseServiceRootListener
public static void removeWritableDatabaseServiceRootListener(PluginUtilities.WritableDatabaseServicesListener listener)
Remove a listener previously added usingaddLocalDatabaseSevicesListener
- Parameters:
listener
- the listener previously provided toaddLocalDatabaseSevicesListener
- See Also:
addWritableDatabaseServiceRootListener(com.biomatters.geneious.publicapi.plugin.PluginUtilities.WritableDatabaseServicesListener)
-
doAlignment
public static SequenceAlignmentDocument doAlignment(java.util.List<SequenceDocument> sequences, jebl.util.ProgressListener progressListener) throws com.biomatters.geneious.publicapi.plugin.DocumentOperationException
Prompts the user to perform an alignment using any of the available alignment plugins. This function will return null if the user aborts, and it must not be run in the dispatch thread.- Parameters:
sequences
- the sequences to be alignedprogressListener
- Optional. If this is null, the function will create its own progress listener.- Returns:
- the new alignment.
- Throws:
com.biomatters.geneious.publicapi.plugin.DocumentOperationException
-
importDocuments
public static java.util.List<AnnotatedPluginDocument> importDocuments(java.io.File file, jebl.util.ProgressListener progress) throws java.io.IOException, DocumentImportException
Imports documents from a file into an in memory list.- Parameters:
file
- the file to import from. This can be any importable file type supported by Geneious or any installed plug-ins.progress
- ProgressListener to be notified of import progress. May be null if not interested in progress- Returns:
- a list of documents, or an empty list if the file contains no documents.
- Throws:
java.io.IOException
- when unable to read the contents of the file for any reasonDocumentImportException
- when unable to generate document(s) from contents of file.- See Also:
importDocumentsToDatabase(java.io.File, com.biomatters.geneious.publicapi.databaseservice.WritableDatabaseService, jebl.util.ProgressListener)
-
importDocuments
public static java.util.List<AnnotatedPluginDocument> importDocuments(java.io.File file, java.util.Map<java.lang.String,java.lang.String> extraOptions, jebl.util.ProgressListener progress) throws java.io.IOException, DocumentImportException
Imports documents from a file into an in memory list.- Parameters:
file
- the file to import from. This can be any importable file type supported by Geneious or any installed plug-ins.extraOptions
- The extra options which you want the importer to use. Will attempt to set each option if it's available in the importer identified for the file. Can be null.progress
- ProgressListener to be notified of import progress. May be null if not interested in progress- Returns:
- a list of documents, or an empty list if the file contains no documents.
- Throws:
java.io.IOException
- when unable to read the contents of the file for any reasonDocumentImportException
- when unable to generate document(s) from contents of file.- Since:
- API 4.202200 (Geneious 2022.0.0)
- See Also:
importDocumentsToDatabase(java.io.File, com.biomatters.geneious.publicapi.databaseservice.WritableDatabaseService, jebl.util.ProgressListener)
-
importDocumentsToDatabase
public static java.util.List<AnnotatedPluginDocument> importDocumentsToDatabase(java.io.File file, WritableDatabaseService destination, jebl.util.ProgressListener progress) throws DocumentImportException, java.io.IOException
Imports documents from a file into a database.- Parameters:
file
- the file to import from. This can be any importable file type supported by Geneious or any installed plug-ins.progress
- ProgressListener to be notified of import progress. May be null if not interested in progress- Returns:
- a list of documents imported, or an empty list if the file contains no documents.
- Throws:
java.io.IOException
- when unable to read the contents of the file for any reasonDocumentImportException
- when unable to generate document(s) from contents of file.- Since:
- API 4.14 (Geneious 5.1)
- See Also:
importDocuments(java.io.File, jebl.util.ProgressListener)
-
exportDocumentsInGeneiousFormat
public static void exportDocumentsInGeneiousFormat(java.io.File outputFile, boolean useCompression, AnnotatedPluginDocument... documents) throws java.io.IOException
Exports the given documents in Geneious format (zip compressed), to the given file. UsingexportDocuments(java.io.File, com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument...)
- Parameters:
outputFile
- the file to output to. Its extension should be ".geneious".useCompression
- compress the document in gzip format. As of Geneious 4.8 and later, where there is a single Geneious format that is always compressed, this parameter is ignored.documents
- the documents to export- Throws:
java.io.IOException
- if the documents cannot be exported.- See Also:
exportDocumentsInGeneiousFormat(java.io.File, jebl.util.ProgressListener, com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument...)
-
exportDocumentsInGeneiousFormat
public static void exportDocumentsInGeneiousFormat(java.io.File outputFile, jebl.util.ProgressListener progressListener, AnnotatedPluginDocument... documents) throws java.io.IOException
Exports the given documents in Geneious format (zip compressed), to the given file.- Parameters:
outputFile
- the file to output to. Its extension should be ".geneious".progressListener
- for reporting exporting progress and allowing the export to be cancelled.documents
- the documents to export- Throws:
java.io.IOException
- if the documents cannot be exported or if the progressListener requests the export be canceled.- Since:
- API 4.40 (Geneious 5.4.0)
-
getDocumentFileImporterForSingleFile
public static DocumentFileImporter getDocumentFileImporterForSingleFile(java.io.File file) throws DocumentImportException
This method returns the document importer that will be used for importing the single file provided. Returns null if no importer could be found. Just because an importer is returned doesn't mean that the file is compatible with geneious or even capable of being imported by the returned importer.- Parameters:
file
- the file to get the default importer for.- Returns:
- The document file importer which will be used to import this single file.
- Throws:
DocumentImportException
- if something goes wrong when looking for a compatible DocumentFileImporter- Since:
- API 4.202120 (Geneious 2021.2.0)
-
exportDocumentsInGeneiousFormat
public static void exportDocumentsInGeneiousFormat(java.io.File outputFile, jebl.util.ProgressListener progressListener, Geneious.MajorVersion minimumVersionToTryToMakeCompatibleWith, Geneious.MajorVersion minimumVersionMustBeCompatibleWith, Geneious.MajorVersion minimumVersionToNotWarnAboutDataLossWhenImporting, java.util.List<AnnotatedPluginDocument> documents) throws java.io.IOException, com.biomatters.geneious.publicapi.plugin.DocumentOperationException
Exports the given documents in Geneious format (zip compressed), to the given file.- Parameters:
outputFile
- the file to output to. Its extension should be ".geneious".progressListener
- for reporting exporting progress and allowing the export to be cancelled.minimumVersionToTryToMakeCompatibleWith
- if this is non=null, then the size of the exported file maybe be increased in order to include versions of documents in legacy formats in addition to the current format. Documents exported are not guaranteed to be compatible with this version if for example this document type was created in a more recent version of Geneious. Use minimumVersionMustBeCompatibleWith to fail if documents cannot be exported to the specified versionminimumVersionMustBeCompatibleWith
- if this is non-null, specifies the minimum version that these documents must be able to be imported in. If they can't be exported to this version, this method will throw a DocumentOperationExceptionminimumVersionToNotWarnAboutDataLossWhenImporting
- normally Geneious warns when importing a file which was exported in a future version because there may be data that is ignored by the older version. If this parameter is non-null the user won't be warned about potential data loss when importing into this version or later. If they can't be exported to this version, this method will throw a DocumentOperationExceptiondocuments
- the documents to export- Throws:
java.io.IOException
- if the documents cannot be exported or if the progressListener requests the export be canceled.com.biomatters.geneious.publicapi.plugin.DocumentOperationException
- if the documents cannot be exported in a format compatible with the requested version number- Since:
- API 4.201900 (Geneious 2019.0.0)
-
exportDocumentsInGeneiousFormat
public static void exportDocumentsInGeneiousFormat(java.io.OutputStream outputStream, jebl.util.ProgressListener progressListener, AnnotatedPluginDocument... documents) throws java.io.IOException
Exports the given documents in Geneious format (zip compressed), to the given output stream.- Parameters:
outputStream
- the stream to output to. If streaming to a file its extension should be ".geneious".progressListener
- for reporting exporting progress and allowing the export to be cancelled.documents
- the documents to export- Throws:
java.io.IOException
- if the documents cannot be exported or if the progressListener requests the export be canceled.- Since:
- API 4.44 (Geneious 5.4.4)
-
getClass
public static java.lang.Class getClass(java.lang.String className) throws java.lang.ClassNotFoundException
Find a class by name in Geneious or in any installed plugin. For certain classes where the absolute class name has changed between versions of Geneious, this method automatically re-maps old class names to new class names. This method will find classes in any installed plugin. If multiple plugins define a class with the same name it is undefined which class will be returned. Therefore plugins should always use fully qualified class names to ensure they are unique. This method is useful becauseClass.forName(String)
will not find classes from other plugins due to them being defined in a different class loader from the calling code.- Parameters:
className
- the name of the class to find.- Returns:
- a Class object
- Throws:
java.lang.ClassNotFoundException
- if the class name is not found in Geneious or in any plugin
-
getDocumentFileImporters
public static java.util.List<DocumentFileImporter> getDocumentFileImporters()
Get everyDocumentFileImporter
provided by any plugin.- Returns:
- every
DocumentFileImporter
provided by any plugin.
-
getDocumentFileExporters
public static java.util.List<DocumentFileExporter> getDocumentFileExporters()
Get everyDocumentFileExporter
provided by any plugin.- Returns:
- every
DocumentFileExporter
provided by any plugin.
-
exportDocuments
public static void exportDocuments(java.io.File file, AnnotatedPluginDocument... documentsToExport) throws java.io.IOException, java.lang.UnsupportedOperationException
Exports these documents to this file in a format suitable for the given file's extension. If multipleDocumentFileExporter
plugins support exporting these documents to a format the uses the given file extension then the first plugin found will be used. Note: If the exporter has any options (seeDocumentFileExporter.getOptions(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument[])
, this method uses the default option values. If you want to change option values, usegetDocumentFileExporters()
to get the required exporter.- Parameters:
file
- the file to export to. The file name extension of this file is used to determine the exporter to use.documentsToExport
- the documents to export.- Throws:
java.io.IOException
- if the exporter encounters problems exporting to the file.java.lang.UnsupportedOperationException
- if no plugin exists that can export these documents to a format with the given file extension.
-
getActiveGeneiousPlugins
public static java.util.List<GeneiousPlugin> getActiveGeneiousPlugins()
- Returns:
- a list of the currently enabled plugins in Geneious. Plugins that have been disabled by the user will not appear in this list even if they have been installed.
- Since:
- API 4.14 (Geneious 5.1)
-
getPluginForDocumentOperation
public static GeneiousPlugin getPluginForDocumentOperation(DocumentOperation operation)
Get theGeneiousPlugin
that provides a givenDocumentOperation
viaGeneiousPlugin.getDocumentOperations()
- Parameters:
operation
- The DocumentOperation to get the plugin for- Returns:
- The GeneiousPlugin that provides the specified DocumentOperation or null if there was no plugin found that provides the operation
- Since:
- API 4.14 (Geneious 5.1)
-
getPluginForAssembler
public static GeneiousPlugin getPluginForAssembler(Assembler assembler)
- Parameters:
assembler
- The Assembler to get the plugin for- Returns:
- The GeneiousPlugin that provides the specified Assembler or null if there was no plugin found that provides the assembler
- Since:
- API 4.14 (Geneious 5.1)
-
getPluginForSequenceAnnotationGenerator
public static GeneiousPlugin getPluginForSequenceAnnotationGenerator(SequenceAnnotationGenerator sequenceAnnotationGenerator)
Get theGeneiousPlugin
that provides a givenSequenceAnnotationGenerator
viaGeneiousPlugin.getSequenceAnnotationGenerators()
- Parameters:
sequenceAnnotationGenerator
- The SequenceAnnotationGenerator to get the plugin for- Returns:
- The GeneiousPlugin that provides the specified SequenceAnnotationGenerator or null if there was no plugin found that provides the SequenceAnnotationGenerator
- Since:
- API 4.31 (Geneious 5.3.1)
-
isRunningFromScript
public static boolean isRunningFromScript()
- Returns:
- true if the current thread is running from a script or workflow. If so, then dialogs should not be displayed. Choose a reasonable default or have it as an option. Furthermore, document operations should not modify input documents. Instead they should create copies to modify and output those.
- Since:
- API 4.700 (Geneious 7.0.0)
- See Also:
setRunningFromScript(boolean)
,isConfiguringScript()
-
setRunningFromScript
public static void setRunningFromScript(boolean runningFromScript)
Sets whether or not the current thread is running from a script. For a discussion of what this means, seeisRunningFromScript()
.
Any code that calls setRunningFromScript() with a value of true must make a matching call with a value of false. For exampletry { PluginUtilities.setRunningFromScript(true); ... } finally { PluginUtilities.setRunningFromScript(false); }
Calls to setRunningFromScript from a script may be nested.isRunningFromScript()
only returns false if there has been a matching call with "false" for each call made with "true".- Parameters:
runningFromScript
- whether or not to flag the current thread as running from a script- Since:
- API 4.1000 (Geneious 10.0.0)
- See Also:
isRunningFromScript()
-
isConfiguringScript
public static boolean isConfiguringScript()
- Returns:
- true if the current thread is configuring a script or workflow. If so, then some dialogs should not be displayed. Choose a reasonable default or have it as an option.
- Since:
- API 4.1011 (Geneious 10.1.1)
- See Also:
isRunningFromScript()
,setConfiguringScript(boolean)
-
setConfiguringScript
public static void setConfiguringScript(boolean configuringScript)
Sets whether or not the current thread is configuring a script. For a discussion of what this means, seeisConfiguringScript()
.
Any code that calls setConfiguringScript() with a value of true must make a matching call with a value of false. For exampletry { PluginUtilities.setConfiguringScript(true); ... } finally { PluginUtilities.setConfiguringScript(false); }
Calls to setConfiguringScript from a script may be nested.isConfiguringScript()
only returns false if there has been a matching call with "false" for each call made with "true".- Parameters:
configuringScript
- whether or not to flag the current thread is currently configuring a script- Since:
- API 4.1011 (Geneious 10.1.1)
- See Also:
isConfiguringScript()
-
installPluginSilently
public static void installPluginSilently(java.io.File pluginFile) throws java.io.IOException
Installs and activates a plugin without providing any feedback to the user- Parameters:
pluginFile
- the gplugin file to be installed- Throws:
java.io.IOException
- if the plugin can't be installed, or if it requires a restart to complete the installation (in which case the exception message will begin with the word restart)- Since:
- API 4.1021 (Geneious 10.2.1)
-
-