public class AlignmentReaderImpl extends AbstractAlignmentReader implements AlignmentReader
| Modifier and Type | Field and Description |
|---|---|
static String[] |
COMPACT_ALIGNMENT_FILE_POSSIBLE_EXTS
Other possible extensions that can follow a Goby alignment basename.
|
static String[] |
COMPACT_ALIGNMENT_FILE_REQUIRED_EXTS
Required file extension for alignment data in "compact reads" format.
|
constantLength, constantQueryLengths, largestQueryIndex, numberOfQueries, numberOfTargets, queryIdentifiers, sampleBasenames, smallestQueryIndex, targetIdentifiers, targetLengths| Constructor and Description |
|---|
AlignmentReaderImpl(InputStream entriesStream) |
AlignmentReaderImpl(long start,
long end,
it.unimi.dsi.fastutil.io.FastBufferedInputStream stream)
Initialize the reader to read a segment of the input.
|
AlignmentReaderImpl(long startOffset,
long endOffset,
String basename)
Open a Goby alignment file for reading between the byte positions startOffset and endOffset.
|
AlignmentReaderImpl(long startOffset,
long endOffset,
String basename,
boolean upgrade)
Open a Goby alignment file for reading between the byte positions startOffset and endOffset.
|
AlignmentReaderImpl(String basename) |
AlignmentReaderImpl(String basename,
boolean upgrade) |
AlignmentReaderImpl(String basename,
int startReferenceIndex,
int startPosition,
int endReferenceIndex,
int endPosition)
A constructor that allows reading a slice of an alignment file contained exactly between a start
and an end location.
|
AlignmentReaderImpl(String basename,
int startReferenceIndex,
int startPosition,
int endReferenceIndex,
int endPosition,
boolean upgrade)
A constructor that allows reading a slice of an alignment file contained exactly between a start
and an end location.
|
| Modifier and Type | Method and Description |
|---|---|
String |
basename()
Returns the basename for the alignment being read, or null if the basename is unknown.
|
static boolean |
canRead(String filename)
Returns true if filename belongs to an alignment basename that can be read.
|
void |
close() |
String |
getAlignerName()
Return the name of the aligner that produced this alignment.
|
String |
getAlignerVersion()
Return the version of the aligner that produced this alignment.
|
protected long |
getByteOffset(int targetIndex,
int position,
int chunkOffset)
Calculate the offset (in bytes) in the compact entries file for a specific targetIndex and position.
|
int |
getConstantQueryLength() |
long |
getEndByteOffset(int startReferenceIndex,
int startPosition,
int endReferenceIndex,
int endPosition)
Obtain the byte offset at the end of the chunk with entries at or before the given genomic end position.
|
String |
getGobyVersion()
Return the version of Goby that created this alignment.
|
boolean |
getHasAllReadQualityScores()
Indicates if all the entries of this alignment have the read_quality_score field.
|
it.unimi.dsi.fastutil.objects.ObjectList<ReferenceLocation> |
getLocations(int modulo)
Returns a sample of locations covered by this alignment.
|
it.unimi.dsi.fastutil.objects.ObjectList<ReferenceLocation> |
getLocationsByBytes(int bytesPerSlice)
Returns a sample of locations covered by this alignment.
|
ReferenceLocation |
getMaxLocation()
Return the maximum location in this alignment.
|
ReferenceLocation |
getMinLocation()
Return the minimum location in this alignment.
|
int |
getNumberOfAlignedReads()
Obtain the number of aligned reads from the header.
|
boolean |
getQueryIndicesWerePermuted()
Indicate whether query indices are small indices.
|
ReadOriginInfo |
getReadOriginInfo()
Return the read origin infos from the header.
|
long |
getStartByteOffset(int startReferenceIndex,
int startPosition)
Obtain the byte offset at the start of the chunk with entries at or after the given genomic position.
|
Properties |
getStatistics()
Obtain statistics asssociated with the alignment.
|
boolean |
hasAmbiguity()
This field is true when entries in the alignment .entries file all have the ambiguity field populated
(Since Goby 2.0).
|
boolean |
hasNext()
Returns true if the input has more entries.
|
boolean |
hasQueryIndexOccurrences()
This field is true when entries in the alignment .entries file all have the query_index_occurences field populated
(Since Goby 2.0).
|
boolean |
isIndexed()
Returns true if this alignment is indexed.
|
boolean |
isQueryLengthStoredInEntries()
Indicates if query lengths are stored in alignment entries (True) or in the alignment header (alignments produced with goby 1.7-, False).
|
boolean |
isSorted()
Returns whether this alignment is sorted.
|
Iterator<Alignments.AlignmentEntry> |
iterator() |
Alignments.AlignmentEntry |
next()
Returns the next alignment entry from the input stream.
|
void |
readHeader()
Read the header of this alignment.
|
void |
readIndex()
Read the index.
|
protected long |
recodePosition(int firstTargetIndexInChunk,
int firstPositionInChunk) |
void |
remove()
This operation is not supported.
|
void |
reposition(int targetIndex,
int position)
Reposition the reader to a new target sequence and start position.
|
protected void |
seek(long byteOffset)
Seek to a position in the entries file.
|
Alignments.AlignmentEntry |
skipTo(int targetIndex,
int position)
Skip all entries that have position before (targetIndex,position).
|
getBasename, getBasenames, getLargestSplitQueryIndex, getNumberOfQueries, getNumberOfTargets, getQueryIdentifiers, getSampleBasename, getSmallestSplitQueryIndex, getTargetIdentifiers, getTargetLength, getTargetLength, isConstantQueryLengths, isHeaderLoaded, setHeaderLoadedclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetLargestSplitQueryIndex, getNumberOfQueries, getNumberOfTargets, getQueryIdentifiers, getSmallestSplitQueryIndex, getTargetIdentifiers, getTargetLength, isConstantQueryLengthsforEachRemainingforEach, spliteratorpublic static final String[] COMPACT_ALIGNMENT_FILE_REQUIRED_EXTS
public static final String[] COMPACT_ALIGNMENT_FILE_POSSIBLE_EXTS
public AlignmentReaderImpl(String basename, int startReferenceIndex, int startPosition, int endReferenceIndex, int endPosition) throws IOException
basename - Basename for the alignemnt.startReferenceIndex - Index of the reference for the start position.startPosition - Position on the reference for the start position.endReferenceIndex - Index of the reference for the end position.endPosition - Position on the reference for the end position.IOException - Thrown if an error occurs opening or reading the alignment file.public AlignmentReaderImpl(String basename, int startReferenceIndex, int startPosition, int endReferenceIndex, int endPosition, boolean upgrade) throws IOException
basename - Basename for the alignemnt.startReferenceIndex - Index of the reference for the start position.startPosition - Position on the reference for the start position.endReferenceIndex - Index of the reference for the end position.endPosition - Position on the reference for the end position.IOException - Thrown if an error occurs opening or reading the alignment file.public AlignmentReaderImpl(long startOffset,
long endOffset,
String basename)
throws IOException
startOffset - Position in the file where reading will start (in bytes).endOffset - Position in the file where reading will end (in bytes).basename - Basename of the alignment to read.IOException - If an error occurs opening or reading the file.public AlignmentReaderImpl(long startOffset,
long endOffset,
String basename,
boolean upgrade)
throws IOException
startOffset - Position in the file where reading will start (in bytes).endOffset - Position in the file where reading will end (in bytes).basename - Basename of the alignment to read.upgrade - Whether to try to upgrade the alignment on the fly.IOException - If an error occurs opening or reading the file.public AlignmentReaderImpl(String basename) throws IOException
IOExceptionpublic AlignmentReaderImpl(String basename, boolean upgrade) throws IOException
IOExceptionpublic AlignmentReaderImpl(InputStream entriesStream) throws IOException
IOExceptionpublic AlignmentReaderImpl(long start,
long end,
it.unimi.dsi.fastutil.io.FastBufferedInputStream stream)
throws IOException
hasNext(), next().start - Start offset in the input file.end - End offset in the input file.stream - Stream over the input fileIOException - If an error occurs reading the input.public boolean isSorted()
isSorted in interface AlignmentReaderpublic boolean isIndexed()
isIndexed in interface AlignmentReaderpublic static boolean canRead(String filename)
filename - Filename of an alignment component.public String basename()
basename in interface AlignmentReaderpublic boolean hasNext()
hasNext in interface Iterator<Alignments.AlignmentEntry>hasNext in interface AlignmentReaderpublic Alignments.AlignmentEntry next()
next in interface Iterator<Alignments.AlignmentEntry>next in interface AlignmentReaderpublic final Alignments.AlignmentEntry skipTo(int targetIndex, int position) throws IOException
skipTo in interface AlignmentReadertargetIndex - The index of the target sequence to skip to.position - The position on the target sequence.IOException - If an error occurs reading the alignment header. The header is accessed to check that the alignment is sorted.public final void reposition(int targetIndex,
int position)
throws IOException
reposition in interface AlignmentReadertargetIndex - Index of the target sequence to reposition to.position - Position in the target sequence to reposition to.IOException - If an error occurs repositioning.protected void seek(long byteOffset)
throws IOException
byteOffset - Where to reposition the stream.IOException - If an error occured.protected long getByteOffset(int targetIndex,
int position,
int chunkOffset)
targetIndex - Index of a reference sequence.position - Position along the reference sequence.chunkOffset - Offset used to iterate through successive PB chunks.protected long recodePosition(int firstTargetIndexInChunk,
int firstPositionInChunk)
public void remove()
remove in interface Iterator<Alignments.AlignmentEntry>remove in interface AlignmentReaderpublic void readHeader()
throws IOException
readHeader in interface AlignmentReaderreadHeader in class AbstractAlignmentReaderIOException - If an error occurs.public boolean getHasAllReadQualityScores()
public final void readIndex()
throws IOException
readIndex in interface AlignmentReaderIOException - If an error occurs loading the index or header.public void close()
close in interface Closeableclose in interface AutoCloseableclose in interface AlignmentReaderpublic Iterator<Alignments.AlignmentEntry> iterator()
iterator in interface Iterable<Alignments.AlignmentEntry>iterator in interface AlignmentReaderpublic Properties getStatistics()
AlignmentReadergetStatistics in interface AlignmentReaderpublic int getNumberOfAlignedReads()
AlignmentReadergetNumberOfAlignedReads in interface AlignmentReaderpublic ReferenceLocation getMinLocation() throws IOException
AbstractAlignmentReadergetMinLocation in interface AlignmentReadergetMinLocation in class AbstractAlignmentReaderIOExceptionpublic ReferenceLocation getMaxLocation() throws IOException
AbstractAlignmentReadergetMaxLocation in interface AlignmentReadergetMaxLocation in class AbstractAlignmentReaderIOExceptionpublic it.unimi.dsi.fastutil.objects.ObjectList<ReferenceLocation> getLocationsByBytes(int bytesPerSlice) throws IOException
AlignmentReadergetLocationsByBytes in interface AlignmentReaderbytesPerSlice - Return locations approximately spaced by this number of compressed bytes.IOExceptionpublic it.unimi.dsi.fastutil.objects.ObjectList<ReferenceLocation> getLocations(int modulo) throws IOException
getLocations in interface AlignmentReadermodulo - Modulo to avoid sampling every position in the genome.IOExceptionpublic boolean isQueryLengthStoredInEntries()
AlignmentReaderisQueryLengthStoredInEntries in interface AlignmentReaderpublic String getAlignerName()
getAlignerName in interface AlignmentReadergetAlignerName in class AbstractAlignmentReaderpublic String getAlignerVersion()
getAlignerVersion in interface AlignmentReadergetAlignerVersion in class AbstractAlignmentReaderpublic int getConstantQueryLength()
getConstantQueryLength in interface AlignmentReaderpublic long getStartByteOffset(int startReferenceIndex,
int startPosition)
AlignmentReadergetStartByteOffset in interface AlignmentReaderstartReferenceIndex - Index of the reference sequence for the genomic position.startPosition - genomic coordinate in the reference sequence.public boolean getQueryIndicesWerePermuted()
AlignmentReadergetQueryIndicesWerePermuted in interface AlignmentReaderpublic boolean hasQueryIndexOccurrences()
AlignmentReaderhasQueryIndexOccurrences in interface AlignmentReaderpublic boolean hasAmbiguity()
AlignmentReaderhasAmbiguity in interface AlignmentReaderpublic long getEndByteOffset(int startReferenceIndex,
int startPosition,
int endReferenceIndex,
int endPosition)
AlignmentReadergetEndByteOffset in interface AlignmentReaderstartReferenceIndex - Index of the reference sequence for the start genomic position.startPosition - start genomic coordinate in the reference sequence.endReferenceIndex - Index of the reference sequence for the end genomic position.endPosition - end genomic coordinate in the reference sequence.public ReadOriginInfo getReadOriginInfo()
AlignmentReadergetReadOriginInfo in interface AlignmentReaderpublic String getGobyVersion()
Copyright © 2018 Campagne Laboratory. All rights reserved.