Class SequenceSelection

    • Method Detail

      • forAnnotations

        public static SequenceSelection forAnnotations​(java.util.List<SequenceSelection.SelectedAnnotation> annotations)
        Parameters:
        annotations - the annotations to be selected
        Returns:
        a new SequenceSelection for a selection of annotations. The intervals for the created selection will correspond to the annotations provided.
        Since:
        API 4.1100 (Geneious 11.0.0)
      • withoutZeroLengthIntervals

        public SequenceSelection withoutZeroLengthIntervals()
        Returns:
        an exact copy of this SequenceSelection but with any zero length SelectionIntervals removed.
        Since:
        API 4.50 (Geneious 5.5.0)
      • getAnnotationSequenceIndex

        public SequenceSelection.SequenceIndex getAnnotationSequenceIndex()
        Get the sequence index of the selected annotation if there is single selected annotation
        Returns:
        the sequence index of the selected annotation.
        Throws:
        java.lang.IllegalStateException - If this SequenceSelection was deserialized from XML Created in Geneious 5.5 or earlier and the annotation had no intervals or if there is not a single selected annotation
        Since:
        API 4.60 (Geneious 5.6.0)
        See Also:
        getAnnotation()
      • getIntervals

        public java.util.List<SequenceSelection.SelectionInterval> getIntervals​(boolean splitMultiSequenceIntervalsIntoSingleSelectionIntervals)
        Gets the intervals selected
        Parameters:
        splitMultiSequenceIntervalsIntoSingleSelectionIntervals - true to split rectangular SelectionIntervals (those that cover more than 1 sequence) into 1 SelectionInterval per sequence. When this is true , SequenceSelection.SelectionInterval.getSequenceIndex() may be called on the returned intervals.
        Returns:
        the intervals selected, possibly including rectangular selections if splitMultiSequenceIntervalsIntoSingleSelectionIntervals is false (a range of sequences and a range of residues). Note that this may return empty intervals, for example to denote a cursor position. Using getNonZeroLengthIntervals() will return a list guaranteed to correspond exactly to the nonempty selections that a user has made.
        Since:
        API 4.40 (Geneious 5.4.0)
      • getNonZeroLengthIntervals

        public java.util.List<SequenceSelection.SelectionInterval> getNonZeroLengthIntervals()
        Returns:
        the (potentially ranged) intervals in this selection. Normally this will be a single element list unless the selection is discontiguous. The List of SelectionInterval that this method returns does not include any with zero length.
        Since:
        API 4.40 (Geneious 5.4.0)
      • getSelectedSequenceCount

        public int getSelectedSequenceCount()
        Returns the number of sequences which have any residues selected (0 length selections are included). If the same sequence occurs in multiple SelectionIntervals it will be counted once.
        Returns:
        the number of sequences which have any residues selected (0 length selections are included)
      • getSelectedSequences

        @Deprecated
        public java.util.Set<SequenceDocument> getSelectedSequences()
        Returns:
        set of sequences which have any residues selected (0 length selections are included)
      • getSelectedSequenceIndices

        public java.util.Set<SequenceSelection.SequenceIndex> getSelectedSequenceIndices()
        Returns:
        set of sequence indices which have any residues selected (0 length selections are included)
        Since:
        API 4.40 (Geneious 5.4.0)
      • extractIntervals

        @Deprecated
        public java.util.List<DefaultSequenceDocument> extractIntervals()
        Deprecated.
        Extract the selected intervals as individual sequence documents. If multiple intervals are selected in a single sequence document then each of the intervals is extracted separately.
        Returns:
        the selected intervals as individual sequence documents
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

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

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

        public static SequenceSelection getTotalSelection​(java.util.List<AnnotatedPluginDocument> documents,
                                                          jebl.evolution.sequences.SequenceType type,
                                                          SequenceSelection.SequenceDocumentType sequenceDocumentType)
        For a List of AnnotatedPluginDocument, creates a selection that represents a "Select all" on each of the documents. This depends on the SequenceType and SequenceDocumentType passed in which determine whether to use the nucleotide or amino acid sequences from a List, and whether to use the stand-alone sequences or the aligned sequences from a document (which is ambiguous in the case of a CombinedAlignmentAndSequenceDocument). If SequenceSelection.SequenceDocumentType.Sequence is provided for sequenceDocumentType, then the sequences from SequenceListDocument, SequenceDocument and the stand-alone sequence from a CombinedAlignmentAndSequenceDocument will be included, or else ignored. If SequenceSelection.SequenceDocumentType.Alignment is provided, then the aligned sequences from a SequenceAlignmentDocument will be included, or else ignored.
        Parameters:
        documents - the documents to create a total selection for
        type - the type of sequences (nucleotide or amino-acid) to select in each document
        sequenceDocumentType - whether to use the stand-alone sequences or the aligned sequences in each document. If SequenceSelection.SequenceDocumentType.Sequence is provided, then the sequences from SequenceListDocument, SequenceDocument and the stand-alone sequence from a CombinedAlignmentAndSequenceDocument will be included, or else ignored. If SequenceSelection.SequenceDocumentType.Alignment is provided, then the aligned sequences from a SequenceAlignmentDocument will be included, or else ignored.
        Returns:
        the SequenceSelection representing the total selection.
        Since:
        API 4.40 (Geneious 5.4.0)
      • 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
      • toXML

        public org.jdom.Element toXML​(Geneious.MajorVersion version,
                                      jebl.util.ProgressListener progressListener)
        Description copied from interface: XMLSerializable.OldVersionCompatible
        Serializes this class to XML format, potentially to a format readable by an earlier version of Geneious. It is acceptable for the XML to include unnecessary tags that will be ignored by the earlier version. For example if the implementation has only extended the XML since the earlier version, then the XML returned may be identical to the XML returned for the current version.

        See XMLSerializable.toXML() for a more detailed description of what it means to serialize to XML.

        All classes that implement this method must also implement XMLSerializable.toXML() and should delegate back to this method using Geneious.getMajorVersion() and ProgressListener.EMPTY as parameters.

        Specified by:
        toXML in interface XMLSerializable.OldVersionCompatible
        Parameters:
        version - the major version of Geneious to serialize to XML for. For example "6.0" but not "6.0.0". This must be a version returned greater or equal to a version returned from getVersionSupport(VersionSupportType.OldestVersionSerializableTo) and must never be greater than the current version (Geneious.getMajorVersion())
        progressListener - for reporting progress and cancelling
        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