public class SequenceSelectionWithDocuments extends Object implements XMLSerializable, XMLSerializable.OldVersionCompatible
SequenceSelection with the List of AnnotatedPluginDocument that it is
defined on.| Modifier and Type | Class and Description |
|---|---|
static class |
SequenceSelectionWithDocuments.DocumentsInvalidException
Thrown to indicate that a group of documents is not valid to have a SequenceSelectionWithDocuments upon.
|
static class |
SequenceSelectionWithDocuments.ExtractionStrategy
Instances of this allow calling code to fine tune how
getSequences() returns
SequenceDocuments from its selection and documents. |
static class |
SequenceSelectionWithDocuments.SelectedDocumentsModifiedException
Thrown when the selected documents are modified between the moment when the SequenceSelectionWithDocuments is constructed
and the documents within it are accessed.
|
XMLSerializable.OldVersionCompatible, XMLSerializable.VersionSupportType| Modifier and Type | Field and Description |
|---|---|
static SequenceSelectionWithDocuments.ExtractionStrategy |
DEFAULT_EXTRACTION_STRATEGY
The default ExtractionStrategy used to return sequences.
|
static SequenceSelectionWithDocuments.ExtractionStrategy |
TRIMMING_EXTRACTION_STRATEGY
An ExtractionStrategy that does what
DefaultExtractionStrategy does, but additionally performs trimming on the sequences, such that any leading or trailing
trim annotations are respected and these portions of the sequence are left out of the extraction. |
ROOT_ELEMENT_NAME| Constructor and Description |
|---|
SequenceSelectionWithDocuments(org.jdom.Element element)
Construct a SequenceSelectionWithDocuments from the results of
toXML() |
SequenceSelectionWithDocuments(List<AnnotatedPluginDocument> documents)
|
SequenceSelectionWithDocuments(List<AnnotatedPluginDocument> documents,
SequenceSelection selection)
|
SequenceSelectionWithDocuments(List<AnnotatedPluginDocument> documents,
SequenceSelection selection,
SequenceSelectionWithDocuments.ExtractionStrategy extractionStrategy)
Constructs an SequenceSelectionWithDocuments for the given documents and given SelectionSelection on those documents.
|
SequenceSelectionWithDocuments(List<AnnotatedPluginDocument> documents,
SequenceSelectionWithDocuments.ExtractionStrategy extractionStrategy)
Constructor which "selects all" from the given documents.
It infers the SequenceType and SequenceSelection.SequenceDocumentType
from the documents.If the documents contain a mixture of nucleotide and amino acid sequences, this will throw an DocumentsInvalidException. |
| Modifier and Type | Method and Description |
|---|---|
void |
fromXML(org.jdom.Element element)
Restore the object from the JDOM Element returned by
XMLSerializable.toXML(). |
AnnotatedPluginDocument |
getContainingDocument(int index) |
List<AnnotatedPluginDocument> |
getDocuments() |
List<SequenceAlignmentDocument.ReferencedSequence> |
getReferenceSequences()
If everything in the documents in this SequenceSelection is selected, return a list of the ReferencedSequences
representing the AnnotatedPluginDocument which each sequence in the selection appears in and its index therein.
|
List<SequenceDocument> |
getSequences()
Returns the sequences referred to by this object's SequenceSelection for its List of AnnotatedPluginDocument, as a List of SequenceDocument,
applying the given ExtractionStrategy in order to extract sequences.
|
SequenceSelection |
getSequenceSelection() |
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. |
void |
setDoRevisionNumberChecks(boolean doRevisionNumberChecks)
When
getSequences() is called, checks are made to make sure that the revision of the document hasn't changed and
will throw a SequenceSelectionWithDocuments.SelectedDocumentsModifiedException if so. |
SequenceSelectionWithDocuments |
subSelection(int... sequenceIndices)
Given a set of indices specifying some of this class's SequenceSelection's intervals, determines which AnnotatedPluginDocuments are referenced by those SelectionIntervals,
and groups them together into a List.
|
org.jdom.Element |
toXML()
Convert object to a JDOM element.
|
org.jdom.Element |
toXML(Geneious.MajorVersion majorVersion,
ProgressListener progressListener)
Serializes this class to XML format, potentially to a format readable by an earlier version of Geneious.
|
public static final SequenceSelectionWithDocuments.ExtractionStrategy DEFAULT_EXTRACTION_STRATEGY
public static final SequenceSelectionWithDocuments.ExtractionStrategy TRIMMING_EXTRACTION_STRATEGY
DefaultExtractionStrategy does, but additionally performs trimming on the sequences, such that any leading or trailing
trim annotations are respected and these portions of the sequence are left out of the extraction.public SequenceSelectionWithDocuments(List<AnnotatedPluginDocument> documents, SequenceSelection selection) throws DocumentOperationException
SequenceSelectionWithDocuments(java.util.List, SequenceSelection, com.biomatters.geneious.publicapi.plugin.SequenceSelectionWithDocuments.ExtractionStrategy) with
DEFAULT_EXTRACTION_STRATEGY.documents - the List of Documents for which this SequenceSelectionWithDocuments's SequenceSelection is defined on. Must not be null, but can be an empty list.selection - the SequenceSelection to group together with its List of Documents. Must not be null.DocumentOperationException - if there was an error loading the PluginDocument from one of documentspublic SequenceSelectionWithDocuments(List<AnnotatedPluginDocument> documents, SequenceSelection selection, SequenceSelectionWithDocuments.ExtractionStrategy extractionStrategy) throws DocumentOperationException
documents - the List of Documents for which this SequenceSelectionWithDocuments's SequenceSelection is defined on. Must not be null, but can be an empty list.selection - the SequenceSelection to group together with its List of Documents. Must not be null.extractionStrategy - the ExtractionStrategy which determines how this SequenceSelectionWithDocuments will return sequences when getSequences()
is called. At present, there are two choices: DEFAULT_EXTRACTION_STRATEGY and TRIMMING_EXTRACTION_STRATEGY.DocumentOperationException - if there was an error loading the PluginDocument from one of documentspublic SequenceSelectionWithDocuments(List<AnnotatedPluginDocument> documents) throws DocumentOperationException
SequenceSelectionWithDocuments(java.util.List, ExtractionStrategy) with DEFAULT_EXTRACTION_STRATEGY.documents - the List of Documents for which this SequenceSelectionWithDocuments's SequenceSelection is defined on. Must not be null, but can be an empty list.DocumentOperationException - if there was an error loading the PluginDocument from one of documentsIllegalArgumentException - if documents is empty, or if they're not valid to create a selection over.public SequenceSelectionWithDocuments(List<AnnotatedPluginDocument> documents, SequenceSelectionWithDocuments.ExtractionStrategy extractionStrategy) throws DocumentOperationException
SequenceType and SequenceSelection.SequenceDocumentType
from the documents.CombinedAlignmentAndSequenceDocument
this will return a selection for the sequences instead of the alignments.
If there are a mixture of documents of different types (sequence vs alignment) this will throw an IllegalArgumentException.documents - the List of Documents for which this SequenceSelectionWithDocuments's SequenceSelection is defined on. Must not be null, but can be an empty list.extractionStrategy - the ExtractionStrategy to use when getting sequences.DocumentOperationException - if there was an error loading the PluginDocument from one of documentsSequenceSelectionWithDocuments.DocumentsInvalidException - if there is a mixture of nucleotide and amino acid sequencesIllegalArgumentException - if documents is empty, or if the documents are not valid to create a selection over.public SequenceSelectionWithDocuments(org.jdom.Element element)
throws XMLSerializationException,
DocumentOperationException
toXML()element - an element returned from toXML()XMLSerializationException - if XML does not conform to our unpublished specificationDocumentOperationException - if one occurred when getting a PluginDocument from one of the AnnotatedPluginDocument taken from the
deserialized list.public void setDoRevisionNumberChecks(boolean doRevisionNumberChecks)
getSequences() is called, checks are made to make sure that the revision of the document hasn't changed and
will throw a SequenceSelectionWithDocuments.SelectedDocumentsModifiedException if so. However in some cases you may want to disable this
behaviour and manually handle the revision numbers.doRevisionNumberChecks - true to throw an exception if the revision number has changed since the SequenceSelection was created
when getSequences() or most other methods in this class are accessed, false otherwisepublic List<AnnotatedPluginDocument> getDocuments()
getSequenceSelection() is defined on.public List<SequenceAlignmentDocument.ReferencedSequence> getReferenceSequences()
public SequenceSelection getSequenceSelection()
public AnnotatedPluginDocument getContainingDocument(int index)
index - the index of the sequence in question, in the List of SelectionInterval returned by getSequenceSelection().getIntervals(true)SequenceSelection.SequenceIndex.SelectionWrongForDocumentsException - if the selection index doesn't correspond to these documents.public List<SequenceDocument> getSequences()
ExtractionStrategy passed in as an argument to this class's constructor.
SequenceSelectionWithDocuments serialized before this time will be deserialized with DefaultExtractionStrategy, and their behaviour will remain unchanged.getSequences()public SequenceSelectionWithDocuments subSelection(int... sequenceIndices)
sequenceIndices - a list of the indices of the SequenceIntervals in this object's SequenceSelection, to create a new SelectionSelection for. This must be a subset of the ones returned by
getSequenceSelection() and SequenceSelection.getIntervals()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 XMLSerializableSequenceSelectionWithDocuments(org.jdom.Element)public 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 majorVersion, 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.OldVersionCompatiblemajorVersion - 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