public final class PluginUtilities extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
PluginUtilities.WritableDatabaseServicesListener
A listener used for notifying when root WritableDatabaseServices are added or removed in Geneious.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
LOCAL_DATABASE_SERVICE_UNIQUE_ID
The unique ID of the local database root "Local" service.
|
static String |
SEARCH_RESULTS_SERVICE_UNIQUE_ID
The unique ID of the local database root "Searches" service.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
addWritableDatabaseServiceRootListener(PluginUtilities.WritableDatabaseServicesListener listener)
Add a listener to be notificed when root WritableDatabaseServices are added or removed.
|
static DocumentSelectionOption.FolderOrDocuments |
displayDocumentSearchDialog(String preferenceKey,
DocumentSearchCache searchCache,
Set<DocumentType> documentTypes,
DocumentFilter documentFilter,
String documentTypeDescription,
List<AnnotatedPluginDocument> extraDocuments,
DocumentSelectionOption.FolderOrDocuments initialSelection,
List<DocumentField> fieldsToDisplay,
boolean allowMultipleSelection,
boolean showUseAllButton,
JComponent owner)
Display a dialog allowing the user to choose document(s) from their local database (or connected shared databases).
|
static SequenceAlignmentDocument |
doAlignment(List<SequenceDocument> sequences,
ProgressListener progressListener)
Prompts the user to perform an alignment using any of the available alignment plugins.
|
static void |
exportDocuments(File file,
AnnotatedPluginDocument... documentsToExport)
Exports these documents to this file in a format suitable for the given file's extension.
|
static void |
exportDocumentsInGeneiousFormat(File outputFile,
boolean useCompression,
AnnotatedPluginDocument... documents)
Exports the given documents in Geneious format (zip compressed), to the given file.
|
static void |
exportDocumentsInGeneiousFormat(File outputFile,
ProgressListener progressListener,
AnnotatedPluginDocument... documents)
Exports the given documents in Geneious format (zip compressed), to the given file.
|
static void |
exportDocumentsInGeneiousFormat(OutputStream outputStream,
ProgressListener progressListener,
AnnotatedPluginDocument... documents)
Exports the given documents in Geneious format (zip compressed), to the given output stream.
|
static List<GeneiousPlugin> |
getActiveGeneiousPlugins() |
static DocumentOperation |
getAlignmentOperation(String uniqueIdPrefix,
SequenceDocument.Alphabet alphabet)
Get a
DocumentOperation representation of an AlignmentOperation. |
static List<Assembler> |
getAssemblers()
Get a list of all
Assemblers 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 Class |
getClass(String className)
Find a class by name in Geneious or in any installed plugin.
|
static DocumentFileExporter |
getDocumentFileExporter(String uniqueID)
get the DocumentFileExporter with the given unique ID.
|
static List<DocumentFileExporter> |
getDocumentFileExporters()
Get every
DocumentFileExporter provided by any plugin. |
static DocumentFileImporter |
getDocumentFileImporter(String uniqueID)
get the DocumentFileImporter with the given unique ID.
|
static List<DocumentFileImporter> |
getDocumentFileImporters()
Get every
DocumentFileImporter provided by any plugin. |
static DocumentOperation |
getDocumentOperation(String uniqueID)
get the DocumentOperation with the given unique ID.
|
static List<DocumentOperation> |
getDocumentOperations()
Get a list of all
DocumentOperations provided by all currently installed plugins. |
static List<DocumentViewerFactory> |
getDocumentViewerFactories(AnnotatedPluginDocument... documents)
Get a list of
DocumentViewerFactories 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(String uniqueID)
Get access to any standard GeneiousService or any 3rd party GeneiousService.
|
static List<GeneiousService> |
getGeneiousServices()
Returns all installed GeneiousServices.
|
static GeneiousPlugin |
getPluginForAssembler(Assembler assembler)
|
static GeneiousPlugin |
getPluginForDocumentOperation(DocumentOperation operation)
Get the
GeneiousPlugin that provides a given DocumentOperation via GeneiousPlugin.getDocumentOperations() |
static GeneiousPlugin |
getPluginForSequenceAnnotationGenerator(SequenceAnnotationGenerator sequenceAnnotationGenerator)
Get the
GeneiousPlugin that provides a given SequenceAnnotationGenerator via GeneiousPlugin.getSequenceAnnotationGenerators() |
static SequenceAnnotationGenerator |
getSequenceAnnotationGenerator(String uniqueID)
get the SequenceAnnotationGenerator with the given unique ID.
|
static List<SequenceAnnotationGenerator> |
getSequenceAnnotationGenerators()
Get a list of all
SequenceAnnotationGenerators provided by all currently installed plugins |
static List<SequenceGraphFactory> |
getSequenceGraphFactories()
Get a list of all
SequenceGraphFactories provided by all currently installed plugins |
static List<SequenceViewerExtension.Factory> |
getSequenceViewerExtensionFactories()
Get a list of all
SequenceViewerExtension.Factories provided by all currently installed plugins |
static List<TreeViewerExtension.Factory> |
getTreeViewerExtensionFactories()
Get a list of all
TreeViewerExtension.Factories provided by all currently installed plugins |
static List<WritableDatabaseService> |
getWritableDatabaseServiceRoots()
Returns the root services of all installed WritableDatabaseServices.
|
static List<AnnotatedPluginDocument> |
importDocuments(File file,
ProgressListener progress)
Imports documents from a file into an in memory list.
|
static List<AnnotatedPluginDocument> |
importDocumentsToDatabase(File file,
WritableDatabaseService destination,
ProgressListener progress)
Imports documents from a file into a database.
|
static boolean |
isRunningFromScript() |
static void |
removeWritableDatabaseServiceRootListener(PluginUtilities.WritableDatabaseServicesListener listener)
Remove a listener previously added using
addLocalDatabaseSevicesListener |
public static final String SEARCH_RESULTS_SERVICE_UNIQUE_ID
getGeneiousService(String) to get the
service.public static final String LOCAL_DATABASE_SERVICE_UNIQUE_ID
getGeneiousService(String) to get the
service.public static List<SequenceAnnotationGenerator> getSequenceAnnotationGenerators()
SequenceAnnotationGenerators provided by all currently installed pluginsSequenceAnnotationGenerators provided by all currently installed pluginspublic static List<DocumentOperation> getDocumentOperations()
DocumentOperations 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 has
DocumentOperation.getActionOptions().getCategory()
== Category.Alignment.DocumentOperations provided by all currently installed pluginspublic static List<Assembler> getAssemblers()
Assemblers provided by all currently installed plugins.Assemblers provided by all currently installed pluginspublic static DocumentOperation getCategoryOperation(GeneiousActionOptions.Category category)
public static List<SequenceGraphFactory> getSequenceGraphFactories()
SequenceGraphFactories provided by all currently installed pluginsSequenceGraphFactories provided by all currently installed pluginspublic static List<TreeViewerExtension.Factory> getTreeViewerExtensionFactories()
TreeViewerExtension.Factories provided by all currently installed pluginsTreeViewerExtension.Factories provided by all currently installed pluginspublic static List<SequenceViewerExtension.Factory> getSequenceViewerExtensionFactories()
SequenceViewerExtension.Factories provided by all currently installed pluginsSequenceViewerExtension.Factories provided by all currently installed pluginspublic static List<DocumentViewerFactory> getDocumentViewerFactories(AnnotatedPluginDocument... documents)
DocumentViewerFactories 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.documents - optionally restrict the list of returned factories to only those that can view these documents. Use no documents to get all viewer factories.DocumentViewerFactories provided by all currently installed pluginspublic static DocumentSelectionOption.FolderOrDocuments displayDocumentSearchDialog(String preferenceKey, DocumentSearchCache searchCache, Set<DocumentType> documentTypes, DocumentFilter documentFilter, String documentTypeDescription, List<AnnotatedPluginDocument> extraDocuments, DocumentSelectionOption.FolderOrDocuments initialSelection, List<DocumentField> fieldsToDisplay, boolean allowMultipleSelection, boolean showUseAllButton, JComponent owner)
preferenceKey - a preferences key used for storing the most recently viewed folder and expanded folders.searchCache - the DocumentSearchCache 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 of DocumentFields 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 dialogpublic static GeneiousService getGeneiousService(String uniqueID)
for (GeneiousService service : PluginUtilities.getGeneiousServices()) {
System.out.println(service.getUniqueID());
}
>
If the service with the specified unique ID is currently unavailable (e.g. it has not finished initializing, or it is restricted because there is no active license),
this method will return null.uniqueID - a unique ID as described above or the unique ID returned from any GeneiousService.getUniqueID()DatabaseServices, so you can usually cast the return type to that.public static DocumentOperation getDocumentOperation(String uniqueID)
DocumentOperation.getUniqueId()
on each of the results returned from getDocumentOperations()
e.g.
for (DocumentOperation operation : PluginUtilities.getDocumentOperations())
System.out.println("Operation: "+operation.getUniqueId());
A DocumentOperation version of an AlignmentOperation 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_".uniqueID - a unique ID as described above or the unique ID returned from any DocumentOperation.getUniqueId()public static DocumentOperation getAlignmentOperation(String uniqueIdPrefix, SequenceDocument.Alphabet alphabet)
DocumentOperation representation of an AlignmentOperation.
To determine the unique IDs of AlignmentOperations, you can call DocumentOperation.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 for uniqueIdPrefix:
uniqueIdPrefix - the uniqueIdPrefix returned from AlignmentOperation.getUniqueIdPrefix()alphabet - alphabet of the sequences that need to be alignedpublic static SequenceAnnotationGenerator getSequenceAnnotationGenerator(String uniqueID)
SequenceAnnotationGenerator.getUniqueId()
on each of the results returned from getSequenceAnnotationGenerators()uniqueID - a unique ID as described above or the unique ID returned from any SequenceAnnotationGenerator.getUniqueId()public static DocumentFileImporter getDocumentFileImporter(String uniqueID)
DocumentFileImporter.getUniqueId()
on each of the results returned from getDocumentFileImporters()uniqueID - a unique ID as described above or the unique ID returned from any DocumentFileImporter.getUniqueId()public static DocumentFileExporter getDocumentFileExporter(String uniqueID)
DocumentFileExporter.getUniqueId()
on each of the results returned from getDocumentFileExporters()uniqueID - a unique ID as described above or the unique ID returned from any DocumentFileExporter.getUniqueId()public static List<GeneiousService> getGeneiousServices()
getGeneiousService(String).
Note, unlike getGeneiousService(String) this method returns services that are currently unavailable (e.g. have not finished initializing or are restricted and there is no active license).public static List<WritableDatabaseService> getWritableDatabaseServiceRoots()
public static void addWritableDatabaseServiceRootListener(PluginUtilities.WritableDatabaseServicesListener listener)
getWritableDatabaseServiceRoots() has changed).listener - the listener to be notified when root WritableDatabaseServices are added or removed.removeWritableDatabaseServiceRootListener(com.biomatters.geneious.publicapi.plugin.PluginUtilities.WritableDatabaseServicesListener)public static void removeWritableDatabaseServiceRootListener(PluginUtilities.WritableDatabaseServicesListener listener)
addLocalDatabaseSevicesListenerlistener - the listener previously provided to addLocalDatabaseSevicesListeneraddWritableDatabaseServiceRootListener(com.biomatters.geneious.publicapi.plugin.PluginUtilities.WritableDatabaseServicesListener)public static SequenceAlignmentDocument doAlignment(List<SequenceDocument> sequences, ProgressListener progressListener) throws DocumentOperationException
sequences - the sequences to be alignedprogressListener - Optional. If this is null, the function will create its own progress listener.DocumentOperationExceptionpublic static List<AnnotatedPluginDocument> importDocuments(File file, ProgressListener progress) throws IOException, DocumentImportException
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 progressIOException - when unable to read the contents of the file for any reasonDocumentImportException - when unable to generate document(s) from contents of file.importDocumentsToDatabase(java.io.File, com.biomatters.geneious.publicapi.databaseservice.WritableDatabaseService, jebl.util.ProgressListener)public static List<AnnotatedPluginDocument> importDocumentsToDatabase(File file, WritableDatabaseService destination, ProgressListener progress) throws DocumentImportException, IOException
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 progressIOException - when unable to read the contents of the file for any reasonDocumentImportException - when unable to generate document(s) from contents of file.importDocuments(java.io.File, jebl.util.ProgressListener)public static void exportDocumentsInGeneiousFormat(File outputFile, boolean useCompression, AnnotatedPluginDocument... documents) throws IOException
exportDocuments(java.io.File, com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument...)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 exportIOException - if the documents cannot be exported.exportDocumentsInGeneiousFormat(java.io.File, jebl.util.ProgressListener, com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument...)public static void exportDocumentsInGeneiousFormat(File outputFile, ProgressListener progressListener, AnnotatedPluginDocument... documents) throws IOException
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 exportIOException - if the documents cannot be exported or if the progressListener requests the export be canceled.public static void exportDocumentsInGeneiousFormat(OutputStream outputStream, ProgressListener progressListener, AnnotatedPluginDocument... documents) throws IOException
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 exportIOException - if the documents cannot be exported or if the progressListener requests the export be canceled.public static Class getClass(String className) throws ClassNotFoundException
Class.forName(String) will not find classes from other
plugins due to them being defined in a different class loader from the calling code.className - the name of the class to find.ClassNotFoundException - if the class name is not found in Geneious or in any pluginpublic static List<DocumentFileImporter> getDocumentFileImporters()
DocumentFileImporter provided by any plugin.DocumentFileImporter provided by any plugin.public static List<DocumentFileExporter> getDocumentFileExporters()
DocumentFileExporter provided by any plugin.DocumentFileExporter provided by any plugin.public static void exportDocuments(File file, AnnotatedPluginDocument... documentsToExport) throws IOException, UnsupportedOperationException
DocumentFileExporter
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 (see DocumentFileExporter.getOptions(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument[]), this method
uses the default option values. If you want to change option values, use getDocumentFileExporters() to get the required exporter.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.IOException - if the exporter encounters problems exporting to the file.UnsupportedOperationException - if no plugin exists that can export these documents to a format with the given file extension.public static List<GeneiousPlugin> getActiveGeneiousPlugins()
public static GeneiousPlugin getPluginForDocumentOperation(DocumentOperation operation)
GeneiousPlugin that provides a given DocumentOperation via GeneiousPlugin.getDocumentOperations()operation - The DocumentOperation to get the plugin forpublic static GeneiousPlugin getPluginForAssembler(Assembler assembler)
assembler - The Assembler to get the plugin forpublic static GeneiousPlugin getPluginForSequenceAnnotationGenerator(SequenceAnnotationGenerator sequenceAnnotationGenerator)
GeneiousPlugin that provides a given SequenceAnnotationGenerator via GeneiousPlugin.getSequenceAnnotationGenerators()sequenceAnnotationGenerator - The SequenceAnnotationGenerator to get the plugin forpublic static boolean isRunningFromScript()