Class AlignmentLayout
- java.lang.Object
-
- com.biomatters.geneious.publicapi.documents.sequence.AlignmentLayout
-
- All Implemented Interfaces:
XMLSerializable.OldVersionCompatible
public final class AlignmentLayout extends java.lang.Object implements XMLSerializable.OldVersionCompatible
Provides information about how to layout of sequences (excluding the reference sequence) for rendering in an alignment or contig. Each sequence is assigned to a row number such that all the sequences in a row do not overlap each other and have a minimum separation. Paired reads can optionally be forced to appear in the same row as their mate, with no sequences in between. In order to support very large alignments or contigs, the data is never all loaded into memory at once, but is instead loaded on demand (with caching) An AlignmentLayout can be obtained from aDefaultAlignmentDocument
viaDefaultAlignmentDocument.getAlignmentDataForSequencesNotInMemory()
.getLinkAllPairsLayout()
orDefaultAlignmentDocument.getAlignmentDataForSequencesNotInMemory()
.getLinkNearbyPairsLayout()
orDefaultAlignmentDocument.getAlignmentDataForSequencesNotInMemory()
.getLinkNoPairsLayout()
Code should not construct an AlignmentLayout directly. Instead, AlignmentLayouts are constructed as part of creating an alignment via aSequenceListOnDisk.Builder
Unless you are writing your own contig viewer, you can probably ignore this class.- Since:
- API 4.40 (Geneious 5.4.0)
-
-
Constructor Summary
Constructors Constructor Description AlignmentLayout(org.jdom.Element element)
Recreates an AlignmentLayout from XML.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
finalize()
static int
getMaximumColumnsCached()
Returns the maximum number of columns in the alignment which will be cached in memory at one time.int
getNumberOfColumnsInAlignment()
Returns the number of columns in the alignmentint
getNumberOfRows()
Returns the total number of rows used for laying out sequencesint
getNumberOfSequences()
int
getRowNumber(int sequenceNumber)
Get the row number that the given sequence has been lain out in.int
getSequenceInRowNearestToColumn(int rowNumber, int columnIndex)
For a given row, gets the sequence covering this column index, or if there isn't a sequence covering this column, returns the nearest sequence to it.IntList
getSequencesInRowIntersectingRange(int rowNumber, int firstColumn, int lastColumnInclusive)
Gets all sequences in the given row that intersect with the given range of columnsGeneious.MajorVersion
getVersionSupport(XMLSerializable.VersionSupportType versionType)
Gets either the latest version this class can serialize to viaXMLSerializable.OldVersionCompatible.toXML(Geneious.MajorVersion, ProgressListener)
or the most recent version in which the XML returned fromXMLSerializable.OldVersionCompatible.toXML(Geneious.MajorVersion, ProgressListener)
last changed.boolean
isLinkPairedReadsInRow(int rowNumber)
Returns true if pairs reads in the given row number are linked (i.e.org.jdom.Element
toXML(Geneious.MajorVersion majorVersion, jebl.util.ProgressListener progressListener)
Serializes this class to XML format, potentially to a format readable by an earlier version of Geneious.org.jdom.Element
toXML(java.lang.String elementName)
Converts this layout to XML for use withAlignmentLayout(org.jdom.Element)
-
-
-
Constructor Detail
-
AlignmentLayout
public AlignmentLayout(org.jdom.Element element) throws XMLSerializationException
Recreates an AlignmentLayout from XML.- Parameters:
element
- an element returned fromtoXML(String)
- Throws:
XMLSerializationException
- if we can't deserialize because the XML is invalid
-
-
Method Detail
-
getVersionSupport
public Geneious.MajorVersion getVersionSupport(XMLSerializable.VersionSupportType versionType)
Description copied from interface:XMLSerializable.OldVersionCompatible
Gets either the latest version this class can serialize to viaXMLSerializable.OldVersionCompatible.toXML(Geneious.MajorVersion, ProgressListener)
or the most recent version in which the XML returned fromXMLSerializable.OldVersionCompatible.toXML(Geneious.MajorVersion, ProgressListener)
last changed. Example implementation:switch (versionType) { case FormatLastExtended: //added a new tag to xml in 10.0 that can be safely ignored by older versions return Geneious.MajorVersion.Version10_0; case FormatLastChanged: //renamed a tag in 9.1 meaning that older versions can no longer read the xml from 9.1 return Geneious.MajorVersion.Version9_1; case OldestVersionSerializableTo: //this document class can export xml that is compatible with 9.0 return Geneious.MajorVersion.Version9_0; default: throw new IllegalArgumentException("Unrecognized VersionSupportType"); }
- Specified by:
getVersionSupport
in interfaceXMLSerializable.OldVersionCompatible
- Parameters:
versionType
- specifies which version property to return- Returns:
- the major version of Geneious corresponding to the versionType for this classes toXML method.
-
toXML
public org.jdom.Element toXML(java.lang.String elementName)
Converts this layout to XML for use withAlignmentLayout(org.jdom.Element)
- Parameters:
elementName
- the name of the element to return- Returns:
- this layout as XML. Note that this uses
PluginDocument.FILE_DATA_ATTRIBUTE_NAME
-
toXML
public org.jdom.Element toXML(Geneious.MajorVersion majorVersion, 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. SeeXMLSerializable.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 interfaceXMLSerializable.OldVersionCompatible
- Parameters:
majorVersion
- 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 fromgetVersionSupport
(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
-
getNumberOfColumnsInAlignment
public int getNumberOfColumnsInAlignment()
Returns the number of columns in the alignment- Returns:
- the number of columns in the alignment
-
getNumberOfSequences
public int getNumberOfSequences()
- Returns:
- the number of sequences in this layout
-
getNumberOfRows
public int getNumberOfRows()
Returns the total number of rows used for laying out sequences- Returns:
- the total number of rows used for laying out sequences
-
isLinkPairedReadsInRow
public boolean isLinkPairedReadsInRow(int rowNumber)
Returns true if pairs reads in the given row number are linked (i.e. nothing is laid out between them)- Parameters:
rowNumber
- the 0-based row number (from 0 togetNumberOfRows()
- Returns:
- true if pairs reads in the given row number are linked (i.e. nothing is laid out between them)
- Throws:
java.lang.IndexOutOfBoundsException
- if rowNumber is not between 0 andgetNumberOfRows()
-1 inclusive.
-
getRowNumber
public int getRowNumber(int sequenceNumber)
Get the row number that the given sequence has been lain out in.- Parameters:
sequenceNumber
- the 0-based sequence number- Returns:
- the 0-based row number (will be between 0 and
getNumberOfRows()
-1 inclusive) - Throws:
java.lang.IndexOutOfBoundsException
- if sequenceNumber is not between 0 andgetNumberOfSequences()
-1 inclusive.
-
getSequenceInRowNearestToColumn
public int getSequenceInRowNearestToColumn(int rowNumber, int columnIndex)
For a given row, gets the sequence covering this column index, or if there isn't a sequence covering this column, returns the nearest sequence to it.- Parameters:
rowNumber
- the 0-based row numbercolumnIndex
- the 0-based index of the column. If this is out of the range 0->getNumberOfColumnsInAlignment()
it will be clipped to that range.- Returns:
- the nearest sequence. Every row has at least 1 sequence so this method will always return a valid sequence number.
- Throws:
java.lang.IndexOutOfBoundsException
- if rowNumber is not between 0 andgetNumberOfRows()
-1 inclusive.
-
getSequencesInRowIntersectingRange
public IntList getSequencesInRowIntersectingRange(int rowNumber, int firstColumn, int lastColumnInclusive)
Gets all sequences in the given row that intersect with the given range of columns- Parameters:
rowNumber
- the 0-based row numberfirstColumn
- the 0-based index of the first column. If this is out of the range 0->getNumberOfColumnsInAlignment()
it will be clipped to that range.lastColumnInclusive
- the 0-based index (inclusive) of the last column- Returns:
- all sequences that intersect the given range of columns.
- Throws:
java.lang.IndexOutOfBoundsException
- if rowNumber is not between 0 andgetNumberOfRows()
-1 inclusive.
-
finalize
protected void finalize() throws java.lang.Throwable
- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
-
getMaximumColumnsCached
public static int getMaximumColumnsCached()
Returns the maximum number of columns in the alignment which will be cached in memory at one time. A viewer on this data should not try viewing data when more than this many columns are visible or it will hit cache throttling performance issues.- Returns:
- the maximum number of columns in the alignment which will be cached in memory at one time. A viewer on this data should not try viewing data when more than this many columns are visible or it will hit cache throttling performance issues
-
-