public final class SequenceSelection extends Object implements XMLSerializable, XMLSerializable.OldVersionCompatible
DocumentOperations and SequenceAnnotationGenerators to allow them to optionally make their behaviour depend on
what the user has currently selected in the sequence/alignment viewer. DocumentViewers are also informed of the current selection in other viewers via DocumentViewerMessageHandler.setSequenceSelection
Each SequenceSelection consists of one or more SelectionIntervals. A SelectionInterval
has a range of selected residues/bases (see SelectionInterval.getResidueInterval())
and an associated SequenceSelection.SequenceIndex.
The SequenceIndex indicates which sequence in the set of sequences is selected.
The index is relative to the first sequence in the first document. So for example if 2 SequenceListDocuments are
selected, and the first sequence list has 5 sequences, then a SequenceIndex of 6 corresponds to the second sequence in the second list.
SequenceIndex.getSequence automatically applies this logic.
For a slightly more complicated example, consider a set of 2 documents, the first of which is a SequenceDocument and the second is a CombinedAlignmentAndSequenceDocument.
Let [a,b] denote a SequenceIndex with SequenceSelection.SequenceIndex.getSequenceIndex()==a and SequenceSelection.SequenceIndex.getSequenceDocumentType()==b)
Then:| Modifier and Type | Class and Description |
|---|---|
static class |
SequenceSelection.SelectionInterval
A contiguous selection of residues in a sequence.
|
static class |
SequenceSelection.SequenceDocumentType
Used for identifying the type of view the selection applies for identifying which list the index applies to in a
CombinedAlignmentAndSequenceDocument |
static class |
SequenceSelection.SequenceIndex
Represents the index of the selected sequence and the type (so that we can identify which list the index applies to in
SequenceListDocuments. |
XMLSerializable.OldVersionCompatible, XMLSerializable.VersionSupportTypeROOT_ELEMENT_NAME| Constructor and Description |
|---|
SequenceSelection(org.jdom.Element element)
Construct a SequenceSelection from the results of
toXML() |
SequenceSelection(List<SequenceSelection.SelectionInterval> intervals)
Create a SequenceSelection
|
SequenceSelection(SequenceDocument sequence,
SequenceAnnotation annotation)
|
SequenceSelection(SequenceSelection.SelectionInterval... intervals)
Create a SequenceSelection
|
SequenceSelection(SequenceSelection.SequenceIndex sequenceIndex,
SequenceAnnotation annotation)
Construct for a selected SequenceAnnotation on the specified sequence.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object o) |
List<DefaultSequenceDocument> |
extractIntervals()
Deprecated.
|
void |
fromXML(org.jdom.Element element)
Restore the object from the JDOM Element returned by
XMLSerializable.toXML(). |
SequenceAnnotation |
getAnnotation()
Get the selected annotation if there is one
|
SequenceSelection.SequenceIndex |
getAnnotationSequenceIndex()
Get the sequence index of the selected annotation if there is an annotation
|
List<SequenceSelection.SelectionInterval> |
getIntervals()
Deprecated.
use
getIntervals(boolean) instead |
List<SequenceSelection.SelectionInterval> |
getIntervals(boolean splitMultiSequenceIntervalsIntoSingleSelectionIntervals)
Gets the intervals selected
|
List<SequenceSelection.SelectionInterval> |
getNonZeroLengthIntervals() |
int |
getSelectedSequenceCount()
Returns the number of sequences which have any residues selected (0 length selections are included).
|
Set<SequenceSelection.SequenceIndex> |
getSelectedSequenceIndices() |
Set<SequenceDocument> |
getSelectedSequences()
Deprecated.
|
static SequenceSelection |
getTotalSelection(List<AnnotatedPluginDocument> documents,
SequenceType type,
SequenceSelection.SequenceDocumentType sequenceDocumentType)
For a List of AnnotatedPluginDocument, creates a selection that represents a "Select all" on each of the documents.
|
Geneious.MajorVersion |
getVersionSupport(XMLSerializable.VersionSupportType versionType)
Gets either the latest version this class can serialize to via
XMLSerializable.OldVersionCompatible.toXML(com.biomatters.geneious.publicapi.plugin.Geneious.MajorVersion, jebl.util.ProgressListener)
or the most recent version in which the XML returned from XMLSerializable.OldVersionCompatible.toXML(com.biomatters.geneious.publicapi.plugin.Geneious.MajorVersion, jebl.util.ProgressListener) last changed. |
int |
hashCode() |
String |
toString() |
org.jdom.Element |
toXML()
Convert object to a JDOM element.
|
org.jdom.Element |
toXML(Geneious.MajorVersion version,
ProgressListener progressListener)
Serializes this class to XML format, potentially to a format readable by an earlier version of Geneious.
|
SequenceSelection |
withoutZeroLengthIntervals() |
public SequenceSelection(List<SequenceSelection.SelectionInterval> intervals)
intervals - the intervalspublic SequenceSelection(SequenceSelection.SelectionInterval... intervals)
intervals - the intervalspublic SequenceSelection(SequenceSelection.SequenceIndex sequenceIndex, SequenceAnnotation annotation)
getIntervals()
will correspond to the intervals of this annotation.sequenceIndex - the index of the sequenceannotation - the selected annotation, must not be null@Deprecated public SequenceSelection(SequenceDocument sequence, SequenceAnnotation annotation)
SequenceSelection(com.biomatters.geneious.publicapi.plugin.SequenceSelection.SequenceIndex, com.biomatters.geneious.publicapi.documents.sequence.SequenceAnnotation) insteadgetIntervals()
will correspond to the intervals of this annotation.sequence - the sequence in which the annotation is selected, must not be nullannotation - the selected annotation, must not be nullpublic SequenceSelection(org.jdom.Element element)
throws XMLSerializationException
toXML()element - an element returned from toXML()XMLSerializationException - if XML does not conform to our unpublished specificationpublic SequenceSelection withoutZeroLengthIntervals()
public SequenceAnnotation getAnnotation()
null if nonegetAnnotationSequenceIndex()public SequenceSelection.SequenceIndex getAnnotationSequenceIndex()
null if no annotationIllegalStateException - If this SequenceSelection was deserialized from XML Created in Geneious 5.5 or earlier and the annotation had no intervals.getAnnotation()@Deprecated public List<SequenceSelection.SelectionInterval> getIntervals()
getIntervals(boolean) insteadgetIntervals(true)public List<SequenceSelection.SelectionInterval> getIntervals(boolean splitMultiSequenceIntervalsIntoSingleSelectionIntervals)
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.getNonZeroLengthIntervals() will return a list guaranteed to correspond exactly to the nonempty selections that a user has made.public List<SequenceSelection.SelectionInterval> getNonZeroLengthIntervals()
public int getSelectedSequenceCount()
@Deprecated public Set<SequenceDocument> getSelectedSequences()
getSelectedSequenceIndices()public Set<SequenceSelection.SequenceIndex> getSelectedSequenceIndices()
@Deprecated public List<DefaultSequenceDocument> extractIntervals()
public static SequenceSelection getTotalSelection(List<AnnotatedPluginDocument> documents, SequenceType type, SequenceSelection.SequenceDocumentType sequenceDocumentType)
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.documents - the documents to create a total selection fortype - the type of sequences (nucleotide or amino-acid) to select in each documentsequenceDocumentType - 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.public org.jdom.Element toXML()
XMLSerializableXMLSerializable.fromXML(org.jdom.Element) can completely
restore the objects 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.toXML in interface XMLSerializablepublic Geneious.MajorVersion getVersionSupport(XMLSerializable.VersionSupportType versionType)
XMLSerializable.OldVersionCompatibleXMLSerializable.OldVersionCompatible.toXML(com.biomatters.geneious.publicapi.plugin.Geneious.MajorVersion, jebl.util.ProgressListener)
or the most recent version in which the XML returned from XMLSerializable.OldVersionCompatible.toXML(com.biomatters.geneious.publicapi.plugin.Geneious.MajorVersion, jebl.util.ProgressListener) last changed.getVersionSupport in interface XMLSerializable.OldVersionCompatibleversionType - specifies which version property to returnpublic org.jdom.Element toXML(Geneious.MajorVersion version, ProgressListener progressListener)
XMLSerializable.OldVersionCompatibleXMLSerializable.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.toXML in interface XMLSerializable.OldVersionCompatibleversion - 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 cancellingpublic void fromXML(org.jdom.Element element)
throws XMLSerializationException
XMLSerializableXMLSerializable.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().fromXML in interface XMLSerializableelement - representation from a previous call to XMLSerializable.toXML()XMLSerializationException - if the Element can't be converted into this type of object