/#define bam_index_build(fn, min_shift) (sam_index_build((fn), (min_shift)))
/#define bam_itr_destroy(iter) hts_itr_destroy(iter)
/#define bam_itr_queryi(idx, tid, beg, end) sam_itr_queryi(idx, tid, beg, end)
/#define bam_itr_querys(idx, hdr, region) sam_itr_querys(idx, hdr, region)
typedef struct __bam_mplp_t *bam_mplp_t;
typedef int (*bam_plp_auto_f)(void *data, bam1_t *b);
typedef struct __bam_plp_t *bam_plp_t;
/#define sam_itr_destroy(iter) hts_itr_destroy(iter)
/#define sam_itr_multi_next(htsfp, itr, r) hts_itr_multi_next((htsfp), (itr), (r))
** SAM I/O ***
** CIGAR related macros ***
@param s Pointer to the tag data, as returned by bam_aux_get(). @return The value, or 0 if the tag was not a character ('A') type If the tag is not a character type, errno is set to EINVAL.
@param s Pointer to the tag data, as returned by bam_aux_get(). @return Pointer to the string, or NULL if the tag was not a string type If the tag is not a string type ('Z' or 'H'), errno is set to EINVAL.
@param s Pointer to the tag data, as returned by bam_aux_get() @return The value, or 0 if the tag was not an integer type If the tag is not an numeric type, errno is set to EINVAL. The value of integer flags will be returned cast to a double.
@param s Pointer to the tag data, as returned by bam_aux_get() @return The value, or 0 if the tag was not an integer type If the tag is not an integer type, errno is set to EINVAL. This function will not return the value of floating-point tags.
@param s Pointer to the tag data, as returned by bam_aux_get(). @param idx 0-based Index into the array @return The idx'th value, or 0.0 on error. If the array is not a numeric type, errno is set to EINVAL. This can only actually happen if the input record has an invalid type field. If idx is greater than or equal to the value returned by bam_auxB_len(s), errno is set to ERANGE. In both cases, 0.0 will be returned.
@param s Pointer to the tag data, as returned by bam_aux_get(). @param idx 0-based Index into the array @return The idx'th value, or 0 on error. If the array is not an integer type, errno is set to EINVAL. If idx is greater than or equal to the value returned by bam_auxB_len(s), errno is set to ERANGE. In both cases, 0 will be returned.
@param s Pointer to the tag data, as returned by bam_aux_get(). @return The length of the array, or 0 if the tag is not an array type. If the tag is not an array type, errno is set to EINVAL.
Append tag data to a bam record
Delete tag data from a bam record
@param b Pointer to the bam record @param tag Desired aux tag @return Pointer to the tag data, or NULL if tag is not present or on error If the tag is not present, this function returns NULL and sets errno to ENOENT. If the bam record's aux data is corrupt (either a tag has an invalid type, or the last record is incomplete) then errno is set to EINVAL and NULL is returned.
Update or add an array tag
Update or add a floating-point tag
Update or add an integer tag
Update or add a string-type tag
How much query is consumed by CIGAR op(s)?
How much reference is consumed by CIGAR op(s)?
Generate CIGAR uint from length and operator
CIGAR opcode for CIGAR uint (4 LSB)
CIGAR opcode character for CIGAR uint
CIGAR operation length for CIGAR uint (28 MSB >> 4)
bam_cigar_type returns a bit flag with: bit 1 set if the cigar operation consumes the query bit 2 set if the cigar operation consumes the reference
copy a BAM record from dst to src
destroy a BAM record
duplicate a BAM record
! @abstract Calculate the rightmost base position of an alignment on the reference genome.
The string must be freed by the user
! @function @abstract Get auxiliary data @param b pointer to an alignment @return pointer to the concatenated auxiliary data /#define bam_get_aux(b) ((b)->data + ((b)->core.n_cigar<<2) + (b)->core.l_qname + (((b)->core.l_qseq + 1)>>1) + (b)->core.l_qseq)
! @function @abstract Get the CIGAR array @param b pointer to an alignment @return pointer to the CIGAR array
! @function @abstract Get length of auxiliary data @param b pointer to an alignment @return length of the concatenated auxiliary data /#define bam_get_l_aux(b) ((b)->l_data - ((b)->core.n_cigar<<2) - (b)->core.l_qname - (b)->core.l_qseq - (((b)->core.l_qseq + 1)>>1))
! @function @abstract Get the name of the query @param b pointer to an alignment @return pointer to the name string, null terminated
! @function @abstract Get query quality @param b pointer to an alignment @return pointer to quality string /#define bam_get_qual(b) ((b)->data + ((b)->core.n_cigar<<2) + (b)->core.l_qname + (((b)->core.l_qseq + 1)>>1))
! @function @abstract Get query sequence @param b pointer to an alignment @return pointer to sequence
destroy a BAM header
duplicate a BAM header
** BAM I/O *** init a BAM header
read BAM header from fp
write BAM header to fp
/#define bam_index_load(fn) hts_idx_load((fn), HTS_FMT_BAI)
init a BAM record
! @function @abstract Get whether the query's mate is on the reverse strand @param b pointer to an alignment @return boolean true if query's mate on the reverse strand
! @function @abstract Get whether the query is on the reverse strand @param b pointer to an alignment @return boolean true if query is on the reverse strand
/#define bam_itr_next(htsfp, itr, r) hts_itr_next((htsfp)->fp.bgzf, (itr), (r), 0)
???
see bam_plp_constructor
destroy mpileup iterator
see bam_plp_destructor
initialize new mpileup iterator
bam_mplp_init_overlaps() - if called, mpileup will detect overlapping read pairs and for each base pair set the base quality of the lower-quality base to zero, thus effectively discarding it from calling. If the two bases are identical, the quality of the other base is increased to the sum of their qualities (capped at 200), otherwise it is multiplied by 0.8.
reset mpileup
set maximum mpileup records returned per subpileup (init default of each pileup in the mpileup is 8000)
Get contig tid
???
bam_plp_constructor() - sets a callback to initialise any per-pileup1_t fields. @plp: The bam_plp_t initialised using bam_plp_init. @func: The callback function itself. When called, it is given the data argument (specified in bam_plp_init), the bam structure and a pointer to a locally allocated bam_pileup_cd union. This union will also be present in each bam_pileup1_t created.
destroy pileup iterator
per-pileup1_t field destructor (may be needed if used bam_plp_constructor())
bam_plp_init() - sets an iterator over multiple @func: see mplp_func in bam_plcmd.c in samtools for an example. Expected return status: 0 on success, -1 on end, < -1 on non-recoverable errors @data: user data to pass to @func NB: maxcnt records default is 8000
Prepares next pileup position in bam records collected by bam_plp_auto -> user func -> bam_plp_push. Returns pointer to the piled records if next position is ready or NULL if there is not enough records in the buffer yet (the current position is still the maximum position across all buffered reads).
add bam record to pileup iterator
reset pileup
set maximum pileup records returned (init default is 8000)
read BAM record from fp
! @function @abstract Get a base on read @param s Query sequence returned by bam_get_seq() @param i The i-th position, 0-based @return 4-bit integer representing the base. /#define bam_seqi(s, i) ((s)[(i)>>1] >> ((~(i)&1)<<2) & 0xf)
returns negative value on error
write BAM record to fp
BAQ calculation and realignment *
emit text SAM line
edit SAM/BAM/CRAM header @HD line by key/value (see SAM specs section 1.3)
parse SAM/BAM/CRAM header from text
read SAM/BAM/CRAM header frpm fp
write SAM/BAM/CRAM header to fp
@param fn Input BAM/etc filename, to which .csi/etc will be added @param min_shift Positive to generate CSI, or 0 to generate BAI @return 0 if successful, or negative if an error occurred (usually -1; or -2: opening fn failed; -3: format not indexable; -4: failed to create and/or save the index)
@param fn Input BAM/CRAM/etc filename @param fnidx Output filename, or NULL to add .bai/.csi/etc to @a fn @param min_shift Positive to generate CSI, or 0 to generate BAI @return 0 if successful, or negative if an error occurred (see sam_index_build for error codes)
@param fp File handle of the data file whose index is being opened @param fn BAM/CRAM/etc filename to search alongside for the index file @return The index, or NULL if an error occurred.
@param fp File handle of the data file whose index is being opened @param fn BAM/CRAM/etc data file filename @param fnidx Index filename, or NULL to search alongside @a fn @return The index, or NULL if an error occurred.
/#define sam_itr_next(htsfp, itr, r) hts_itr_next((htsfp)->fp.bgzf, (itr), (r), (htsfp))
SAM/BAM/CRAM iterator query by integer tid/start/end
SAM/BAM/CRAM iterator query by string ("chr:start-end")
SAM/BAM/CRAM iterator query by region list
open SAM/BAM/CRAM
A version of sam_open_mode that can handle ,key=value options. The format string is allocated and returned, to be freed by the caller. Prefix should be "r" or "w",
parse text SAM line
@param b BAM record @param ref Reference sequence @param ref_len Reference sequence length @param flag Flags, see description @return 0 on success \n -1 if the read was unmapped, zero length, had no quality values, did not have at least one M, X or = CIGAR operator, or included a reference skip. \n -3 if BAQ alignment has already been done and does not need to be applied, or has already been applied. \n -4 if alignment failed (most likely due to running out of memory)
! @return >= 0 on successfully reading a new record, -1 on end of stream, < -1 on error
Return >= 0 on successfully writing a new record; <= -1 on error
opaque mpileup data defined in sam.c
opaque pileup data defined in sam.c
! @typedef @abstract Structure for core alignment information. @field tid chromosome ID, defined by bam_hdr_t @field pos 0-based leftmost coordinate @field bin bin calculated by bam_reg2bin() @field qual mapping quality @field l_qname length of the query name @field flag bitwise flag @field l_extranul length of extra NULs between qname & cigar (for alignment) @field n_cigar number of CIGAR operations @field l_qseq length of the query sequence (read) @field mtid chromosome ID of next read in template, defined by bam_hdr_t @field mpos 0-based leftmost coordinate of next read in template
! @typedef @abstract Structure for one alignment. @field core core information about the alignment @field l_data current length of bam1_t::data @field m_data maximum length of bam1_t::data @field data all variable-length data, concatenated; structure: qname-cigar-seq-qual-aux
! @typedef @abstract Structure for the alignment header. @field n_targets number of reference sequences @field l_text length of the plain text in the header @field target_len lengths of the reference sequences @field target_name names of the reference sequences @field text plain text @field sdict header dictionary
! @typedef @abstract Structure for one alignment covering the pileup position. @field b pointer to the alignment @field qpos position of the read base at the pileup site, 0-based @field indel indel length; 0 for no indel, positive for ins and negative for del @field level the level of the read in the "viewer" mode @field is_del 1 iff the base on the padded read is a deletion @field is_head ??? @field is_tail ??? @field is_refskip ??? @field aux ???
** Pileup and Mpileup ***
internal
internal
internal
internal magic const for bam_cigar_type()
! @abstract optical or PCR duplicate
! @abstract the mate is mapped to the reverse strand
! @abstract the mate is unmapped
! @abstract the read is paired in sequencing, no matter whether it is mapped in a pair
! @abstract the read is mapped in a proper pair
! @abstract QC failure
! @abstract this is read1
! @abstract this is read2
! @abstract the read is mapped to the reverse strand
! @abstract not primary alignment
! @abstract supplementary alignment
! @abstract the read itself is unmapped; conflictive with BAM_FPROPER_PAIR
Highest SAM format version supported by this library