plastid.readers.bowtie module¶
This module contains a parser for bowtie’s legacy output format.
Functions in this module are are seldom used on their own, and rather are
accessed by GenomeArray
or SparseGenomeArray
when importing from
bowtie files.
See also¶
GenomeArray
andSparseGenomeArray
Array-like objects that store and index quantitative data over genomes
- http://bowtie-bio.sourceforge.net/manual.shtml#default-bowtie-output
Detailed description of bowtie output format
plastid.test.unit.genomics.test_genome_array
for integrative tests of these functions
- class plastid.readers.bowtie.BowtieReader(stream)[source]¶
Bases:
plastid.util.io.filters.AbstractReader
Read alignments from bowtie files line-by-line into
SegmentChains
. The following attributes are defined and stored in the attr dict of each returnedSegmentChain
- seq_as_aligned
the sequence in the direction it aligns, NOT necessarily the read in the direction it was sequenced
- qualstr_phred
a quality string, phred encoded
- total_alignments
the number of total alignments found
See description of bowtie legacy format at http://bowtie-bio.sourceforge.net/manual.shtml
- Parameters
- streamfile-like
Stream of alignments in bowtie’s legacy output format
- Yields
SegmentChain
A read alignment
- Attributes
- closed
Methods
close
()Close stream
fileno
()Returns underlying file descriptor if one exists.
filter
(line)Parse a read alignment as
SegmentChain
from a line of bowtie outputflush
(/)Flush write buffers, if applicable.
isatty
()Return whether this is an 'interactive' stream.
read
()Similar to
file.read()
.readable
()Return whether object was opened for reading.
readline
()Process a single line of data, assuming it is string-like
next(self)
is more likely to behave as expected.Similar to
file.readlines()
.Change stream position.
seekable
()Return whether object supports random access.
tell
(/)Return current stream position.
Truncate file to size bytes.
writable
()Return whether object was opened for writing.
writelines
(lines, /)Write a list of lines to stream.
next
- close()¶
Close stream
- fileno()¶
Returns underlying file descriptor if one exists.
OSError is raised if the IO object does not use a file descriptor.
- filter(line)[source]¶
Parse a read alignment as
SegmentChain
from a line of bowtie output
- flush(/)¶
Flush write buffers, if applicable.
This is not implemented for read-only and non-blocking streams.
- isatty()¶
Return whether this is an ‘interactive’ stream.
Return False if it can’t be determined.
- next()¶
- read()¶
Similar to
file.read()
. Process all units of data, assuming it is string-like- Returns
- str
- readable()¶
Return whether object was opened for reading.
If False, read() will raise OSError.
- readline()¶
Process a single line of data, assuming it is string-like
next(self)
is more likely to behave as expected.- Returns
- object
a unit of processed data
- readlines()¶
Similar to
file.readlines()
.- Returns
- list
processed data
- seek()¶
Change stream position.
Change the stream position to the given byte offset. The offset is interpreted relative to the position indicated by whence. Values for whence are:
0 – start of stream (the default); offset should be zero or positive
1 – current stream position; offset may be negative
2 – end of stream; offset is usually negative
Return the new absolute position.
- seekable()¶
Return whether object supports random access.
If False, seek(), tell() and truncate() will raise OSError. This method may need to do a test seek().
- tell(/)¶
Return current stream position.
- truncate()¶
Truncate file to size bytes.
File pointer is left unchanged. Size defaults to the current IO position as reported by tell(). Returns the new size.
- writable()¶
Return whether object was opened for writing.
If False, write() will raise OSError.
- writelines(lines, /)¶
Write a list of lines to stream.
Line separators are not added, so it is usual for each of the lines provided to have a line separator at the end.
- closed¶