API Reference
SAM API
Public
XAM.SAM.Header — MethodSAM.Header()Create an empty header.
XAM.SAM.MetaInfo — MethodMetaInfo(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 — MethodMetaInfo(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=12345XAM.SAM.Reader — MethodSAM.Reader(input::IO)Create a data reader of the SAM file format.
Arguments
input: data source
XAM.SAM.Record — MethodSAM.Record(str::AbstractString)Create a SAM record from str. This function verifies the format and indexes fields for accessors.
XAM.SAM.Record — MethodSAM.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 — MethodSAM.Record()Create an unfilled SAM record.
XAM.SAM.Writer — TypeWriter(output::IO, header::Header=Header())Create a data writer of the SAM file format.
Arguments
output: data sinkheader=Header(): SAM header object
Base.findall — Methodfindall(header::Header, key::AbstractString)::Vector{MetaInfo}Find metainfo objects satisfying SAM.tag(metainfo) == key.
Base.read! — Methodread!(rdr::Reader, rec::Record)Read a Record into rec; overwriting or adding to existing field values. It is assumed that rec is already initialized or empty.
BioGenerics.header — Methodheader(reader::Reader)::HeaderGet the header of reader.
XAM.SAM.alignlength — Methodalignlength(record::Record)::IntGet the alignment length of record.
XAM.SAM.alignment — Methodalignment(record::Record)::BioAlignments.AlignmentGet the alignment of record.
XAM.SAM.auxdata — Methodauxdata(record::Record)::Dict{String,Any}Get the auxiliary data (optional fields) of record.
XAM.SAM.cigar — Methodcigar(record::Record)::StringGet the CIGAR string of record.
XAM.SAM.iscomment — Methodiscomment(metainfo::MetaInfo)::BoolTest if metainfo is a comment (i.e. its tag is "CO").
XAM.SAM.keyvalues — Methodkeyvalues(metainfo::MetaInfo)::Vector{Pair{String,String}}Get the values of metainfo as string pairs.
XAM.SAM.mappingquality — Methodmappingquality(record::Record)::UInt8Get the mapping quality of record.
XAM.SAM.nextposition — Methodnextposition(record::Record)::IntGet the position of the mate/next read of record.
XAM.SAM.nextrefname — Methodnextrefname(record::Record)::StringGet the reference name of the mate/next read of record.
XAM.SAM.position — Methodposition(record::Record)::IntGet the 1-based leftmost mapping position of record.
XAM.SAM.quality — Methodquality(::Type{String}, record::Record)::StringGet the ASCII-encoded base quality of record.
XAM.SAM.quality — Methodquality(record::Record)::Vector{UInt8}Get the Phred-scaled base quality of record.
XAM.SAM.refname — Methodrefname(record::Record)::StringGet the reference sequence name of record.
XAM.SAM.rightposition — Methodrightposition(record::Record)::IntGet the 1-based rightmost mapping position of record.
XAM.SAM.seqlength — Methodseqlength(record::Record)::IntGet the sequence length of record.
XAM.SAM.sequence — Methodsequence(::Type{String}, record::Record)::StringGet the segment sequence of record as String.
XAM.SAM.sequence — Methodsequence(record::Record)::BioSequences.LongDNA{4}Get the segment sequence of record.
XAM.SAM.tag — Methodtag(metainfo::MetaInfo)::StringGet the tag of metainfo.
XAM.SAM.templength — Methodtemplength(record::Record)::IntGet the template length of record.
XAM.SAM.tempname — Methodtempname(record::Record)::StringGet the query template name of record.
XAM.SAM.value — Methodvalue(metainfo::MetaInfo)::StringGet the value of metainfo as a string.
Internal
BAM API
Public
XAM.BAM.BAI — MethodBAI(filename::AbstractString)Load a BAI index from filename.
XAM.BAM.BAI — MethodBAI(input::IO)Load a BAI index from input.
XAM.BAM.Reader — TypeBAM.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) or BAI object
XAM.BAM.Record — TypeBAM.Record()Create an unfilled BAM record.
XAM.BAM.Writer — TypeBAM.Writer(output::BGZFStream, header::SAM.Header)Create a data writer of the BAM file format.
Arguments
output: data sinkheader: SAM header object
BioGenerics.header — Methodheader(reader::Reader; fillSQ::Bool=false)::SAM.HeaderGet the header of reader.
If fillSQ is true, this function fills missing "SQ" metainfo in the header.
XAM.BAM.alignlength — Methodalignlength(record::Record)::IntGet the alignment length of record.
XAM.BAM.alignment — Methodalignment(record::Record)::BioAlignments.AlignmentGet the alignment of record.
XAM.BAM.auxdata — Methodauxdata(record::Record)::BAM.AuxDataGet the auxiliary data of record.
XAM.BAM.cigar — Functioncigar(record::Record)::StringGet 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 — Functioncigar_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.mappingquality — Methodmappingquality(record::Record)::UInt8Get the mapping quality of record.
XAM.BAM.n_cigar_op — Functionn_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 — Methodnextposition(record::Record)::IntGet the 1-based leftmost mapping position of the next/mate read of record.
XAM.BAM.nextrefid — Methodnextrefid(record::Record)::IntGet the next/mate reference sequence ID of record.
XAM.BAM.nextrefname — Methodnextrefname(record::Record)::StringGet the reference name of the mate/next read of record.
XAM.BAM.position — Methodposition(record::Record)::IntGet the 1-based leftmost mapping position of record.
XAM.BAM.quality — Methodquality(record::Record)Get the base quality of record.
XAM.BAM.refid — Methodrefid(record::Record)::IntGet 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 — Methodreflen(record::Record)::IntGet the length of the reference sequence this record applies to.
XAM.BAM.refname — Methodrefname(record::Record)::StringGet the reference sequence name of record.
See also: BAM.refid
XAM.BAM.rightposition — Methodrightposition(record::Record)::IntGet the 1-based rightmost mapping position of record.
XAM.BAM.seqlength — Methodseqlength(record::Record)::IntGet the sequence length of record.
XAM.BAM.sequence — Methodsequence(record::Record)::BioSequences.LongDNA{4}Get the segment sequence of record.
XAM.BAM.templength — Methodtemplength(record::Record)::IntGet the template length of record.
XAM.BAM.tempname — Methodtempname(record::Record)::StringGet the query template name of record.