Public API Reference
Contents
XAM.SAM.FLAG_DUP
XAM.SAM.FLAG_MREVERSE
XAM.SAM.FLAG_MUNMAP
XAM.SAM.FLAG_PAIRED
XAM.SAM.FLAG_PROPER_PAIR
XAM.SAM.FLAG_QCFAIL
XAM.SAM.FLAG_READ1
XAM.SAM.FLAG_READ2
XAM.SAM.FLAG_REVERSE
XAM.SAM.FLAG_SECONDARY
XAM.SAM.FLAG_SUPPLEMENTARY
XAM.SAM.FLAG_UNMAP
XAM.BAM.BAI
XAM.BAM.BAI
XAM.BAM.Reader
XAM.BAM.Record
XAM.BAM.Writer
XAM.SAM.Header
XAM.SAM.MetaInfo
XAM.SAM.MetaInfo
XAM.SAM.Reader
XAM.SAM.Record
XAM.SAM.Record
XAM.SAM.Record
XAM.SAM.Writer
Base.findall
BioGenerics.header
BioGenerics.header
XAM.BAM.alignlength
XAM.BAM.alignment
XAM.BAM.auxdata
XAM.BAM.cigar
XAM.BAM.cigar_rle
XAM.BAM.flag
XAM.BAM.ismapped
XAM.BAM.isnextmapped
XAM.BAM.ispositivestrand
XAM.BAM.isprimary
XAM.BAM.mappingquality
XAM.BAM.n_cigar_op
XAM.BAM.nextposition
XAM.BAM.nextrefid
XAM.BAM.nextrefname
XAM.BAM.position
XAM.BAM.quality
XAM.BAM.refid
XAM.BAM.reflen
XAM.BAM.refname
XAM.BAM.rightposition
XAM.BAM.seqlength
XAM.BAM.sequence
XAM.BAM.templength
XAM.BAM.tempname
XAM.SAM.alignlength
XAM.SAM.alignment
XAM.SAM.auxdata
XAM.SAM.cigar
XAM.SAM.flag
XAM.SAM.iscomment
XAM.SAM.ismapped
XAM.SAM.isnextmapped
XAM.SAM.isprimary
XAM.SAM.keyvalues
XAM.SAM.mappingquality
XAM.SAM.nextposition
XAM.SAM.nextrefname
XAM.SAM.position
XAM.SAM.quality
XAM.SAM.quality
XAM.SAM.refname
XAM.SAM.rightposition
XAM.SAM.seqlength
XAM.SAM.sequence
XAM.SAM.sequence
XAM.SAM.tag
XAM.SAM.templength
XAM.SAM.tempname
XAM.SAM.value
SAM API
The following methods and types are provided by the SAM submodule for public use.
XAM.SAM.FLAG_DUP
— Constant.0x0400: optical or PCR duplicate
XAM.SAM.FLAG_MREVERSE
— Constant.0x0020: the mate is mapped to the reverse strand
XAM.SAM.FLAG_MUNMAP
— Constant.0x0008: the mate is unmapped
XAM.SAM.FLAG_PAIRED
— Constant.0x0001: the read is paired in sequencing, no matter whether it is mapped in a pair
XAM.SAM.FLAG_PROPER_PAIR
— Constant.0x0002: the read is mapped in a proper pair
XAM.SAM.FLAG_QCFAIL
— Constant.0x0200: QC failure
XAM.SAM.FLAG_READ1
— Constant.0x0040: this is read1
XAM.SAM.FLAG_READ2
— Constant.0x0080: this is read2
XAM.SAM.FLAG_REVERSE
— Constant.0x0010: the read is mapped to the reverse strand
XAM.SAM.FLAG_SECONDARY
— Constant.0x0100: not primary alignment
XAM.SAM.FLAG_SUPPLEMENTARY
— Constant.0x0800: supplementary alignment
XAM.SAM.FLAG_UNMAP
— Constant.0x0004: the read itself is unmapped; conflictive with SAM.FLAGPROPERPAIR
XAM.SAM.Header
— Method.SAM.Header()
Create an empty header.
XAM.SAM.MetaInfo
— Method.MetaInfo(tag::AbstractString, value)
Create a SAM metainfo with tag
and value
.
tag
is a two-byte ASCII string. If tag
is "CO"
, value
must be a string; otherwise, value
is an iterable object with key and value pairs.
Examples
julia> SAM.MetaInfo("CO", "some comment")
BioAlignments.SAM.MetaInfo:
tag: CO
value: some comment
julia> string(ans)
"@CO some comment"
julia> SAM.MetaInfo("SQ", ["SN" => "chr1", "LN" => 12345])
BioAlignments.SAM.MetaInfo:
tag: SQ
value: SN=chr1 LN=12345
julia> string(ans)
"@SQ SN:chr1 LN:12345"
XAM.SAM.MetaInfo
— Method.MetaInfo(str::AbstractString)
Create a SAM metainfo from str
.
Examples
julia> SAM.MetaInfo("@CO some comment")
BioAlignments.SAM.MetaInfo:
tag: CO
value: some comment
julia> SAM.MetaInfo("@SQ SN:chr1 LN:12345")
BioAlignments.SAM.MetaInfo:
tag: SQ
value: SN=chr1 LN=12345
XAM.SAM.Reader
— Method.SAM.Reader(input::IO)
Create a data reader of the SAM file format.
Arguments
input
: data source
XAM.SAM.Record
— Method.SAM.Record(str::AbstractString)
Create a SAM record from str
. This function verifies the format and indexes fields for accessors.
XAM.SAM.Record
— Method.SAM.Record(data::Vector{UInt8})
Create a SAM record from data
. This function verifies the format and indexes fields for accessors. Note that the ownership of data
is transferred to a new record object.
XAM.SAM.Record
— Method.SAM.Record()
Create an unfilled SAM record.
XAM.SAM.Writer
— Type.Writer(output::IO, header::Header=Header())
Create a data writer of the SAM file format.
Arguments
output
: data sinkheader=Header()
: SAM header object
Base.findall
— Method.find(header::Header, key::AbstractString)::Vector{MetaInfo}
Find metainfo objects satisfying SAM.tag(metainfo) == key
.
BioGenerics.header
— Method.header(reader::Reader)::Header
Get the header of reader
.
XAM.SAM.alignlength
— Method.alignlength(record::Record)::Int
Get the alignment length of record
.
XAM.SAM.alignment
— Method.alignment(record::Record)::BioAlignments.Alignment
Get the alignment of record
.
XAM.SAM.auxdata
— Method.auxdata(record::Record)::Dict{String,Any}
Get the auxiliary data (optional fields) of record
.
XAM.SAM.cigar
— Method.cigar(record::Record)::String
Get the CIGAR string of record
.
XAM.SAM.flag
— Method.flag(record::Record)::UInt16
Get the bitwise flag of record
.
XAM.SAM.iscomment
— Method.iscomment(metainfo::MetaInfo)::Bool
Test if metainfo
is a comment (i.e. its tag is "CO").
XAM.SAM.ismapped
— Method.ismapped(record::Record)::Bool
Test if record
is mapped.
XAM.SAM.isnextmapped
— Method.isnextmapped(record::Record)::Bool
Test if the mate/next read of record
is mapped.
XAM.SAM.isprimary
— Method.isprimary(record::Record)::Bool
Test if record
is a primary line of the read.
This is equivalent to flag(record) & 0x900 == 0
.
XAM.SAM.keyvalues
— Method.keyvalues(metainfo::MetaInfo)::Vector{Pair{String,String}}
Get the values of metainfo
as string pairs.
XAM.SAM.mappingquality
— Method.mappingquality(record::Record)::UInt8
Get the mapping quality of record
.
XAM.SAM.nextposition
— Method.nextposition(record::Record)::Int
Get the position of the mate/next read of record
.
XAM.SAM.nextrefname
— Method.nextrefname(record::Record)::String
Get the reference name of the mate/next read of record
.
XAM.SAM.position
— Method.position(record::Record)::Int
Get the 1-based leftmost mapping position of record
.
XAM.SAM.quality
— Method.quality(::Type{String}, record::Record)::String
Get the ASCII-encoded base quality of record
.
XAM.SAM.quality
— Method.quality(record::Record)::Vector{UInt8}
Get the Phred-scaled base quality of record
.
XAM.SAM.refname
— Method.refname(record::Record)::String
Get the reference sequence name of record
.
XAM.SAM.rightposition
— Method.rightposition(record::Record)::Int
Get the 1-based rightmost mapping position of record
.
XAM.SAM.seqlength
— Method.seqlength(record::Record)::Int
Get the sequence length of record
.
XAM.SAM.sequence
— Method.sequence(::Type{String}, record::Record)::String
Get the segment sequence of record
as String
.
XAM.SAM.sequence
— Method.sequence(record::Record)::BioSequences.DNASequence
Get the segment sequence of record
.
XAM.SAM.tag
— Method.tag(metainfo::MetaInfo)::String
Get the tag of metainfo
.
XAM.SAM.templength
— Method.templength(record::Record)::Int
Get the template length of record
.
XAM.SAM.tempname
— Method.tempname(record::Record)::String
Get the query template name of record
.
XAM.SAM.value
— Method.value(metainfo::MetaInfo)::String
Get the value of metainfo
as a string.
BAM API
The following methods and types are provided by the BAM submodule for public use.
XAM.BAM.BAI
— Method.BAI(filename::AbstractString)
Load a BAI index from filename
.
XAM.BAM.BAI
— Method.BAI(input::IO)
Load a BAI index from input
.
XAM.BAM.Reader
— Type.BAM.Reader(input::IO; index=nothing)
Create a data reader of the BAM file format.
Arguments
input
: data sourceindex=nothing
: filepath to a random access index (currently bai is supported)
XAM.BAM.Record
— Type.BAM.Record()
Create an unfilled BAM record.
XAM.BAM.Writer
— Type.BAM.Writer(output::BGZFStream, header::SAM.Header)
Create a data writer of the BAM file format.
Arguments
output
: data sinkheader
: SAM header object
BioGenerics.header
— Method.header(reader::Reader; fillSQ::Bool=false)::SAM.Header
Get the header of reader
.
If fillSQ
is true
, this function fills missing "SQ" metainfo in the header.
XAM.BAM.alignlength
— Method.alignlength(record::Record)::Int
Get the alignment length of record
.
XAM.BAM.alignment
— Method.alignment(record::Record)::BioAlignments.Alignment
Get the alignment of record
.
XAM.BAM.auxdata
— Method.auxdata(record::Record)::BAM.AuxData
Get the auxiliary data of record
.
XAM.BAM.cigar
— Function.cigar(record::Record)::String
Get the CIGAR string of record
.
Note that in the BAM specification, the field called cigar
typically stores the cigar string of the record. However, this is not always true, sometimes the true cigar is very long, and due to some constraints of the BAM format, the actual cigar string is stored in an extra tag: CG:B,I
, and the cigar
field stores a pseudo-cigar string.
Calling this method with checkCG
set to true
(default) this method will always yield the true cigar string, because this is probably what you want the vast majority of the time.
If you have a record that stores the true cigar in a CG:B,I
tag, but you still want to access the pseudo-cigar that is stored in the cigar
field of the BAM record, then you can set checkCG to false
.
See also BAM.cigar_rle
.
XAM.BAM.cigar_rle
— Function.cigar_rle(record::Record, checkCG::Bool = true)::Tuple{Vector{BioAlignments.Operation},Vector{Int}}
Get a run-length encoded tuple (ops, lens)
of the CIGAR string in record
.
Note that in the BAM specification, the field called cigar
typically stores the cigar string of the record. However, this is not always true, sometimes the true cigar is very long, and due to some constraints of the BAM format, the actual cigar string is stored in an extra tag: CG:B,I
, and the cigar
field stores a pseudo-cigar string.
Calling this method with checkCG
set to true
(default) this method will always yield the true cigar string, because this is probably what you want the vast majority of the time.
If you have a record that stores the true cigar in a CG:B,I
tag, but you still want to access the pseudo-cigar that is stored in the cigar
field of the BAM record, then you can set checkCG to false
.
See also BAM.cigar
.
XAM.BAM.flag
— Method.flag(record::Record)::UInt16
Get the bitwise flag of record
.
XAM.BAM.ismapped
— Method.ismapped(record::Record)::Bool
Test if record
is mapped.
XAM.BAM.isnextmapped
— Method.isnextmapped(record::Record)::Bool
Test if the mate/next read of record
is mapped.
XAM.BAM.ispositivestrand
— Method.ispositivestrand(record::Record)::Bool
Test if record
is aligned to the positive strand.
This is equivalent to flag(record) & 0x10 == 0
.
XAM.BAM.isprimary
— Method.isprimary(record::Record)::Bool
Test if record
is a primary line of the read.
This is equivalent to flag(record) & 0x900 == 0
.
XAM.BAM.mappingquality
— Method.mappingquality(record::Record)::UInt8
Get the mapping quality of record
.
XAM.BAM.n_cigar_op
— Function.n_cigar_op(record::Record, checkCG::Bool = true)
Return the number of operations in the CIGAR string of record
.
Note that in the BAM specification, the field called cigar
typically stores the cigar string of the record. However, this is not always true, sometimes the true cigar is very long, and due to some constraints of the BAM format, the actual cigar string is stored in an extra tag: CG:B,I
, and the cigar
field stores a pseudo-cigar string.
Calling this method with checkCG
set to true
(default) this method will always yield the number of operations in the true cigar string, because this is probably what you want, the vast majority of the time.
If you have a record that stores the true cigar in a CG:B,I
tag, but you still want to get the number of operations in the cigar
field of the BAM record, then set checkCG
to false
.
XAM.BAM.nextposition
— Method.nextposition(record::Record)::Int
Get the 1-based leftmost mapping position of the next/mate read of record
.
XAM.BAM.nextrefid
— Method.nextrefid(record::Record)::Int
Get the next/mate reference sequence ID of record
.
XAM.BAM.nextrefname
— Method.nextrefname(record::Record)::String
Get the reference name of the mate/next read of record
.
XAM.BAM.position
— Method.position(record::Record)::Int
Get the 1-based leftmost mapping position of record
.
XAM.BAM.quality
— Method.quality(record::Record)::Vector{UInt8}
Get the base quality of record
.
XAM.BAM.refid
— Method.refid(record::Record)::Int
Get the reference sequence ID of record
.
The ID is 1-based (i.e. the first sequence is 1) and is 0 for a record without a mapping position.
See also: BAM.rname
XAM.BAM.reflen
— Method.reflen(record::Record)::Int
Get the length of the reference sequence this record applies to.
XAM.BAM.refname
— Method.refname(record::Record)::String
Get the reference sequence name of record
.
See also: BAM.refid
XAM.BAM.rightposition
— Method.rightposition(record::Record)::Int
Get the 1-based rightmost mapping position of record
.
XAM.BAM.seqlength
— Method.seqlength(record::Record)::Int
Get the sequence length of record
.
XAM.BAM.sequence
— Method.sequence(record::Record)::BioSequences.DNASequence
Get the segment sequence of record
.
XAM.BAM.templength
— Method.templength(record::Record)::Int
Get the template length of record
.
XAM.BAM.tempname
— Method.tempname(record::Record)::String
Get the query template name of record
.