Class SequenceAnnotation

    • Field Detail

      • HIDDEN_TYPE_FOR_ACTIVELY_LINKED_PARENTS

        public static final java.lang.String HIDDEN_TYPE_FOR_ACTIVELY_LINKED_PARENTS
        An annotation type for annotations added to documents which are actively linked to their descendants (see OperationRecordDocument.hasAnyActiveLinks()). When a document containing an annotation of this type is regenerated because its parent has changed, then despite all other data on the document being discarded, if the region covered by this annotation can be unambiguously identified on the new version of the document, then this annotation will be copied to the new document covering that region.

        Annotations of this type will be hidden from the user interface. They are intended for programatic use only.

        Since:
        API 4.60 (Geneious 5.6.0)
        See Also:
        SequenceAnnotationQualifier.HIDDEN_QUALIFIER_FOR_ACTIVELY_LINKED_PARENTS, Constant Field Values
      • TYPE_TRANSLATED_REGION

        public static final java.lang.String TYPE_TRANSLATED_REGION
        These annotations were created on translations prior to 10.0.0 but were never used. They are similar to TYPE_EXTRACTED_REGION
        See Also:
        Constant Field Values
      • TYPE_PRIMER_BIND

        public static final java.lang.String TYPE_PRIMER_BIND
        Primer annotation type.
        Primer annotations should not be created inside tracks as most primer handling code ignores tracks.
        See Also:
        Constant Field Values
      • TYPE_MISC_FEATURE

        public static final java.lang.String TYPE_MISC_FEATURE
        See Also:
        Constant Field Values
      • TYPE_RESTRICTION_SITE

        public static final java.lang.String TYPE_RESTRICTION_SITE
        See Also:
        Constant Field Values
      • TYPE_POTENTIAL_RESTRICTION_SITE

        public static final java.lang.String TYPE_POTENTIAL_RESTRICTION_SITE
        Restriction site that can be introduced by a silent mutation
        Since:
        API 4.1100 (Geneious 11.0.0)
        See Also:
        Constant Field Values
      • TYPE_WIG

        public static final java.lang.String TYPE_WIG
        Wiggle track (WIG) annotation
        Since:
        API 4.201910 (Geneious Prime 2019.1.0)
        See Also:
        Constant Field Values
      • TYPE_REGULATORY

        public static final java.lang.String TYPE_REGULATORY
        From Genbank definition: "Any region of sequence that functions in the regulation of transcription or translation"
        Since:
        API 4.810 (Geneious 8.1.0)
        See Also:
        Constant Field Values
      • TYPE_CRISPR

        public static final java.lang.String TYPE_CRISPR
        Candidate CRISPR site
        Since:
        API 4.800 (Geneious 8.0.0)
        See Also:
        Constant Field Values
      • TYPE_SEARCH_HIT

        public static final java.lang.String TYPE_SEARCH_HIT
        The type of annotation added to a sequence search result to indicate the region that matched the query sequence
        Since:
        API 4.703 (Geneious 7.0.3)
        See Also:
        Constant Field Values
      • TYPE_VECTOR_SEGMENT_OF_SUSPECT_ORIGIN

        public static final java.lang.String TYPE_VECTOR_SEGMENT_OF_SUSPECT_ORIGIN
        See Also:
        Constant Field Values
      • TYPE_VECTOR_WEAK

        public static final java.lang.String TYPE_VECTOR_WEAK
        See Also:
        Constant Field Values
      • TYPE_VECTOR_MODERATE

        public static final java.lang.String TYPE_VECTOR_MODERATE
        See Also:
        Constant Field Values
      • TYPE_VECTOR_STRONG

        public static final java.lang.String TYPE_VECTOR_STRONG
        See Also:
        Constant Field Values
      • TYPE_DISULFIDE_BOND

        public static final java.lang.String TYPE_DISULFIDE_BOND
        See Also:
        Constant Field Values
      • TYPE_ORIGIN_OF_REPLICATION

        public static final java.lang.String TYPE_ORIGIN_OF_REPLICATION
        See Also:
        Constant Field Values
      • TYPE_SIGNAL_PEPTIDE

        public static final java.lang.String TYPE_SIGNAL_PEPTIDE
        See Also:
        Constant Field Values
      • TYPE_MATURE_PEPTIDE

        public static final java.lang.String TYPE_MATURE_PEPTIDE
        See Also:
        Constant Field Values
      • TYPE_LONG_TERMINAL_REPEAT

        public static final java.lang.String TYPE_LONG_TERMINAL_REPEAT
        See Also:
        Constant Field Values
      • TYPE_REPEAT_REGION

        public static final java.lang.String TYPE_REPEAT_REGION
        See Also:
        Constant Field Values
      • TYPE_REPEAT_UNIT

        public static final java.lang.String TYPE_REPEAT_UNIT
        See Also:
        Constant Field Values
      • TYPE_MISC_DIFFERENCE

        public static final java.lang.String TYPE_MISC_DIFFERENCE
        See Also:
        Constant Field Values
      • TYPE_POLYA_SIGNAL

        public static final java.lang.String TYPE_POLYA_SIGNAL
        See Also:
        Constant Field Values
      • TYPE_PROTEIN_BIND

        public static final java.lang.String TYPE_PROTEIN_BIND
        See Also:
        Constant Field Values
      • TYPE_TRANSMEMBRANE

        public static final java.lang.String TYPE_TRANSMEMBRANE
        See Also:
        Constant Field Values
      • TYPE_COILED_COIL

        public static final java.lang.String TYPE_COILED_COIL
        See Also:
        Constant Field Values
      • TYPE_PRECURSOR_RNA

        public static final java.lang.String TYPE_PRECURSOR_RNA
        See Also:
        Constant Field Values
      • TYPE_CONCATENATED_SEQUENCE

        @Deprecated
        public static final java.lang.String TYPE_CONCATENATED_SEQUENCE
        Deprecated.
        As of Geneious 2025.0, these types of annotations are no longer created by cloning operations. Instead TYPE_CLONING_FRAGMENT are created.
        See Also:
        Constant Field Values
      • TYPE_CLONING_FRAGMENT

        public static final java.lang.String TYPE_CLONING_FRAGMENT
        The type of annotation adding to the results of a cloning operation to indicate which source sequence that fragment of the result was produced from
        Since:
        API 4.202500 (Geneious 2025.0.0)
        See Also:
        Constant Field Values
      • TYPE_INSERTED_SEQUENCE

        public static final java.lang.String TYPE_INSERTED_SEQUENCE
        See Also:
        Constant Field Values
      • TYPE_EXCLUDED_REGION

        public static final java.lang.String TYPE_EXCLUDED_REGION
        Annotations of this type are length 0 annotations between 2 sites, and represent a region of the sequence that has been excluded for some reason, usually for example when viewing a query centric alignment with gaps hidden in the reference sequence.
        See Also:
        Constant Field Values
      • TYPE_OVERHANG

        public static final java.lang.String TYPE_OVERHANG
        A terminal region of a sequence annotated with an annotation of this type is an overhang on one of the strands. If the annotation is directed from left to right (SequenceAnnotationInterval.Direction.leftToRight), the overhang is on the forward strand. If the annotation is directed right to left (SequenceAnnotationInterval.Direction.rightToLeft), it is an overhang on the reverse strand.
        Overhang annotations should not be created inside tracks as most overhang handling code ignores tracks.
        See Also:
        Constant Field Values
      • TYPE_EDITING_HISTORY_INSERTION

        public static final java.lang.String TYPE_EDITING_HISTORY_INSERTION
        A directionless annotation type to record deletions, insertions and replacements of bases in a sequence compared to the original imported sequence. The bases that the annotation covers will always be bases the user has inserted into the sequence. And the qualifier SequenceAnnotationQualifier.EDITING_HISTORY_ORIGINAL_BASES within the annotation records the bases that originally existed there. For example:
          1   2   3   4   5   6   7   8   9
          G   A   T   T   A   C   A   G   G
                 [ ]       [C]       [  T  ]
         
        Here we have 3 annotations. The first covers only the 3rd base and therefore represents and insertion of T at that point. The second annotation represents a deletion of a C between the 5th and 6th bases. The final annotation represents a replacement of a T with GG at the end of the sequence. This works well for the implementation but isn't that nice to look at so the text displayed to the user might be something like: "Inserted T", for the first annotaion, "Deleted C" for the second, and "Replaced T with GG" for the third.
        See Also:
        TYPE_EDITING_HISTORY_REPLACEMENT, TYPE_EDITING_HISTORY_DELETION, Constant Field Values
      • TYPE_GIBSON_PRIMER_EXTENSION

        public static final java.lang.String TYPE_GIBSON_PRIMER_EXTENSION
        A type to mark bases that have to be added as a primer extension (instead of primer binding site) during the newgibson assembly operation.
        Since:
        API 4.810 (Geneious 8.1.0)
        See Also:
        Constant Field Values
      • TYPE_STATISTICS

        public static final java.lang.String TYPE_STATISTICS
        A type used to represent statistical data
        Since:
        API 4.60 (Geneious 5.6.0)
        See Also:
        Constant Field Values
      • TYPE_EXPRESSION_LEVEL

        public static final java.lang.String TYPE_EXPRESSION_LEVEL
        A type used to represent expression levels (for example when dealing with RNA sequencing data)
        Since:
        API 4.60 (Geneious 5.6.0)
        See Also:
        Constant Field Values
      • TYPE_EXPRESSION_DIFFERENCE

        public static final java.lang.String TYPE_EXPRESSION_DIFFERENCE
        A type used to represent differential expression levels (for example when dealing with RNA sequencing data)
        Since:
        API 4.801 (Geneious 8.0.1)
        See Also:
        Constant Field Values
      • TYPE_OPTIMIZED_CODON

        public static final java.lang.String TYPE_OPTIMIZED_CODON
        A type used to represent a codon that has been replaced wih an optimized equivalent
        Since:
        API 4.700 (Geneious 7.0.0)
        See Also:
        Constant Field Values
      • KEY_CREATED_BY

        public static final java.lang.String KEY_CREATED_BY
        A special key used to identify the origin of this annotation. eg. "ORF finder" if this annotation was generated by the ORF finder plugin the user's name if this annotation was created by the user Annotations from databases such as NCBI should not be given a created tag.

        To add a created by tag it should be added to the qualifiers of the annotation with this as the name

        See Also:
        Constant Field Values
      • KEY_MODIFIED_BY

        public static final java.lang.String KEY_MODIFIED_BY
        A special key to identify the last modifier of this annotation. eg. the user's name if this annotation was modifed by the user. Annotations this tag if they have been modified after creation (do not give modified by tag to a new annotation).

        To add a modified by tag it should be added to the qualifiers of the annotation with this as the name

        See Also:
        Constant Field Values
      • KEY_ANNOTATION_GROUP

        public static final java.lang.String KEY_ANNOTATION_GROUP
        Name of a qualifier whose value identifies a group that this annotation belongs to on a single sequence. In the sequence viewer, if the user puts the mouse over one of these annotations then all others of the same group will be highlighted. (eg) Primer pairs are associated in this way. This value should be unique on a per sequence basis and groups cannot span several sequences.

        For example two corresponding TYPE_PRIMER_BIND annotations may have KEY_ANNOTATION_GROUP qualifier with a value "group_1", with opposite direction, to work as a pair.

        Note: KEY_ANNOTATION_GROUP is different from SequenceAnnotationGroup which is used for grouping entire sets of types together.

        See Also:
        Constant Field Values
      • TYPE_LOW_COVERAGE

        public static final java.lang.String TYPE_LOW_COVERAGE
        Annotation types created by High/Low coverage finder when it finds low coverage regions Note that prior to Geneious 2022.2, the coverage finder would only use this field (value "Coverage - Low") under some situations and would use a value of "Low" in other situations.
        Since:
        API 4.902 (Geneious 9.0.2)
        See Also:
        TYPE_HIGH_COVERAGE, Constant Field Values
      • TYPE_HIGH_COVERAGE

        public static final java.lang.String TYPE_HIGH_COVERAGE
        Annotation types created by High/Low coverage finder when it finds high coverage regions. Note that prior to Geneious 2022.2, the coverage finder would only use this field (value "Coverage - High") under some situations and would use a value of "High" in other situations.
        Since:
        API 4.902 (Geneious 9.0.2)
        See Also:
        TYPE_LOW_COVERAGE, Constant Field Values
      • TYPE_MASKED

        public static final java.lang.String TYPE_MASKED
        The annotation type used to mask alignment regions for the purpose of inferring phylogeny. During tree building, masked columns can be optionally removed.
        Since:
        API 4.1000 (Geneious 10.0.0)
        See Also:
        Constant Field Values
    • Constructor Detail

      • SequenceAnnotation

        public SequenceAnnotation​(java.lang.String name,
                                  java.lang.String type)
        Constructs a new SequenceAnnotation with the specified name and type. The type can be e.g. one of the TYPE_* constants in this class, but may be any arbitrary non-null value.
        Parameters:
        name - Human readable name for the annotation; must not be null. See getName().
        type - Identifier for the type of the annotation, e.g. TYPE_CDS, TYPE_ORF. May be any arbitrary String, but must not be null. See getType().
        Throws:
        java.lang.NullPointerException - if name or type is null
      • SequenceAnnotation

        public SequenceAnnotation​(java.lang.String name,
                                  java.lang.String type,
                                  SequenceAnnotationInterval... intervals)
        Constructs a new SequenceAnnotation with the specified name and type. The type can be e.g. one of the TYPE_* constants in this class, but may be any arbitrary non-null value.
        Parameters:
        name - Human readable name for the annotation; must not be null. See getName().
        type - Identifier for the type of the annotation, e.g. TYPE_CDS, TYPE_ORF. May be any arbitrary String, but must not be null. See getType().
        intervals - 0 or more intervals to add to this annotation.
        Throws:
        java.lang.NullPointerException - if name or type is null
      • SequenceAnnotation

        public SequenceAnnotation​(org.jdom.Element element)
                           throws XMLSerializationException
        XML deserialization constructor.
        Parameters:
        element - an element returned from a previous call to toXML()
        Throws:
        XMLSerializationException - if unable to deserialize the annotation
      • SequenceAnnotation

        public SequenceAnnotation​(SequenceAnnotation annotation)
        creates a copy of the given annotation
        Parameters:
        annotation - SequenceAnnotation of which to create a copy
        Throws:
        java.lang.NullPointerException - if annotation is null
      • SequenceAnnotation

        public SequenceAnnotation​(SequenceAnnotation annotation,
                                  int offset)
        creates a copy of the given annotation offset by a certain amount
        Parameters:
        annotation - SequenceAnnotation of which to create a copy
        offset - amount to offset by
        Throws:
        java.lang.NullPointerException - if annotation is null
    • Method Detail

      • getIntervals

        public java.util.List<SequenceAnnotationInterval> getIntervals()
        Gets all the intervals this annotation contains.

        If the annotation is for the entire sequence, this method must return an interval specifying the entire sequence range.

        For a CDS annotation the order of the intervals indicates the order in which the translation proceeds.

        Returns:
        all annotation intervals
        See Also:
        getNumberOfIntervals(), getInterval(int)
      • getNumberOfIntervals

        public int getNumberOfIntervals()
        Returns the number of intervals this annotation has
        Returns:
        the number of intervals this annotation has
        Since:
        API 4.810 (Geneious 8.1.0)
        See Also:
        getInterval(int), getIntervals()
      • getInterval

        public SequenceAnnotationInterval getInterval()
        If this annotation has exactly 1 interval gets that interval or throws an IllegalStateException if it doesn't have exactly 1 interval.

        Annotations are generally made of several intervals. However, certain types of annotations (such as TYPE_PRIMER_BIND) never have more than one interval, and in such cases this method can be called to avoid needing to call .getIntervals().get(0).

        Returns:
        the sole interval of this annotation
        Throws:
        java.lang.IllegalStateException - if this annotation does not have exactly 1 interval
        Since:
        API 4.600 (Geneious 6.0.0)
        See Also:
        getIntervals()
      • getQualifiers

        public java.util.List<SequenceAnnotationQualifier> getQualifiers()
        A list of qualifiers for the sequence. If there are no qualifiers, this method must return an empty list (e.g. Collections.emptyList()).
        Returns:
        the qualifiers
      • getName

        public java.lang.String getName()
        The name of the annotation which should be a short human readable text description.
        Returns:
        name of the annotation
      • getType

        public java.lang.String getType()
        Type of the annotation. types are non structured - for example "CDS" or "gene". These can be any of the strings defined at SequenceAnnotation.TYPE_* or any custom string.
        Returns:
        the type
        See Also:
        setType(String)
      • setType

        public void setType​(java.lang.String type)
        Set the type of this annotation. Types are non structured - for example "CDS" or "gene". These can be any of the strings defined at SequenceAnnotation.TYPE_* or any custom string.
        Parameters:
        type - the new type of this annotation
        See Also:
        getType()
      • equals

        public final boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • createTrimAnnotation

        public static SequenceAnnotation createTrimAnnotation​(int minimumIndexInclusive,
                                                              int maximumIndexInclusive)
        Creates a new TYPE_TRIMMED annotation
        Parameters:
        minimumIndexInclusive - the minimum 1-based index
        maximumIndexInclusive - the maximum 1-based index
        Returns:
        a new trim annotation
        Since:
        API 4.40 (Geneious 5.4.0)
      • createMaskedAnnotation

        public static SequenceAnnotation createMaskedAnnotation​(int minimumIndexInclusive,
                                                                int maximumIndexInclusive)
        Creates a new TYPE_MASKED annotation
        Parameters:
        minimumIndexInclusive - the minimum 1-based index
        maximumIndexInclusive - the maximum 1-based index
        Returns:
        a new masked annotation
        Since:
        API 4.1000 (Geneious 10.0.0)
      • copyOf

        public static java.util.List<SequenceAnnotation> copyOf​(java.util.List<SequenceAnnotation> sequenceAnnotationsToCopy)
        Creates a deep copy of a list of SequenceAnnotations. This is useful in cases where you obtain a list of annotations from another class and need to ensure the other class doesn't modify the list or any of the contained annotations after providing it to you.
        Parameters:
        sequenceAnnotationsToCopy - the annotations to copy.
        Returns:
        a deep copy of sequenceAnnotationsToCopy
      • addInterval

        public void addInterval​(int from,
                                int to)
        Add one left to right interval to this annotation.
        Parameters:
        from - lower limit (inclusive), in range 1 to sequence length.
        to - upper limit (inclusive), in range 1 to sequence length.
      • addInterval

        public void addInterval​(int minIndex,
                                int maxIndex,
                                SequenceAnnotationInterval.Direction direction)
        Add one interval to this annotation.
        Parameters:
        minIndex - The minimum index (inclusive) spanned by this interval, in range 1 to sequence length.
        maxIndex - The maximum index (inclusive) spanned by this interval, in range 1 to sequence length.
        direction - The direction of this annotation.
        See Also:
        SequenceAnnotationInterval.Direction
      • setIntervals

        public void setIntervals​(java.util.List<SequenceAnnotationInterval> intervals)
        set the intervals on this annotation
        Parameters:
        intervals - the intervals to set on the annotation
        Since:
        API 4.60 (Geneious 5.6.0)
        See Also:
        SequenceAnnotationInterval
      • addInterval

        public void addInterval​(SequenceAnnotationInterval interval)
        add a new interval to this annotation. In Geneious 5.0 and later. annotations are not required to have any intervals. If they don't have intervals they will not be displayed in the sequence viewer, but will be visible in the annotations viewer.
        Parameters:
        interval - an interval to copy the newly added interval from
        See Also:
        SequenceAnnotationInterval
      • removeInterval

        public void removeInterval​(SequenceAnnotationInterval interval)
        Removes the given interval from this annotation. Does nothing if the interval is not already present.
        Parameters:
        interval - the interval to remove
      • copyWithoutIntervals

        public SequenceAnnotation copyWithoutIntervals()
        Creates a copy of this annotation, without any intervals. i.e. the returned annotation will have no intervals. The name, type and all qualifiers on this annotation will be the same on the returned annotation.
        Returns:
        a copy of this annotation, without any intervals. i.e. the returned annotation will have no intervals.
      • addQualifier

        public void addQualifier​(java.lang.String name,
                                 java.lang.String value)
        Add a qualifier with the specified name-value mapping.
        Parameters:
        name - name of the new SequenceAnnotationQualifier to add
        value - value of the new SequenceAnnotationQualifier to add
        Throws:
        java.lang.NullPointerException - if name or value is null
      • setQualifier

        public void setQualifier​(java.lang.String name,
                                 java.lang.String value)
        Deletes all existing qualifiers with the given name, and adds a new qualifier with the given value.
        Parameters:
        name - Name of the existing qualifier whose value to replace; must not be null
        value - Value to set on the qualifier; must not be null
        Throws:
        java.lang.NullPointerException - if name or value is null
      • removeQualifier

        public void removeQualifier​(java.lang.String name)
        Deletes all existing qualifiers with the given name
        Parameters:
        name - Name of the qualifier whose values to delete; must not be null
        Throws:
        java.lang.NullPointerException - if name is null
        Since:
        API 4.700 (Geneious 7.0.0)
      • getQualifierValue

        public java.lang.String getQualifierValue​(java.lang.String name)
        Get the value of the first qualifier in the list of the given name or "" if one is not found.
        Parameters:
        name - the name of the qualifier to get the value for; must not be nll
        Returns:
        the value of the qualifier with the specified name, or "" if no such qualifier was found
        Throws:
        java.lang.NullPointerException - if name is null
      • addQualifier

        public void addQualifier​(SequenceAnnotationQualifier qualifier)
        add a new qualifier.
        Parameters:
        qualifier - a qualifier to copy the newly added qualifier from
      • addQualifiers

        public void addQualifiers​(java.util.Collection<SequenceAnnotationQualifier> qualifiersToAdd)
        Adds all the given qualifiers to this annotation
        Parameters:
        qualifiersToAdd - the qualifiers to add to this annotation.
      • removeQualifier

        public void removeQualifier​(SequenceAnnotationQualifier qualifierToRemove)
        Removes the given qualifier from this annotation. Does nothing if the qualifier is not already present.
        Parameters:
        qualifierToRemove - the qualifier to remove.
      • toXML

        public org.jdom.Element toXML()
        Description copied from interface: XMLSerializable
        Convert object to a JDOM element. The representation should be complete so that XMLSerializable.fromXML(org.jdom.Element) can completely restore the object's representation.

        It is recommended that the returned element use XMLSerializable.ROOT_ELEMENT_NAME as its name, in which case it must not define an attribute called "type". In this case, fromXML, will be called with an element whose name may differ from the element return from this function. This recommendation allows a more compact representation of the XML can be stored.

        This method generally should not be called directly. Instead, you should usually call XMLSerializer.classToXML(String, XMLSerializable) which calls this method internally.

        PluginDocument implementations of this method may choose to throw an XMLSerializationException, enclosed in a RuntimeException.

        Specified by:
        toXML in interface XMLSerializable
        Returns:
        object encoded as a JDOM element
      • fromXML

        public void fromXML​(org.jdom.Element element)
                     throws XMLSerializationException
        Description copied from interface: XMLSerializable
        Restore the object from the JDOM Element returned by XMLSerializable.toXML().

        This method generally should not be called directly. Instead, you should usually call XMLSerializer.classFromXML(org.jdom.Element) or XMLSerializer.classFromXML(org.jdom.Element, Class) which calls this method internally.

        It is optional to implement this method. Instead of implementing an empty constructor and implementing this method properly, the implementation may instead throw an UnsupportedOperationException and implement a constructor that takes a single Element as a parameter. This allows for cleaner code such as support for final fields in the XMLSerializable class.

        The element parameter should not be modified since it may be reused. If you need a modified version of it, take a copy with Element.clone().

        Specified by:
        fromXML in interface XMLSerializable
        Parameters:
        element - representation from a previous call to XMLSerializable.toXML()
        Throws:
        XMLSerializationException - if the Element can't be converted into this type of object
      • setName

        public void setName​(java.lang.String name)
        Parameters:
        name - The new name to set for this SequenceAnnotation; must not be null
        Throws:
        java.lang.NullPointerException - if name is null
        See Also:
        getName()
      • toString

        public java.lang.String toString()
        Returns a human readable string with information about this annotation; the exact format of the string is not guaranteed and should not be relied on, because it may change at any time.
        Overrides:
        toString in class java.lang.Object
        Returns:
        A human readable string with information about this annotation.
      • writeObject

        public void writeObject​(GeneiousObjectOutputStream out)
                         throws java.io.IOException
        Writes this annotation to an output stream as defined by Serializable.
        Parameters:
        out - the stream to write to.
        Throws:
        java.io.IOException - if we are unable to write to the stream
        See Also:
        readObject(GeneiousObjectInputStream)
      • writeObject

        public void writeObject​(java.io.DataOutput out)
                         throws java.io.IOException
        Writes this annotation to a DataOutput
        Parameters:
        out - the DataOutput to write to.
        Throws:
        java.io.IOException - if we are unable to write to the DataOutput
        Since:
        API 4.30 (Geneious 5.3.0)
        See Also:
        readObject(GeneiousObjectInputStream)
      • writeObject

        public void writeObject​(Geneious.MajorVersion version,
                                java.io.DataOutput out)
                         throws java.io.IOException
        Writes this annotation to a DataOutput in a form that can potentially be read by old versions of Geneious
        Parameters:
        version - the version number of Geneious that must be able to deserialize this.
        out - the DataOutput to write to.
        Throws:
        java.io.IOException - if we are unable to write to the DataOutput
        Since:
        API 4.600 (Geneious 6.0.0)
        See Also:
        readObject(GeneiousObjectInputStream)
      • readObject

        public static SequenceAnnotation readObject​(java.io.DataInput in)
                                             throws java.io.IOException
        Reads data previously created using writeObject(java.io.DataOutput)
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized annotation
        Throws:
        java.io.IOException - if we are unable to read from the DataInput
        Since:
        API 4.30 (Geneious 5.3.0)
      • reverse

        public SequenceAnnotation reverse​(int sequenceLength,
                                          SequenceDocument.Alphabet alphabet)
        Creates a new annotation that is either the reverse or the reverse complements this annotation.
        Parameters:
        sequenceLength - the length of the sequence in which the annotation is being reversed.
        alphabet - the alphabet of the sequence the annotation is from. This is used to determine whether or not to complement the bases in any editing annotation qualifiers (see SequenceAnnotationQualifier.EDITING_HISTORY_ORIGINAL_BASES)
        Returns:
        this annotation in the reverse direction.
      • getCodonStart

        public int getCodonStart()
        The value of the NCBI_CODON_START qualifier indicates the offset at which the first complete codon of a coding feature can be found, relative to the first base of that feature. Valid values are 1, 2 or 3.

        If this annotation has an NCBI_CODON_START qualifier, and the value of it is between 1 and 3, return that value. Otherwise, return -1

        Returns:
        the codon start of this annotation, or -1 if there is no NCBI_CODON_START qualifier or its value is not between 1 and 3
        Since:
        API 4.600 (Geneious 6.0.0)
        See Also:
        SequenceAnnotationQualifier.NCBI_CODON_START
      • removeAnnotationWhenEdited

        public boolean removeAnnotationWhenEdited()
      • isReadOnlyAnnotationType

        public static boolean isReadOnlyAnnotationType​(java.lang.String type)
        Parameters:
        type - a type of annotation returned from getType()
        Returns:
        true if this annotation type is read only (i.e. the user shouldn't be allowed to edit it)
        Since:
        API 4.700 (Geneious 7.0.0)
      • getAnnotationAdjustedForInsertion

        public SequenceAnnotation getAnnotationAdjustedForInsertion​(int indexToInsertAt,
                                                                    int lengthOfInsertion,
                                                                    boolean isInsertionAllGaps,
                                                                    int newSequenceLengthIfCircular)
        Handles an insertion into the sequence which this annotation is for, by either returning a new annotation adjusted to take the insertion into account, or this annotation if it doesn't change, or null if the annotation should be deleted (for example the user inserts nucleotides into a primer annotation)
        Parameters:
        indexToInsertAt - the 1-based index to insert. On a circular sequence, this must still be in the range 1 to the sequence length.
        lengthOfInsertion - the number of characters in the insertion
        isInsertionAllGaps - true if the insertion consists entirely of gaps (which means for example we don't delete primer annotations)
        newSequenceLengthIfCircular - if the sequence this annotation corresponds to is circular, then this should be >0 to indicate the length of a circular sequence (after the insertion)
        Returns:
        either a new annotation (if the insertion was within or prior to this annotation), or this annotation (if it is unaffected by the insertion), or null (if this annotation should be deleted)
        Since:
        API 4.700 (Geneious 7.0.0)
      • getAnnotationAdjustedForReplacement

        public SequenceAnnotation getAnnotationAdjustedForReplacement​(int replacementPosition,
                                                                      int replacementLength,
                                                                      int sequenceLengthIfCircular)
        Handles a non-gap replacement in the sequence which this annotation is for, by either returning this annotation if it doesn't change, or null if the annotation should be deleted (for example the user replaces nucleotides in a primer annotation)
        Parameters:
        replacementPosition - the 1-based index of the first character being replaced
        replacementLength - the length of the region being replaced
        sequenceLengthIfCircular - if the sequence this annotation corresponds to is circular, then this should be >0 to indicate the length of a circular sequence
        Returns:
        either this annotation (if it is unaffected by the replacement), or null (if this annotation should be deleted)
        Since:
        API 4.700 (Geneious 7.0.0)
      • containsOnPotentiallyCircularSequence

        public boolean containsOnPotentiallyCircularSequence​(int startPosition,
                                                             int length,
                                                             int sequenceLengthIfCircular)
        Checks whether any of this annotation's intervals include a residues between startPosition and startPosition+length on a potentially circular sequence.
        Parameters:
        startPosition - An index in a sequence (In range 1 to sequence length.)
        length - The number of indexes to check after the startPosition
        sequenceLengthIfCircular - if the sequence this annotation corresponds to is circular, then this should be >0 to indicate the length of a circular sequence
        Returns:
        true if this annotation contains any residue index between startPosition (inclusive) and startPosition+length (exclusive).
        Since:
        API 4.202120 (Geneious 2021.2.0)
      • getAnnotationAdjustedForDeletion

        @Deprecated
        public SequenceAnnotation getAnnotationAdjustedForDeletion​(int deletionStart,
                                                                   int deletionLength,
                                                                   boolean isDeletionAllGaps,
                                                                   int newSequenceLengthIfCircular)
        Handles a deletion from the sequence which this annotation is for, by either returning a new annotation adjusted to take the deletion into account, or this annotation if it doesn't change, or null if the annotation should be deleted (for example the user deletes nucleotides from a primer annotation)
        Parameters:
        deletionStart - the 1-based index the deletion begins at. On a circular sequence, this must still be in the range 1 to the sequence length.
        deletionLength - the number of characters deleted.
        isDeletionAllGaps - true if all the removed characters are gaps
        newSequenceLengthIfCircular - if the sequence this annotation corresponds to is circular, then this should be >0 to indicate the length of a circular sequence (after the deletion)
        Returns:
        either a new annotation (if the deletion was within this annotation), or this annotation (if it is unaffected by the insertion), or null (if this annotation should be deleted)
        Since:
        API 4.700 (Geneious 7.0.0)
      • getAnnotationAdjustedForDeletion

        public SequenceAnnotation getAnnotationAdjustedForDeletion​(int deletionStart,
                                                                   java.lang.CharSequence deletedSequence,
                                                                   int newSequenceLengthIfCircular)
        Handles a deletion from the sequence which this annotation is for, by either returning a new annotation adjusted to take the deletion into account, or this annotation if it doesn't change, or null if the annotation should be deleted (for example the user deletes nucleotides from a primer annotation).

        For TYPE_CDS and TYPE_ORF annotations, if the start of the first interval is deleted, SequenceAnnotationQualifier.NCBI_CODON_START is adjusted to keep the translation in frame.

        Parameters:
        deletionStart - the 1-based index the deletion begins at. On a circular sequence, this must still be in the range 1 to the sequence length.
        deletedSequence - the deleted sequence characters, including gaps
        newSequenceLengthIfCircular - if the sequence this annotation corresponds to is circular, then this should be >0 to indicate the length of a circular sequence (after the deletion)
        Returns:
        either a new annotation (if the deletion was within this annotation), or this annotation (if it is unaffected by the insertion), or null (if this annotation should be deleted)
        Since:
        API 4.1021 (Geneious 10.2.1)
      • getTranslation

        public static java.lang.String getTranslation​(AnnotatedPluginDocument document,
                                                      SequenceDocument sequence,
                                                      SequenceAnnotation annotation)
        Returns the translation (if applicable) for the given annotation. Usually this should only be called on CDS annotations. The genetic code defined by the annotations' trans_table qualifier is used if present. If that is not specified, the genetic code specified by the document is used. If that is not specified, the genetic code of the sequence is used. If that is not specified, the default genetic code (as specified from the cog section of the sequence viewer preferences) is used.
        Parameters:
        document - the document the sequence came from. Used to obtain the genetic code. May be null.
        sequence - the sequence the annotation to applies to
        annotation - the annotation to translate
        Returns:
        the translation for the given annotation or null if it cannot be translated
        Since:
        API 4.800 (Geneious 8.0.0)
      • getAlignmentHiddenQualifierName

        public static java.lang.String getAlignmentHiddenQualifierName​(SequenceDocument.Alphabet alphabet,
                                                                       boolean firstSequenceIsReferenceSequence,
                                                                       java.lang.String alignmentName,
                                                                       java.lang.String sequenceName)
        Returns the name of an hidden (SequenceAnnotationQualifier.HIDDEN_PREFIX) annotation qualifier that can be used for storing a single sequence that will appear in the alignments returned from getAlignmentsFromHiddenQualifiers(). The Sequence Viewer will display the alignment(s) in its annotation tooltip. Alignments must contain a minimum of two sequences, so will only appear if two qualifiers with the same alignmentName but different sequenceNames are present.
        Parameters:
        alphabet - whether this is a nucleotide or protein alignment
        firstSequenceIsReferenceSequence - if the first sequence in the alignment should be a reference sequence (i.e. SequenceAlignmentDocument.getContigReferenceSequenceIndex() so it will be highlighted where other sequences differ from the reference)
        alignmentName - the name of the alignment
        sequenceName - the name of the sequence within the alignment
        Returns:
        the name of the qualifier to store the sequence characters under
        Since:
        API 4.201900 (Geneious 2019.0.0)
        See Also:
        getAlignmentsFromHiddenQualifiers()
      • setIsAddedToActivelyLinkedChild

        public void setIsAddedToActivelyLinkedChild​(URN urnOfDocument)
        Flags this annotations as being added to a sequence which is actively linked to its parent document. This means that when the operation which produced this document is rerun, this annotation will be automatically transferred to the newly produced result. If residues are different on the new document, the location of the annotation will be automatically moved to the correct new location if it can be determined with reasonable confidence (i.e. the residue changes are not significant). If the new location cannot be reliable determined, the annotation will not be transferred to the new document.
        Parameters:
        urnOfDocument - the AnnotatedPluginDocument.getURN() of the document this annotation is added to. This is required so that if this annotation is ever transfered to a document derived from this sequence, the annotation will not received special handling on that child sequence.
        Since:
        API 4.202020 (Geneious 2020.2.0)
        See Also:
        isAddedToActivelyLinkedChild(URN)
      • createHiddenAnnotationForDeletingThisFromActivelyLinkedChild

        public SequenceAnnotation createHiddenAnnotationForDeletingThisFromActivelyLinkedChild​(URN urnOfDocument)
        Creates an invisible annotation which can be added to an actively linked child document to indicate that this child document should delete the matching annotation when it is recreated after a parent document is edited.
        Parameters:
        urnOfDocument - the URN of the child document which this annotation should be deleted from.
        Returns:
        an invisible annotation for deleting this annotation
        Since:
        API 4.202020 (Geneious 2020.2.0)
        See Also:
        applyHiddenAnnotationsForDeletingFromActivelyLinkedChild(URN, List, List)