T - the type of sequence in the listpublic abstract class SequenceListOnDisk<T extends SequenceDocument> extends AbstractList<T> implements SequenceListSummary.Provider, XMLSerializable, XMLSerializable.OldVersionCompatible
AbstractList.get(int) may sometimes implement editable interfaces, but if they do, no attempt should be made to modify them. Any
changes will be lost when the sequence is discarded from the cache.
A SequenceListOnDisk can be constructed using a SequenceListOnDiskStandard.Builder or from an existing
list using create(java.util.List, boolean, jebl.util.ProgressListener)
If there is a problem loading a sequence from disk, the AbstractList.get(int) method may throw a RuntimeException whose cause is an IOException.
However, in practice this shouldn't ever happen since we are reading from a local disk. However, if there is insufficient memory to load the sequence, it may throw a
RuntimeException whose cause is an IOException whose cause is an OutOfMemoryError
This class is thread safe| Modifier and Type | Class and Description |
|---|---|
static class |
SequenceListOnDisk.AlignmentData
An immutable class (all of whose elements are immutable too) representing the sequences and data relevant to the sequences (excluding the reference sequence) in an alignment.
|
static class |
SequenceListOnDisk.Builder<T extends SequenceDocument>
Used for building a SequenceListOnDisk.
|
XMLSerializable.OldVersionCompatible, XMLSerializable.VersionSupportTypemodCountROOT_ELEMENT_NAME| Modifier and Type | Method and Description |
|---|---|
abstract void |
cacheSequencesInMemory(ProgressListener progressListener)
Loads all sequences in this list into memory so that they can be quickly retrieved later using
AbstractList.get(int) |
static <T extends SequenceDocument> |
create(List<T> sequences,
boolean tryCompressingSequences,
ProgressListener progressListener)
Creates a new SequenceListOnDisk from an existing list of ungapped sequences.
|
static <T extends SequenceDocument> |
createInterlaced(SequenceListOnDisk<T> sequences1,
SequenceListOnDisk<T> sequences2,
ProgressListener progressListener)
Creates a new SequenceListOnDisk by interlacing a pair of existing SequenceListOnDisks.
|
static SequenceListOnDisk |
fromXml(org.jdom.Element element)
Recreates a SequenceListOnDisk from XML returned from
toXML(String) |
void |
fromXML(org.jdom.Element element)
Restore the object from the JDOM Element returned by
XMLSerializable.toXML(). |
static int |
getMaximumCachedUnalignedSequenceLength()
Returns the maximum length of an unaligned sequence which will be cached in memory to improve performance.
|
static int |
getMaximumSequencesCached(boolean isAlignmentOrContig)
Returns the maximum number of sequences (of length up to
if unaligned which will be cached in memory at one time. |
void |
invokeWhileHoldingLock(Runnable runnable)
Invokes a runnable while holding the synchronization lock for this sequence list on disk.
|
org.jdom.Element |
toXML(String elementName)
Converts this list to XML for use with storing in a
PluginDocument. |
add, add, addAll, clear, equals, get, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subListaddAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, size, toArray, toArray, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetSummarytoXMLgetVersionSupport, toXMLpublic static SequenceListOnDisk fromXml(org.jdom.Element element) throws XMLSerializationException
toXML(String)element - the element returned from a previous call to toXML(String)XMLSerializationException - if it can't be recreated.public org.jdom.Element toXML(String elementName)
PluginDocument. It can be reconstructed using fromXml(org.jdom.Element).
Note that the implementation uses PluginDocument.FILE_DATA_ATTRIBUTE_NAME so the XML should only be used inside a PluginDocumentelementName - the name of the element to returnpublic 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 objectpublic static <T extends SequenceDocument> SequenceListOnDisk<T> create(List<T> sequences, boolean tryCompressingSequences, ProgressListener progressListener) throws DocumentOperationException
SequenceListOnDisk.Builder is recommended.T - the type of sequencesequences - the sequences to put in the list.tryCompressingSequences - true to try compressing the sequences into a more compact storage format. This will be slow, but result in sequences using less space on disk and later when loaded into memory.progressListener - for reporting progress and cancellingDocumentOperationException - if there is a problem reading/writing to disk.public static <T extends SequenceDocument> SequenceListOnDisk<T> createInterlaced(SequenceListOnDisk<T> sequences1, SequenceListOnDisk<T> sequences2, ProgressListener progressListener) throws DocumentOperationException
T - the type of sequencesequences1 - the first sequences to put in the list.sequences2 - the second sequences to put in the list.progressListener - for reporting progress and cancellingIllegalArgumentException - if the 2 lists to be interlaced are not the same sizeDocumentOperationException - if there is a problem reading/writing to diskpublic static int getMaximumSequencesCached(boolean isAlignmentOrContig)
if unaligned which will be cached in memory at one time. A viewer on this data should not try viewing data when more than sequences are visible or it will hit cache throttling performance issues.isAlignmentOrContig - true to get the cache size for alignments/contigs. False to get the cache size for sequence listsgetMaximumCachedUnalignedSequenceLength()public static int getMaximumCachedUnalignedSequenceLength()
getMaximumSequencesCached(boolean)
sequences of this length or less will be cached to improve performance.getMaximumSequencesCached(boolean)public abstract void cacheSequencesInMemory(ProgressListener progressListener) throws DocumentOperationException
AbstractList.get(int)progressListener - for reporting progress and cancellingDocumentOperationException - if the sequences cannot be loadedpublic void invokeWhileHoldingLock(Runnable runnable)
AbstractList.get(int) needs to wait on a synchronization lock and if multiple threads
are doing this simultaneously, things can get quite slow. By obtaining the lock prior to
a series of AbstractList.get(int) calls performance can be significantly improved. This is intended
for use with rendering in the swing thread while other threads are calculating stuff in less important background threads.runnable - the runnable to run while holding the synchronization lock