Class ImportUtilities


  • public class ImportUtilities
    extends java.lang.Object
    Provides methods for importing documents into Geneious.

    Other import methods are also available in PluginUtilities such as PluginUtilities.importDocuments

    Since:
    API 4.40 (Geneious 5.4)
    • Method Detail

      • importFastaSequences

        public static java.util.List<SequenceDocument> importFastaSequences​(java.io.File fastaFile,
                                                                            SequenceDocument.Alphabet alphabet,
                                                                            jebl.util.ProgressListener progressListener)
                                                                     throws java.io.IOException,
                                                                            DocumentImportException
        Imports the given fasta file as a list of unaligned sequences.
        Parameters:
        fastaFile - the fasta file to import
        alphabet - the alphabet (either nucleotide or protein) of the file to import. May be null to automatically guess the correct type.
        progressListener - a progress listener for reporting progress and allowing the import to be cancelled.
        Returns:
        the imported sequences
        Throws:
        java.io.IOException - if there is a problem reading the file
        DocumentImportException - if there is a problem importing the alignment or if the progress listener requests the import be cancelled.
      • importFastaAlignment

        public static SequenceAlignmentDocument importFastaAlignment​(java.io.File fastaFile,
                                                                     SequenceDocument.Alphabet alphabet,
                                                                     jebl.util.ProgressListener progressListener)
                                                              throws java.io.IOException,
                                                                     DocumentImportException
        Imports the given fasta file as a list of aligned sequences, padding the sequences with trailing gaps if necessary.
        Parameters:
        fastaFile - the fasta file to import
        alphabet - the alphabet (either nucleotide or protein) of the file to import. May be null to automatically guess the correct type.
        progressListener - a progress listener for reporting progress and allowing the import to be cancelled.
        Returns:
        the imported alignment
        Throws:
        java.io.IOException - if there is a problem reading the file
        DocumentImportException - if there is a problem importing the alignment or if the progress listener requests the import be cancelled.
      • importDocuments

        public static java.util.List<AnnotatedPluginDocument> importDocuments​(java.io.File file,
                                                                              DocumentFileImporter importer,
                                                                              ImportUtilities.ActionWhenInvalid actionWhenInvalid,
                                                                              jebl.util.ProgressListener progressListener)
                                                                       throws java.io.IOException,
                                                                              DocumentImportException
        Imports the given file with a specific importer and default options. If you need to use non-default options, you will need to call the importer directly.
        Parameters:
        file - the file to import
        importer - importer to use
        actionWhenInvalid - action to take when a sequence with invalid bases/residues is encountered. Note that using ImportUtilities.ActionWhenInvalid.ImportWithInvalidBases will cause this method to throw a DocumentImportException on invalid documents
        progressListener - a progress listener for reporting progress and allowing the import to be cancelled.
        Returns:
        the imported documents
        Throws:
        java.io.IOException - if there is a problem reading the file
        DocumentImportException - if there is a problem importing the documents or if the progress listener requests the import be cancelled.
      • importDocuments

        public static void importDocuments​(java.io.File file,
                                           DocumentFileImporter.ImportCallback callback,
                                           ImportUtilities.ActionWhenInvalid actionWhenInvalid,
                                           ImportUtilities.ImportDocumentType importDocumentType,
                                           jebl.util.ProgressListener progressListener)
                                    throws java.io.IOException,
                                           DocumentImportException
        Imports the given file, using any available importer. Sequences will be grouped into a sequence list. If the importer used uses options, the default options will be used without any dialogs popping up.
        Parameters:
        file - the file to import
        callback - callback to pass imported documents back to
        actionWhenInvalid - action to take when a sequence with invalid bases/residues is encountered
        progressListener - a progress listener for reporting progress and allowing the import to be cancelled.
        importDocumentType - whether to import ambiguous files as alignments of sequence lists. For example fasta format that contains ungapped sequences all of which are the same length
        Throws:
        java.io.IOException - if there is a problem reading the file
        DocumentImportException - if there is a problem importing the documents or if the progress listener requests the import be cancelled.
        Since:
        API 4.710 (Geneious 7.1.0)
      • importDocuments

        public static void importDocuments​(java.io.File file,
                                           DocumentFileImporter.ImportCallback callback,
                                           ImportUtilities.ActionWhenInvalid actionWhenInvalid,
                                           ImportUtilities.ImportDocumentType importDocumentType,
                                           SequenceDocument.Alphabet alphabet,
                                           jebl.util.ProgressListener progressListener)
                                    throws java.io.IOException,
                                           DocumentImportException
        Imports the given file, using any available importer. Sequences will be grouped into a sequence list. If the importer used uses options, the default options will be used without any dialogs popping up.
        Parameters:
        file - the file to import
        callback - callback to pass imported documents back to
        actionWhenInvalid - action to take when a sequence with invalid bases/residues is encountered
        progressListener - a progress listener for reporting progress and allowing the import to be cancelled.
        importDocumentType - whether to import ambiguous files as alignments of sequence lists. For example fasta format that contains ungapped sequences all of which are the same length
        alphabet - the alphabet to use when the file format is ambiguous (for example fasta format). null indicates auto-detect the format (and potentially prompt the user)
        Throws:
        java.io.IOException - if there is a problem reading the file
        DocumentImportException - if there is a problem importing the documents or if the progress listener requests the import be cancelled.
        Since:
        API 4.800 (Geneious 8.0.0)
      • importDocuments

        public static void importDocuments​(java.util.List<java.io.File> files,
                                           DocumentFileImporter.ImportCallback callback,
                                           ImportUtilities.ActionWhenInvalid actionWhenInvalid,
                                           ImportUtilities.ImportDocumentType importDocumentType,
                                           SequenceDocument.Alphabet alphabet,
                                           jebl.util.ProgressListener progressListener)
                                    throws java.io.IOException,
                                           DocumentImportException
        Imports the given files, using any available importer. Sequences will be grouped into a sequence list. If the importer used uses options, the default options will be used without any dialogs popping up.
        Parameters:
        files - the files to import
        callback - callback to pass imported documents back to
        actionWhenInvalid - action to take when a sequence with invalid bases/residues is encountered
        progressListener - a progress listener for reporting progress and allowing the import to be cancelled.
        importDocumentType - whether to import ambiguous files as alignments of sequence lists. For example fasta format that contains ungapped sequences all of which are the same length
        alphabet - the alphabet to use when the file format is ambiguous (for example fasta format). null indicates auto-detect the format (and potentially prompt the user)
        Throws:
        java.io.IOException - if there is a problem reading the file
        DocumentImportException - if there is a problem importing the documents or if the progress listener requests the import be cancelled.
        Since:
        API 4.202020 (Geneious 2020.2.0)