java.lang.Object
com.biomatters.geneious.publicapi.documents.sequence.AlignmentLayout
All Implemented Interfaces:
XMLSerializable.OldVersionCompatible

public final class AlignmentLayout extends 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 a DefaultAlignmentDocument via DefaultAlignmentDocument.getAlignmentDataForSequencesNotInMemory().getLinkAllPairsLayout() or DefaultAlignmentDocument.getAlignmentDataForSequencesNotInMemory().getLinkNearbyPairsLayout() or DefaultAlignmentDocument.getAlignmentDataForSequencesNotInMemory().getLinkNoPairsLayout() Code should not construct an AlignmentLayout directly. Instead, AlignmentLayouts are constructed as part of creating an alignment via a SequenceListOnDisk.Builder

Unless you are writing your own contig viewer, you can probably ignore this class.

Since:
API 4.40 (Geneious 5.4.0)
  • Constructor Details

  • Method Details

    • getVersionSupport

      public Geneious.MajorVersion getVersionSupport(XMLSerializable.VersionSupportType versionType)
      Description copied from interface: XMLSerializable.OldVersionCompatible
      Gets either the latest version this class can serialize to via XMLSerializable.OldVersionCompatible.toXML(Geneious.MajorVersion, ProgressListener) or the most recent version in which the XML returned from XMLSerializable.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 interface XMLSerializable.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(String elementName)
      Converts this layout to XML for use with AlignmentLayout(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, 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:
      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 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
    • 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 to getNumberOfRows()
      Returns:
      true if pairs reads in the given row number are linked (i.e. nothing is laid out between them)
      Throws:
      IndexOutOfBoundsException - if rowNumber is not between 0 and getNumberOfRows()-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:
      IndexOutOfBoundsException - if sequenceNumber is not between 0 and getNumberOfSequences()-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 number
      columnIndex - 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:
      IndexOutOfBoundsException - if rowNumber is not between 0 and getNumberOfRows()-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 number
      firstColumn - 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:
      IndexOutOfBoundsException - if rowNumber is not between 0 and getNumberOfRows()-1 inclusive.
    • finalize

      protected void finalize() throws Throwable
      Overrides:
      finalize in class Object
      Throws:
      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