dhtslib.sam

SAMRecord and SAMFile are wrappers for htslib functions relating to SAM/BAM/CRAM* files

SAMRecord is a structured representation of a SAM/BAM/CRAM* record, backed internally by htslib's bam1_t, but with convenient getters and setters for record attributes, including functions not included in vanilla htslib like returning the sequence or the qscore string (NB: actually char*)

SAMFile is a structured representation of SAM/BAM/CRAM* file, backed internally by htslib's htsFile and bam_hdr_t, but with convenient getters and setters for file and header attributes, as well as query functions accessible explicitly (query("chr1:999-9999") and by indexing (samfile["chr1", 999 .. 9999]). The file object can be iterated as an InputRange to obtain every record in the file.

Modules

cigar
module dhtslib.sam.cigar

This module simplifies working with CIGAR strings/ops from SAM/BAM/CRAM alignment records.

header
module dhtslib.sam.header

This module provides a struct that encapsulates a SAMHeader

md
module dhtslib.sam.md

Module to deal with SAM records' MD auxillary tag.

reader
module dhtslib.sam.reader
Undocumented in source.
record
module dhtslib.sam.record
Undocumented in source.
tagvalue
module dhtslib.sam.tagvalue

Module provides a parser for SAM/BAM record auxillary tags.

writer
module dhtslib.sam.writer
Undocumented in source.

Public Imports

dhtslib.sam.header
public import dhtslib.sam.header;
dhtslib.sam.record
public import dhtslib.sam.record;
dhtslib.sam.cigar
public import dhtslib.sam.cigar;
dhtslib.sam.md
public import dhtslib.sam.md;
dhtslib.sam.tagvalue
public import dhtslib.sam.tagvalue;
dhtslib.sam.reader
public import dhtslib.sam.reader;
dhtslib.sam.writer
public import dhtslib.sam.writer;

Members

Functions

cmpInterval
bool cmpInterval(hts_pair32_t a, hts_pair32_t b)

Used in sorting

cmpRegList
bool cmpRegList(hts_reglist_t a, hts_reglist_t b)

Used in sorting

parseSam
int parseSam(string line, bam_hdr_t* header, bam1_t* b)

Parse text line of SAM; Used in unittest

Bugs

SAMRecord and SAMFile function only as readers, rather than writers (i.e, cannot build SAMFile) (*CRAM functionality is limited and untested)

Meta

Authors

James S Blachly, MD <james.blachly@gmail.com> ; Thomas Gregory <charles.gregory@osumc.edu>

Date

Date: 2020-09-12

Standards

Sequence Alignment/Map Format Specification v1 14 Dec 2018 http://samtools.github.io/hts-specs/

License

Apache 2.0