public class DefaultAlignmentDocument extends SequenceAlignmentDocument implements PluginDocument, XMLSerializableWithProgress, SequenceListSummary.Provider, PluginDocument.SizeRequiredToLoadIntoMemoryProvider, SequenceTrack.Manager.Provider, XMLSerializable.OldVersionCompatible, Renamable
SequenceAlignmentDocument.
The constructors provided for this class allow for the quick creation of SequenceAlignmentDocuments that fit entirely into memory. For constructing larger
SequenceAlignmentDocuments, see SequenceListOnDisk.BuilderSequenceAlignmentDocument.ReferencedSequencePluginDocument.ReferencedDocumentsAlwaysLoaded, PluginDocument.ReferencedDocumentsNotLoaded, PluginDocument.SizeRequiredToLoadIntoMemoryProviderXMLSerializable.OldVersionCompatible, XMLSerializable.VersionSupportType| Modifier and Type | Field and Description |
|---|---|
static String |
KEY_ALIGNMENT_OPTIONS |
static String |
KEY_ALIGNMENT_SCORE |
static String |
KEY_MATCH_REGIONS |
FILE_DATA_ATTRIBUTE_NAME, MAXIMUM_HTML_LENGTH, MODIFIED_DATE_FIELDROOT_ELEMENT_NAME| Constructor and Description |
|---|
DefaultAlignmentDocument()
Constructs a new empty alignment.
|
DefaultAlignmentDocument(AnnotatedPluginDocument[] referencedDocuments,
CharSequence[] alignedSequenceCharacters,
String alignmentOptions,
Double alignmentScore)
Constructs an alignment with references to original sequence documents.
|
DefaultAlignmentDocument(SequenceAlignmentDocument alignment)
Construct a default alignment as a deep copy of another alignment.
|
DefaultAlignmentDocument(SequenceDocument[] unalignedSequences,
AnnotatedPluginDocument[] referencedDocuments,
CharSequence[] alignedSequenceCharacters,
String alignmentOptions,
Double alignmentScore,
String proposedName)
This is the constructor that should be used in most situations.
|
DefaultAlignmentDocument(SequenceDocument[] unalignedSequences,
CharSequence[] alignedSequenceCharacters,
String alignmentOptions,
Double alignmentScore,
String proposedName,
ProgressListener progressListener)
Constructs an alignment without any references back to the original sequences.
|
DefaultAlignmentDocument(SequenceDocument[] unalignedSequences,
List<SequenceAlignmentDocument.ReferencedSequence> referencedSequences,
CharSequence[] alignedSequenceCharacters,
String alignmentOptions,
Double alignmentScore,
String proposedName,
ProgressListener progressListener)
This is the constructor that should be used in most situations.
|
DefaultAlignmentDocument(SequenceDocument[] alignedSequences,
String alignmentOptions,
Double alignmentScore,
String name)
|
DefaultAlignmentDocument(String name,
SequenceDocument... alignedSequences)
Constructs alignment document with no references to original sequence documents.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addContigReferenceSequence(SequenceDocument referenceSequence)
Adds a sequence as the contig reference sequence {see @link #getContigReferenceSequenceIndex()}.
|
void |
addSequence(SequenceDocument sequence)
Add a sequence to the end of the alignment.
|
static double |
calculateScore(Scores scores,
CharSequence[] alignment,
double gapOpen,
double gapExtend,
boolean freeEndGaps,
boolean applyGapExtendCostToFirstGapResidue)
Calculates the score for a given pairwise alignment.
|
boolean |
canAddAndRemoveSequences()
Check if this alignment supports adding and removing sequences.
|
boolean |
canSetAnnotations()
Returns true if this alignment can have its annotations on sequences (including the consensus sequence) edited alone via
SequenceAlignmentDocument.setAnnotations(int, java.util.List, boolean)
and SequenceAlignmentDocument.setAnnotationsOnConsensus(java.util.List)
Note that some alignment implementations may return true from SequenceAlignmentDocument.isEditable() and allow updating their annotations via
SequenceAlignmentDocument.updateSequence(int, CharSequence, java.util.List, NucleotideGraph, boolean) even if they return false from this method. |
boolean |
canSetAnnotationsOnConsensus() |
boolean |
canSetFieldValue(int sequenceIndex,
DocumentField field)
Returns true if this alignment supports updating field values using
SequenceAlignmentDocument.setFieldValue(int, com.biomatters.geneious.publicapi.documents.DocumentField, Object, boolean) |
boolean |
canSetSequenceNames()
Specifies whether this alignment supports changing the sequence names.
|
static DefaultAlignmentDocument |
fromJeblAlignment(Alignment alignment)
Converts the given JEBL alignment into a DefaultAlignmentDocument.
|
void |
fromXML(org.jdom.Element e)
Restore the object from the JDOM Element returned by
XMLSerializable.toXML(). |
SequenceListOnDisk.AlignmentData |
getAlignmentDataForSequencesNotInMemory()
If this document has its non-reference sequences stored as a
SequenceListOnDisk, then this returns them along with data associated with them, or null if not. |
List<SequenceAnnotation> |
getAnnotationsOnConsensus()
Gets annotations that are associated with the consensus sequence.
|
int |
getCircularLength()
If this alignment is circular, returns the gapped length at which it wraps back to the start or 0 if this alignment is not circular.
|
int |
getContigReferenceSequenceIndex()
Get the index (if any) of the reference sequence in a contig.
|
Date |
getCreationDate()
Get the date this document was created.
|
String |
getDescription()
A human readable single line of text describing this document,
to appear in the description field in the document table.
|
String |
getDescription(boolean includeDate)
Short text description of alignment.
|
List<DocumentField> |
getDisplayableFields()
A list of columns for display in the main document panel.
|
Object |
getFieldValue(String fieldCodeName)
Get the value of a particular field.
|
PairedReadManager |
getImmutablePairedReadManager()
An immutable view of the paired reads managed by this list or alignment.
|
int |
getMateExpectedDistance(int sequenceIndex)
Gets the expected mate distance (also known as predicted median insert size) of this nucleotide sequence from its mate.
|
int |
getMateIndex(int sequenceIndex)
Gets the index of the mate (if any) of the nucleotide sequence at this index.
|
String |
getName()
A short name (preferably one or two words) for the document.
|
int |
getNumberOfSequences()
Number of sequences in this alignment
|
AnnotatedPluginDocument |
getReferencedDocument(int sequenceIndexInAlignment)
Get an original sequence document that this alignment was made from.
|
SequenceAlignmentDocument.ReferencedSequence |
getReferencedSequence(int sequenceIndexInAlignment)
Get an original sequence document that this alignment was made from.
|
Double |
getScore() |
SequenceDocument |
getSequence(int index)
Gets one row from the alignment as a
SequenceDocument. |
List<SequenceDocument> |
getSequences()
Get the alignment as a list of sequences (Convenience function).
|
List<SequenceDocument> |
getSequencesInImmutableList()
Gets an immutable list (whose elements will not change after returning from this method).
|
SequenceType |
getSequenceType()
Returns the sequence type of the first sequence in this alignment (which should be the same as all other sequences in the alignment)
|
long |
getSizeRequiredToLoadIntoMemory()
Return an estimate of the number of bytes required to load this document into memory.
|
SequenceListSummary |
getSummary()
Gets a summary of the properties of the sequences.
|
SequenceTrack.Manager |
getTrackManager(boolean mayReturnNullIfNoTracks)
Gets a
SequenceTrack.Manager associated with this sequence for providing sequence tracks. |
URN |
getURN()
A Universal Resource Name.
|
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. |
boolean |
isContig()
Returns false by default.
|
boolean |
isEditable()
true if this alignment is editable.
|
boolean |
isFreeEndGapAlignment()
True if this alignment was built using free end gaps.
|
boolean |
isQueryCentricAlignment()
Returns true if this alignment is a query centric alignment.
|
boolean |
isReferencedDocumentReversed(int index)
Sequence direction.
|
void |
removeSequence(int index)
Removes the specified sequence from the alignment.
|
void |
reorderSequences(int[] ordering)
Adjusts the ordering of sequences in the alignment according to the ordering array.
|
void |
setAlignmentDataForSequencesNotInMemory(SequenceListOnDisk.AlignmentData alignmentData)
Replaces or sets all sequences (and associated data) in this alignment that are not the reference sequence (if any - see
getContigReferenceSequenceIndex(). |
void |
setAlignmentOptions(String alignmentOptions) |
void |
setAnnotations(int index,
List<SequenceAnnotation> annotations,
boolean allowModifyingReferencedDocuments)
Updates just the annotations on a sequence.
|
void |
setAnnotationsOnConsensus(List<SequenceAnnotation> annotations)
Sets the annotations on the consensus sequence that will be returned from a later call to
SequenceAlignmentDocument.getAnnotationsOnConsensus(). |
void |
setCircularLength(int circularLength)
Sets the circular length of this alignment.
|
void |
setContig(boolean isContig)
Set if this is a contig.
|
void |
setContigReferenceSequenceIndex(int referenceSequenceIndex)
Set the index (if any) of the reference sequence in a contig.
|
void |
setCreationDate(Date creationDate) |
void |
setFieldValue(int sequenceIndex,
DocumentField field,
Object fieldValue,
boolean allowModifyingOriginals)
Sets the value of a displayable field on one of the sequences in the alignment.
|
void |
setFreeEndGapAlignment(boolean freeEndGapAlignment)
Set whether or not this alignment is considered to have free end gaps.
|
void |
setMatchRegions(String matchRegions)
Sets information about the matching regions of a local alignment.
|
void |
setMates(int sequenceIndex,
int sequenceIndexOfMate,
int expectedMateDistance)
Records the 2nd sequence as being paired with the first sequence with the given distance.
|
void |
setName(String name)
Sets the name of this object
|
void |
setQueryCentricAlignment(boolean isQueryCentricAlignment)
Sets whether or not this alignment is a query centric alignment.
|
boolean |
setReferencedDocument(int index,
AnnotatedPluginDocument document)
Sets the sequence at the given sequenceIndexInAlignment in this alignment to refer to the given document as if it is the original source.
|
boolean |
setReferencedSequence(int sequenceIndexInAlignment,
SequenceAlignmentDocument.ReferencedSequence referencedSequence,
int referencedDocumentRevisionNumberSequenceWasCopiedFrom)
Sets the sequence at the given index in this alignment to refer to the given document as if it is the original source.
|
boolean |
setReferencedSequenceListDocument(int sequenceIndexInAlignment,
AnnotatedPluginDocument sequenceListDocument,
int sequenceIndexInSequenceListDocument) |
void |
setScore(Double score)
set the score of this alignment, or null if no score was calculated.
|
void |
setSequenceName(int index,
String newName,
boolean allowModifyingOriginals)
change the name of a sequence within the alignment.
|
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.
|
org.jdom.Element |
toXML(ProgressListener progressListener)
Convert object to a JDOM element.
|
void |
updateSequence(int index,
CharSequence sequence,
List<SequenceAnnotation> annotations,
NucleotideGraph graph,
boolean allowModifyingOriginals)
Set new residues and related data for one sequence.
|
asJeblAlignment, asJeblAlignmentIfMemoryAllows, getRealignedName, getReferencedDocuments, getReferencedSequences, getRefinedName, getSequenceAsJeblSequence, setReferencedSequence, toHTMLclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waittoHTMLpublic static final String KEY_ALIGNMENT_OPTIONS
public static final String KEY_ALIGNMENT_SCORE
public static final String KEY_MATCH_REGIONS
public DefaultAlignmentDocument()
addSequence(com.biomatters.geneious.publicapi.documents.sequence.SequenceDocument)
For constructing DefaultAlignmentDocuments that are too large to fit in memory, see SequenceListOnDisk.Builderpublic DefaultAlignmentDocument(String name, SequenceDocument... alignedSequences)
name - alignment document name or null to have one generatedalignedSequences - the aligned sequences, including gap residues@Deprecated public DefaultAlignmentDocument(SequenceDocument[] alignedSequences, String alignmentOptions, Double alignmentScore, String name)
DefaultAlignmentDocument(String, com.biomatters.geneious.publicapi.documents.sequence.SequenceDocument...) instead.alignedSequences - the aligned sequences, including gap residuesalignmentOptions - text description of options used to create the alignment. Should be null because it has been replaced by document historyalignmentScore - some sort of score for this alignment. May be nullname - alignment document name or null to have one generatedpublic DefaultAlignmentDocument(SequenceDocument[] unalignedSequences, AnnotatedPluginDocument[] referencedDocuments, CharSequence[] alignedSequenceCharacters, String alignmentOptions, Double alignmentScore, String proposedName)
unalignedSequencesand referencedDocuments are optional, but at least
one must be supplied. If both are supplied, they
must be the same length and for each index one of the arrays must contain a non-null value.
If both arrays have a value at the same index, the referencedDocuments is used and the unalignedSequences entry is ignored.
For constructing DefaultAlignmentDocuments that are too large to fit in memory, see SequenceListOnDisk.BuilderunalignedSequences - the original unaligned sequences. The residues must match (or be the reverse complement of) the ungapped corresponding sequence in alignedSequenceStringsreferencedDocuments - used for storing references back to the original documents so that annotations
or other information about the aligned sequences is available to the alignment. The residues must match (or be the reverse complement of) the ungapped corresponding sequence in alignedSequenceStringsalignedSequenceCharacters - the aligned sequence characters, with gap characters inserted. The length of the individual CharSequences and the characters retured from the CharSequences must not change after calling this method.alignmentOptions - a text description of options used to create the alignment. Should be null because it has been replaced by document historyalignmentScore - some sort of score for this alignment. May be nullproposedName - name for the resulting alignment document, or null to generate a default namepublic DefaultAlignmentDocument(SequenceDocument[] unalignedSequences, CharSequence[] alignedSequenceCharacters, String alignmentOptions, Double alignmentScore, String proposedName, ProgressListener progressListener)
SequenceListOnDisk.BuilderunalignedSequences - the original unaligned sequences. The residues must match (or be the reverse complement of) the ungapped corresponding sequence in alignedSequenceStringsalignedSequenceCharacters - the aligned sequence characters, with gap characters inserted. The length of the individual CharSequences and the characters retured from the CharSequences must not change after calling this method.alignmentOptions - a text description of options used to create the alignment. Should be null because it has been replaced by document historyalignmentScore - some sort of score for this alignment. May be nullproposedName - name for the resulting alignment document, or null to generate a default nameprogressListener - since creating huge alignments (100,000 or more sequences) can take a while, progress will be reported to this and it can be used for canceling the creation of this alignment document, in which case the returned document will be invalid.public DefaultAlignmentDocument(SequenceDocument[] unalignedSequences, List<SequenceAlignmentDocument.ReferencedSequence> referencedSequences, CharSequence[] alignedSequenceCharacters, String alignmentOptions, Double alignmentScore, String proposedName, ProgressListener progressListener)
unalignedSequencesand referencedDocuments are optional, but at least
one must be supplied. If both are supplied, they
must be the same length and for each index one of the arrays must contain a non-null value.
If both arrays have a value at the same index, the referencedDocuments is used and the unalignedSequences entry is ignored.
For constructing DefaultAlignmentDocuments that are too large to fit in memory, see SequenceListOnDisk.BuilderunalignedSequences - the original unaligned sequences. The residues must match (or be the reverse complement of) the ungapped corresponding sequence in alignedSequenceStringsreferencedSequences - used for storing references back to the original documents so that annotations
or other information about the aligned sequences is available to the alignment. The residues must match (or be the reverse complement of) the ungapped corresponding sequence in alignedSequenceStrings. This may be null for no referenced sequences.alignedSequenceCharacters - the aligned sequence characters, with gap characters inserted. The length of the individual CharSequences and the characters retured from the CharSequences must not change after calling this method.alignmentOptions - a text description of options used to create the alignment. Should be null because it has been replaced by document historyalignmentScore - some sort of score for this alignment. May be nullproposedName - name for the resulting alignment document, or null to generate a default nameprogressListener - since creating huge alignments (100,000 or more sequences) can take a while, progress will be reported to this and it can be used for canceling the creation of this alignment document, in which case the returned document will be invalid.public DefaultAlignmentDocument(AnnotatedPluginDocument[] referencedDocuments, CharSequence[] alignedSequenceCharacters, String alignmentOptions, Double alignmentScore)
SequenceListOnDisk.BuilderreferencedDocuments - used for storing references back to the original documents so that annotations
or other information about the aligned sequences is available to the alignment. Indices
match those in alignedSequenceStringsalignedSequenceCharacters - the aligned sequence characters, with gap characters inserted. The length of the individual CharSequences and the characters retured from the CharSequences must not change after calling this method.alignmentOptions - a text description of options used to create the alignment. Should be null because it has been replaced by document historyalignmentScore - some sort of score for this alignment. May be nullpublic DefaultAlignmentDocument(SequenceAlignmentDocument alignment)
alignment - to copypublic boolean isReferencedDocumentReversed(int index)
SequenceAlignmentDocumentisReferencedDocumentReversed in class SequenceAlignmentDocumentindex - between 0 and SequenceAlignmentDocument.getNumberOfSequences()-1 inclusive.SequenceAlignmentDocument.getReferencedDocument(int) is not null and it is in the reverse direction of its sequence string in the alignment.public static DefaultAlignmentDocument fromJeblAlignment(Alignment alignment)
alignment - the alignment to convertpublic 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 org.jdom.Element toXML(ProgressListener progressListener)
XMLSerializableWithProgressXMLSerializable.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 XMLSerializableWithProgressprogressListener - for reporting progress of the serialization. The implementation may return null if the progress listener requests that it cancel.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 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 e)
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 XMLSerializablee - representation from a previous call to XMLSerializable.toXML()XMLSerializationException - if the Element can't be converted into this type of objectpublic List<DocumentField> getDisplayableFields()
PluginDocumentPluginDocument.getFieldValue(String).
Each column is specified by a Field. The fields should be obtained from a call to the appropriate
Field.createXXXXField, where XXXX is the appropriate type.
While it is not required, it is recommended that a PluginDocument
handle returning a complete list of its displayable fields before
the document has been properly constructed via a call to XMLSerializable.fromXML(org.jdom.Element)
The returned list need not and should not be modifiable.getDisplayableFields in interface PluginDocumentpublic Double getScore()
public void setScore(Double score)
score - the new scoreIllegalStateException - if this alignment has been manually modifiedpublic Object getFieldValue(String fieldCodeName)
PluginDocumentgetFieldValue in interface PluginDocumentfieldCodeName - field code. This should be the
code of one of the fields
returned from PluginDocument.getDisplayableFields().DocumentField.getValueType() (or a subclass) of the corresponding DocumentField returned from PluginDocument.getDisplayableFields().public String getName()
PluginDocumentAnnotatedPluginDocument then this method
will be overridden and delegate back to AnnotatedPluginDocument.getName(). One way to look at it is
that when you call PluginDocument.getName() you will get the current name of the document. If you are implementing PluginDocument.getName() then you are
returning the default name for the document.getName in interface PluginDocumentpublic URN getURN()
PluginDocumentgetURN in interface PluginDocumentpublic Date getCreationDate()
PluginDocumentAnnotatedPluginDocument.getCreationDate()
instead as that will return either the date returned from
PluginDocument.getCreationDate() or if that returned null,
AnnotatedPluginDocument.getCreationDate() will return the date the
document was first instantiated.getCreationDate in interface PluginDocumentPluginDocument.MODIFIED_DATE_FIELDpublic String getDescription(boolean includeDate)
includeDate - when true, include generation time informationpublic String getDescription()
PluginDocumentgetDescription in interface PluginDocumentpublic SequenceDocument getSequence(int index)
SequenceAlignmentDocumentSequenceDocument. As this sequence
is an alignment row, it will normally contain gaps.
If implementation stores the URN of the original sequence document, see
the note in SequenceAlignmentDocument.getReferencedDocument(int).getSequence in class SequenceAlignmentDocumentindex - between 0 and SequenceAlignmentDocument.getNumberOfSequences()-1 inclusive.public int getNumberOfSequences()
SequenceAlignmentDocumentgetNumberOfSequences in class SequenceAlignmentDocumentpublic boolean canSetFieldValue(int sequenceIndex,
DocumentField field)
SequenceAlignmentDocumentSequenceAlignmentDocument.setFieldValue(int, com.biomatters.geneious.publicapi.documents.DocumentField, Object, boolean)canSetFieldValue in class SequenceAlignmentDocumentsequenceIndex - the index of a sequence in the alignmentfield - the field to updateSequenceAlignmentDocument.setFieldValue(int, com.biomatters.geneious.publicapi.documents.DocumentField, Object, boolean)SequenceAlignmentDocument.setFieldValue(int, com.biomatters.geneious.publicapi.documents.DocumentField, Object, boolean)public void setFieldValue(int sequenceIndex,
DocumentField field,
Object fieldValue,
boolean allowModifyingOriginals)
SequenceAlignmentDocumentSequenceAlignmentDocument.canSetFieldValue(int, com.biomatters.geneious.publicapi.documents.DocumentField) returns true.setFieldValue in class SequenceAlignmentDocumentsequenceIndex - the index of a sequence in the alignment to update the field value onfield - the field to updatefieldValue - the new value for the field.allowModifyingOriginals - true if this field change may be propagated to a referenced sequence (if any). If this is false the sequence will be disconnected from its referenced document.SequenceAlignmentDocument.canSetFieldValue(int, com.biomatters.geneious.publicapi.documents.DocumentField)public void updateSequence(int index,
CharSequence sequence,
List<SequenceAnnotation> annotations,
NucleotideGraph graph,
boolean allowModifyingOriginals)
SequenceAlignmentDocumentSequenceAlignmentDocument.isEditable()
(otherwise, the method should throw UnsupportedOperationException).updateSequence in class SequenceAlignmentDocumentindex - the index of the sequence to be updated. between 0 and SequenceAlignmentDocument.getNumberOfSequences() - 1sequence - the new residuesannotations - a list of the annotationsgraph - Must be null if the original sequence at the specified index is not a NucleotideGraphSequenceDocument.
Otherwise (i.e. if the sequence was a NucleotideGraphSequenceDocument), specifies the new
graph to use for that sequence.allowModifyingOriginals - if the change being made to the sequence would affect the unaligned version of it
(for example, the sequence residues are changing rather than just the gaps)
and the alignment stores a reference an editable original SequenceDocument
(which can be determined by using SequenceAlignmentDocument.getReferencedDocument(int)) then if this parameter is true
the original referenced sequence document will be modified.
If this parameter is not true and the change would have otherwise modified the original SequenceDocument,
then any reference to the original document will be discarded
and a copy of the original sequence stored internally within the alignment instead.public void setMatchRegions(String matchRegions)
matchRegions - a matching region within the alignmentpublic static double calculateScore(Scores scores, CharSequence[] alignment, double gapOpen, double gapExtend, boolean freeEndGaps, boolean applyGapExtendCostToFirstGapResidue)
scores - alignment - must consist of two CharSequences of equal length which represent aligned sequence characters, with gap characters inserted. The length of the individual CharSequences and the characters retured from the CharSequences must not change after calling this method.gapOpen - gapExtend - freeEndGaps - applyGapExtendCostToFirstGapResidue - Generally there is an ambiguity in bioinformatics whether "gap opening" already includes the first gap character - in other words, whether a gap of length N has
(a) a cost of gapOpen + N * gapExtend
or
(b) gapOpen + (N-1) * gapExtend.
.
applyGapExtendCostToFirstGapResidue should be true if using interpretation (a).public boolean isEditable()
SequenceAlignmentDocumentSequenceAlignmentDocument.reorderSequences(int[]), SequenceAlignmentDocument.removeSequence(int) , SequenceAlignmentDocument.updateSequence(int, CharSequence, java.util.List, NucleotideGraph, boolean), SequenceAlignmentDocument.setReferencedDocument(int, com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument) SequenceAlignmentDocument.canSetAnnotations() to allow updating just the annotations via SequenceAlignmentDocument.setAnnotations(int, java.util.List, boolean)isEditable in class SequenceAlignmentDocumentpublic AnnotatedPluginDocument getReferencedDocument(int sequenceIndexInAlignment)
SequenceAlignmentDocumentgetReferencedDocument in class SequenceAlignmentDocumentsequenceIndexInAlignment - the index of the sequence in the alignment to get the original document for. between 0 and SequenceAlignmentDocument.getNumberOfSequences()-1 inclusive.SequenceAlignmentDocument.getReferencedSequence(int)public SequenceAlignmentDocument.ReferencedSequence getReferencedSequence(int sequenceIndexInAlignment)
SequenceAlignmentDocumentgetReferencedSequence in class SequenceAlignmentDocumentsequenceIndexInAlignment - the index of the sequence in the alignment to get the original document for. between 0 and SequenceAlignmentDocument.getNumberOfSequences()-1 inclusive.SequenceAlignmentDocument.getReferencedDocument(int).SequenceAlignmentDocument.getReferencedDocument(int)public void reorderSequences(int[] ordering)
SequenceAlignmentDocumentSequenceAlignmentDocument.isEditable()reorderSequences in class SequenceAlignmentDocumentordering - Each integer between 0 and ordering.length - 1 inclusive should occur exactly once in this array.public void removeSequence(int index)
SequenceAlignmentDocumentSequenceAlignmentDocument.isEditable()removeSequence in class SequenceAlignmentDocumentindex - the index of the sequence to be removed. between 0 and SequenceAlignmentDocument.getNumberOfSequences() - 1public boolean canAddAndRemoveSequences()
SequenceAlignmentDocumentcanAddAndRemoveSequences in class SequenceAlignmentDocumentSequenceAlignmentDocument.addSequence(SequenceDocument),
SequenceAlignmentDocument.removeSequence(int)public void addSequence(SequenceDocument sequence)
SequenceAlignmentDocumentsequence should be the
gapped (aligned) sequence.addSequence in class SequenceAlignmentDocumentsequence - sequence to addSequenceAlignmentDocument.reorderSequences(int[]),
SequenceAlignmentDocument.setReferencedDocument(int, com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument)public boolean setReferencedDocument(int index,
AnnotatedPluginDocument document)
SequenceAlignmentDocument sequenceIndexInAlignment ,
with gap residues removed.
This method may be used when the user chooses to extract a sequence from an alignment, so the alignment
should now be updated to reference the extracted sequence.
Any alignment implementations may choose to not implement this method, in which case of the default implementation is used which always returns false.setReferencedDocument in class SequenceAlignmentDocumentindex - the sequenceIndexInAlignment of the sequence referred to. between 0 and SequenceAlignmentDocument.getNumberOfSequences() - 1document - the document to referenceSequenceAlignmentDocument.getReferencedDocument(int) to check if it really worked.public boolean setReferencedSequence(int sequenceIndexInAlignment,
SequenceAlignmentDocument.ReferencedSequence referencedSequence,
int referencedDocumentRevisionNumberSequenceWasCopiedFrom)
SequenceAlignmentDocument sequenceIndexInAlignment ,
with gap residues removed.
This method may be used when the user chooses to extract a sequence from an alignment, so the alignment
should now be updated to reference the extracted sequence.
Any alignment implementations may choose to not implement this method, in which case of the default implementation is used which always returns false.setReferencedSequence in class SequenceAlignmentDocumentsequenceIndexInAlignment - the sequenceIndexInAlignment of the sequence referred to. between 0 and SequenceAlignmentDocument.getNumberOfSequences() - 1referencedSequence - the document to referencereferencedDocumentRevisionNumberSequenceWasCopiedFrom - normally an alignment document stores the most recent revision number it updated its local cache of the sequence from. In order to improve performance, if it is known what revision number (see AnnotatedPluginDocument.getRevisionNumber() the current alignment sequence was created from then it can be supplied here. Use -1 if unsure.public boolean setReferencedSequenceListDocument(int sequenceIndexInAlignment,
AnnotatedPluginDocument sequenceListDocument,
int sequenceIndexInSequenceListDocument)
public void setContig(boolean isContig)
isContig - public boolean isContig()
SequenceAlignmentDocumentDefaultAlignmentDocument
then the document will not be given the contig icon (to set non default icons for
a document see DocumentType.OVERRIDE_DOCUMENT_TYPE_KEY.
Use setContig(boolean)
to create a contig.isContig in class SequenceAlignmentDocumentsetContig(boolean)public boolean isFreeEndGapAlignment()
SequenceAlignmentDocumentisFreeEndGapAlignment in class SequenceAlignmentDocumentpublic void setFreeEndGapAlignment(boolean freeEndGapAlignment)
freeEndGapAlignment - true if thisisFreeEndGapAlignment()public void setSequenceName(int index,
String newName,
boolean allowModifyingOriginals)
SequenceAlignmentDocumentSequenceAlignmentDocument.canSetSequenceNames() returns true.setSequenceName in class SequenceAlignmentDocumentindex - index of the sequence name to changenewName - the new name for the sequence.allowModifyingOriginals - if the alignment stores a reference to an editable original SequenceDocument
(which can be determined by using SequenceAlignmentDocument.getReferencedDocument(int)) then if this parameter is true
the original referenced sequence document will be renamed too.
Otherwise, any existing reference to the original SequenceDocument will be discarded
and a copy of the original sequence stored internally within the alignment instead.public boolean canSetSequenceNames()
SequenceAlignmentDocumentSequenceAlignmentDocument.setSequenceName(int, String, boolean)canSetSequenceNames in class SequenceAlignmentDocumentpublic void setName(String name)
Renamablepublic void setCreationDate(Date creationDate)
public void setAlignmentOptions(String alignmentOptions)
public void setContigReferenceSequenceIndex(int referenceSequenceIndex)
referenceSequenceIndex - the index (in the range [0,getNumberOfSequences()-1]) or -1 to set no reference sequencegetContigReferenceSequenceIndex()public int getContigReferenceSequenceIndex()
SequenceAlignmentDocumentgetContigReferenceSequenceIndex in class SequenceAlignmentDocumentSequenceAlignmentDocument.getNumberOfSequences()-1]) or -1 to if this contig has no reference sequence.public boolean isQueryCentricAlignment()
SequenceAlignmentDocumentSequenceAlignmentDocument.getContigReferenceSequenceIndex().isQueryCentricAlignment in class SequenceAlignmentDocumentpublic void setQueryCentricAlignment(boolean isQueryCentricAlignment)
setContigReferenceSequenceIndex(int)isQueryCentricAlignment - true if this is a query centric alignment.isQueryCentricAlignment(),
setContigReferenceSequenceIndex(int)public void setMates(int sequenceIndex,
int sequenceIndexOfMate,
int expectedMateDistance)
getMateExpectedDistance(int)).
Unlike SequenceAlignmentDocument.setMates(int, int, int) which allows for
an implementation to throw an UnsupportedOperationException this implementation will never throw it.setMates in class SequenceAlignmentDocumentsequenceIndex - the sequence to set the mate for.sequenceIndexOfMate - the index of its mate, or -1 if its mate is not in this contig.expectedMateDistance - the expected mate distance. See getMateExpectedDistance(int)IllegalArgumentException - if this sequence already has a different mate or if its mate is paired to a different sequence.public int getMateExpectedDistance(int sequenceIndex)
PairedReadsgetMateExpectedDistance in interface PairedReadsgetMateExpectedDistance in class SequenceAlignmentDocumentsequenceIndex - the index of the nucleotide sequence for which to get the mate index of.PairedReads.getMateIndex(int) will be -1.PairedReads.getMateIndex(int)public int getMateIndex(int sequenceIndex)
PairedReadsgetMateIndex in interface PairedReadsgetMateIndex in class SequenceAlignmentDocumentsequenceIndex - the index of the nucleotide sequence to get the mate index ofPairedReads.getMateExpectedDistance(int)public PairedReadManager getImmutablePairedReadManager()
PairedReadsgetImmutablePairedReadManager in interface PairedReadsgetImmutablePairedReadManager in class SequenceAlignmentDocumentpublic boolean canSetAnnotationsOnConsensus()
canSetAnnotationsOnConsensus in class SequenceAlignmentDocumentSequenceAlignmentDocument.setAnnotationsOnConsensus(java.util.List).SequenceAlignmentDocument.setAnnotationsOnConsensus(java.util.List)public List<SequenceAnnotation> getAnnotationsOnConsensus()
SequenceAlignmentDocumentgetAnnotationsOnConsensus in class SequenceAlignmentDocumentpublic void setAnnotationsOnConsensus(List<SequenceAnnotation> annotations)
SequenceAlignmentDocumentSequenceAlignmentDocument.getAnnotationsOnConsensus().
It is only legal to call this method if SequenceAlignmentDocument.canSetAnnotationsOnConsensus() returns true.setAnnotationsOnConsensus in class SequenceAlignmentDocumentannotations - the annotations to store on the consensus. Must not be null. This replaces any existing annotations on the consensus.SequenceAlignmentDocument.getAnnotationsOnConsensus(),
SequenceAlignmentDocument.canSetAnnotationsOnConsensus()public List<SequenceDocument> getSequencesInImmutableList()
SequenceAlignmentDocumentImmutableSequence.
Despite that, this method is still useful since if sequences are deleted, added or replaced in this alignment, the returned list will not change.
The default implementation of this method constructs a new list using SequenceAlignmentDocument.getSequences() and returns it.getSequencesInImmutableList in class SequenceAlignmentDocumentImmutableSequence.SequenceAlignmentDocument.getSequences()public boolean canSetAnnotations()
SequenceAlignmentDocumentSequenceAlignmentDocument.setAnnotations(int, java.util.List, boolean)
and SequenceAlignmentDocument.setAnnotationsOnConsensus(java.util.List)
Note that some alignment implementations may return true from SequenceAlignmentDocument.isEditable() and allow updating their annotations via
SequenceAlignmentDocument.updateSequence(int, CharSequence, java.util.List, NucleotideGraph, boolean) even if they return false from this method.canSetAnnotations in class SequenceAlignmentDocumentSequenceAlignmentDocument.setAnnotations(int, java.util.List, boolean)SequenceAlignmentDocument.setAnnotations(int, java.util.List, boolean),
SequenceAlignmentDocument.setAnnotationsOnConsensus(java.util.List),
SequenceAlignmentDocument.canSetAnnotationsOnConsensus()public void setAnnotations(int index,
List<SequenceAnnotation> annotations,
boolean allowModifyingReferencedDocuments)
SequenceAlignmentDocumentSequenceAlignmentDocument.canSetAnnotations() returns true
This is used for updating non-track annotations only. Track annotations are handled via a different API. To update or add tracks check if
a sequence in the alignment implements SequenceTrack.Manager.ProvidersetAnnotations in class SequenceAlignmentDocumentindex - the 0-based index of the sequence to set annotations on, or -1 to set annotations on the consensus sequence.annotations - the new annotations for this sequence, which will replace any existing annotations.allowModifyingReferencedDocuments - if this is true the original referenced sequence document will be modified to use these annotations
If this parameter is not true and then any reference to the original document will be discarded
and a copy of the original sequence stored internally within the alignment instead.public SequenceListSummary getSummary()
SequenceListSummary.ProvidergetSummary in interface SequenceListSummary.Providerpublic void setAlignmentDataForSequencesNotInMemory(SequenceListOnDisk.AlignmentData alignmentData)
getContigReferenceSequenceIndex().
The data is for sequences that are not loaded into memory. This method may not be used on an alignment that already has non-reference
sequences that are loaded into memory.alignmentData - the new alignmentData. Must not be null.IllegalStateException - if there are already non-reference sequences in this alignment that are loaded into memory.getAlignmentDataForSequencesNotInMemory()public SequenceListOnDisk.AlignmentData getAlignmentDataForSequencesNotInMemory()
SequenceListOnDisk, then this returns them along with data associated with them, or null if not.SequenceListOnDisk, then this returns them along with data associated with them, or null if its non-reference sequences are already in memory.setAlignmentDataForSequencesNotInMemory(com.biomatters.geneious.publicapi.documents.sequence.SequenceListOnDisk.AlignmentData)public void addContigReferenceSequence(SequenceDocument referenceSequence)
getContigReferenceSequenceIndex()==-1). The sequence will be added as the first
sequence in the alignment/contig.referenceSequence - the new reference sequence for this contig/alignment.public List<SequenceDocument> getSequences()
SequenceAlignmentDocumentSequenceAlignmentDocument.getNumberOfSequences() and SequenceAlignmentDocument.getSequence(int).getSequences in class SequenceAlignmentDocumentSequenceAlignmentDocument.getSequencesInImmutableList()public SequenceType getSequenceType()
SequenceAlignmentDocumentgetSequenceType in class SequenceAlignmentDocumentpublic long getSizeRequiredToLoadIntoMemory()
PluginDocument.SizeRequiredToLoadIntoMemoryProviderAnnotatedPluginDocument.getSize().
Geneious caches the value returned from this method when the document is wrapped in an AnnotatedPluginDocument or when it is saved.getSizeRequiredToLoadIntoMemory in interface PluginDocument.SizeRequiredToLoadIntoMemoryProviderpublic int getCircularLength()
SequenceAlignmentDocument
RefSeq: -GATTACA----
Read 1: ----TACAAGA-
Read 2: -----ACA-GAT
getCircularLength in class SequenceAlignmentDocumentpublic void setCircularLength(int circularLength)
circularLength - the circular length of this alignment, or 0 if this is not a circular alignmentpublic SequenceTrack.Manager getTrackManager(boolean mayReturnNullIfNoTracks)
SequenceTrack.Manager.ProviderSequenceTrack.Manager associated with this sequence for providing sequence tracks. For detailed information on sequence tracks, see SequenceTrack.
If this method is called on an alignment, the track manager is for the consensus sequence. Individual sequences in the alignment may also implement SequenceTrack.Manager.Provider if they provide tracks.getTrackManager in interface SequenceTrack.Manager.ProvidermayReturnNullIfNoTracks - to save on memory usage when dealing with lots of small sequences, some implementations may not wish to construct a TrackManager unless necessary. If this parameter is true the implementation may return null rather than an empty track manager if is has no tracks