Interface SequenceDocument

    • Field Detail

      • GENOME_SEQUENCE_THRESHOLD

        static final int GENOME_SEQUENCE_THRESHOLD
        The sequence length threshold at which we decide a sequence is a genome. eg. sequence longer than this are serialized differently and have a different set of defaults/preferences in the sequence view.

        At API 4.50 this is 100,000.
        Since:
        API 4.50 (Geneious 5.5.0)
        See Also:
        Constant Field Values
    • Method Detail

      • getSequenceString

        java.lang.String getSequenceString()
        Get the sequence as a string. For nucleotide or amino acid sequences, each residue or ambiguity symbol is represented by one uppercase or lowercase character as per the IUPAC recommendations.

        For nucleotide sequences, any of the following are valid characters "ACGTURYMWSKBDHVN?-acgturymwskbdhvn"

        For amino acid sequences, any of the following are valid characters "ACDEFGHIKLMNPQRSTVWY*OUBJZX?-acdefghiklmnpqrstvwyoubjzx"

        Gap characters (-) are only allowed on sequences within a SequenceAlignmentDocument. Stand-alone sequences may not contain gaps.

        If getCharSequence() doesn't call this method, then one possible implementation for this method is the following:

        return getCharSequence().toString();

        WARNING: It is generally a bad idea to use this method on anything but very short sequences. On large sequences (e.g. whole chromosomes) this method may take some time and may use significant amounts of memory. e.g. A String representation of human chr1 requires 500 MB of memory. It is preferable to use getCharSequence() instead.

        Returns:
        the sequence as a string; must not return null.
        See Also:
        getCharSequence()
      • getSequenceLength

        int getSequenceLength()
        Returns the length of the sequence. This returns exactly the same as getCharSequence().length(), but may be more performant on some implementations.
        Returns:
        The length of this document's sequence. Note that if a class implements both this interface and NucleotideGraph, the return value of this method must be consistent with the contracts from both interfaces.
      • getCharSequence

        SequenceCharSequence getCharSequence()
        Get the sequence as a CharSequence. Used as an alternative to getSequenceString() in situations where a String is unnecessary and could potentially use too much memory, or where we want to efficiently calculate the terminal gap lengths. The returned CharSequence must always return consistent values from any of the CharSequence methods (e.g. CharSequence.length() and CharSequence.charAt(int). If a SequenceDocument is editable and changes are made to it, it is required that the original CharSequence obtained from getCharSequence() not change. A client of the SequenceDocument is only able to obtain the changes by making a fresh call to getCharSequence(). If getSequenceString() doesn't call this method, then it is possible to implement this method as follows:

        return SequenceCharSequence.valueOf(getSequenceString());

        However, it is recommended that a more memory efficient representation is used where possible; in that case, getSequenceString() can be implemented based on this method (see its javadoc).

        Some implementations of this method may choose to throw a RuntimeException whose cause is an XMLSerializationException if there is insufficient memory to load the sequence. In most situations (e.g. from a DocumentOperation or DocumentFileImporter) catching this exception is unnecessary as core Geneious will have either pre-loaded the sequence or will catch and unwrap this exception itself gracefully.

        Returns:
        the sequence as a SequenceCharSequence; must not return null.
        See Also:
        getSequenceString()
      • isCircular

        boolean isCircular()
        Returns true if this sequence is circular.

        A circular sequence is one where the end points touch forming one continuous sequence without ends. For information on how annotations are handled in circular sequences, see. SequenceAnnotationInterval.getFrom()

        Returns:
        true if this sequence is circular.