BamRead

BAM record representation.

struct BamRead {}

Constructors

this
this(ubyte[] chunk, bool fix_byte_order)
Undocumented in source.
this
this(string read_name, string sequence, CigarOperation[] cigar)

Construct alignment from basic information about it.

Members

Functions

_recalculate_bin
void _recalculate_bin()
Undocumented in source. Be warned that the author may not have intended to support it.
associateWithReader
void associateWithReader(bio.std.hts.bam.abstractreader.IBamSamReader reader)

Associates read with BAM reader. This is done automatically if this read is obtained through BamReader/Reference methods.

basesCovered
int basesCovered()

The number of reference bases covered by this read.
Returns 0 if the read is unmapped.

cigarString
string cigarString()

Human-readable representation of CIGAR string (same as in SAM format)

dup
BamRead dup()

Deep copy of the record.

extended_cigar
auto extended_cigar()

Extended CIGAR where M operators are replaced with =/X based on information from MD tag. Throws if the read doesn't have MD tag.

is_slice_backed
bool is_slice_backed()
opEquals
bool opEquals(BamRead other)

Compare two alignments, including tags (the tags must follow in the same order for equality).

opEquals
bool opEquals(const(BamRead) other)
Undocumented in source. Be warned that the author may not have intended to support it.
raw_data
void raw_data(ubyte[] data)

Raw representation of the read. Occasionally useful for dirty hacks!

raw_data
inout(ubyte)[] raw_data()

Raw representation of the read. Occasionally useful for dirty hacks!

reader
inout(bio.std.hts.bam.abstractreader.IBamSamReader) reader()

Associated BAM/SAM reader.

toJson
void toJson(Sink sink)
string toJson()

JSON representation

toMsgpack
void toMsgpack(Packer packer)

Packs message in the following format:
MsgPack array with elements

  1. name - string
  2. flag - ushort
  3. reference sequence id - int
  4. leftmost mapping position (1-based) - int
  5. mapping quality - ubyte
  6. array of CIGAR operation lengths - int[]
  7. array of CIGAR operation types - ubyte[]
  8. mate reference sequence id - int
  9. mate position (1-based) - int
  10. template length - int
  11. segment sequence - string
  12. phred-base quality - ubyte[]
  13. tags - map: string -> value
toSam
void toSam(Sink sink)
string toSam()

String representation.
Possible formats are SAM ("%s") and JSON ("%j")

toString
void toString(void delegate(const(char)[]) sink, FormatSpec!char fmt)

String representation.
Possible formats are SAM ("%s") and JSON ("%j")

write
void write(BamWriter writer)
Undocumented in source. Be warned that the author may not have intended to support it.

Mixins

__anonymous
mixin TagStorage
Undocumented in source.

Properties

base_qualities
inout(ubyte)[] base_qualities [@property getter]

Quality data (phred-based scores)

base_qualities
const(ubyte)[] base_qualities [@property setter]

Set quality data - array length must be of the same length as the sequence.

bin
bio.std.hts.bam.bai.bin.Bin bin [@property getter]

Indexing bin which this read belongs to. Recalculated when position is changed.

cigar
const(CigarOperation)[] cigar [@property getter]
const(CigarOperation)[] cigar [@property setter]

List of CIGAR operations

failed_quality_control
bool failed_quality_control [@property getter]
bool failed_quality_control [@property setter]

Not passing quality controls

flag
ushort flag [@property getter]
ushort flag [@property setter]

Flag bits (should be used on very rare occasions, see flag getters/setters below)

is_duplicate
bool is_duplicate [@property getter]
bool is_duplicate [@property setter]

PCR or optical duplicate

is_first_of_pair
bool is_first_of_pair [@property getter]
bool is_first_of_pair [@property setter]

The first segment in the template

is_paired
bool is_paired [@property getter]
bool is_paired [@property setter]

Template having multiple segments in sequencing

is_reverse_strand
bool is_reverse_strand [@property getter]
bool is_reverse_strand [@property setter]

Sequence being reverse complemented

is_second_of_pair
bool is_second_of_pair [@property getter]
bool is_second_of_pair [@property setter]

The last segment in the template

is_secondary_alignment
bool is_secondary_alignment [@property getter]
bool is_secondary_alignment [@property setter]

Secondary alignment

is_supplementary
bool is_supplementary [@property getter]
bool is_supplementary [@property setter]

Supplementary alignment

is_unmapped
bool is_unmapped [@property getter]
bool is_unmapped [@property setter]

Segment unmapped

mapping_quality
ubyte mapping_quality [@property getter]
ubyte mapping_quality [@property setter]

Mapping quality. Equals to 255 if not available, otherwise equals to rounded -10 * log10(P {mapping position is wrong}).

mate_is_reverse_strand
bool mate_is_reverse_strand [@property getter]
bool mate_is_reverse_strand [@property setter]

Sequence of the next segment in the template being reversed

mate_is_unmapped
bool mate_is_unmapped [@property getter]
bool mate_is_unmapped [@property setter]

Next segment in the template unmapped

mate_position
int mate_position [@property getter]
int mate_position [@property setter]

Mate position

mate_ref_id
int mate_ref_id [@property getter]
int mate_ref_id [@property setter]

Mate reference ID

mate_ref_name
string mate_ref_name [@property getter]

Mate reference sequence name ('*' for unmapped mates)

name
string name [@property getter]
string name [@property setter]

Read name, length must be in 1..255 interval.

position
int position [@property getter]
int position [@property setter]

0-based leftmost coordinate of the first matching base

proper_pair
bool proper_pair [@property getter]
bool proper_pair [@property setter]

Each segment properly aligned according to the aligner

ref_id
int ref_id [@property getter]
int ref_id [@property setter]

Reference index in BAM file header

ref_name
string ref_name [@property getter]

Reference sequence name ('*' for unmapped reads)

sequence
SequenceResult sequence [@property getter]

Random-access range of characters

sequence
string sequence [@property setter]

Sets query sequence. Sets all base qualities to 255 (i.e. unknown).

sequence_length
int sequence_length [@property getter]

Sequence length. In fact, sequence.length can be used instead, but that might be slower if the compiler is not smart enough to optimize away unrelated stuff.

size_in_bytes
size_t size_in_bytes [@property getter]

Size of the alignment record when output to stream in BAM format. Includes block_size as well (see SAM/BAM specification)

strand
char strand [@property getter]
char strand [@property setter]

Convenience function, returns '+' or '-' indicating the strand.

template_length
int template_length [@property getter]
int template_length [@property setter]

Template length

Structs

SequenceResult
struct SequenceResult

Read-only random-access range for access to sequence data.

Variables

_chunk
ubyte[] _chunk;
Undocumented in source.

Mixed In Members

From mixin TagStorage

opIndex
bio.std.hts.bam.tagvalue.Value opIndex(string key)
opIndexAssign
void opIndexAssign(T value, string key)

Hash-like access to tags. Time complexity is O(number of tags).
If tag with such key is not found, returned value 'is nothing'.
If key length is different from 2, exception is thrown.
Special case when value represents nothing is used for removing tag (assuming that no more than one with this key is presented in the record).

appendTag
void appendTag(string key, Value value)

Append new tag to the end, skipping check if it already exists. O(1)

clearAllTags
void clearAllTags()

Remove all tags

tagCount
size_t tagCount()

Number of tags. O(number of tags)

opApply
int opApply(int delegate(const ref string k, const ref Value v) dg)

Provides opportunity to iterate over tags.

tagCount
size_t tagCount()

Returns the number of tags. Time complexity is O(number of tags)

Meta