Previous Up Next

Module Biocaml_bam_alt (.ml)

Read and write BAM format.

The implementation does its best to comply with the official specification.

module Biocaml_bam_alt: 
sig

A BAM file is composed of a header and a list of alignment records. The datatypes used in this module are based on those defined in the Biocaml.SAM module.

BAM header files contain a plain text SAM header, plus additional information related to the encoding of the file.

module Header: 
sig
type t 
val of_sam  : Biocaml_sam.header -> t 
val to_sam  : t -> Biocaml_sam.header 
end
type alignment = Biocaml_sam.alignment  

Representation of partially parsed alignments. When traversing a BAM file for a specific calculation, it may be that only some fields of the alignment records are actually used. In that case, it can be significantly faster to use this representation. As a downside, some encoding errors in the BAM file can go unnoticed.

module Alignment0: 
sig
type t 
val qname  : t -> string option
val flags  : t -> Biocaml_sam.Flags.t Core.Std.Or_error.t
val rname  : t ->
Biocaml_bam_alt.Header.t -> string option Core.Std.Or_error.t
val pos  : t -> int option
val mapq  : t -> int option
val cigar  : t -> Biocaml_sam.cigar_op list Core.Std.Or_error.t
val rnext  : t ->
Biocaml_bam_alt.Header.t -> Biocaml_sam.rnext option Core.Std.Or_error.t
val pnext  : t -> int option
val tlen  : t -> int option
val seq  : t -> string option
val qual  : t ->
Biocaml_phred_score.t list Core.Std.Or_error.t
val optional_fields  : t ->
Biocaml_sam.optional_field list Core.Std.Or_error.t
val decode  : t ->
Biocaml_bam_alt.Header.t -> Biocaml_bam_alt.alignment Core.Std.Or_error.t
val encode  : Biocaml_bam_alt.alignment ->
Biocaml_bam_alt.Header.t -> t Core.Std.Or_error.t
val t_of_sexp  : Sexplib.Sexp.t -> t 
val sexp_of_t  : t -> Sexplib.Sexp.t
end
val read0  : Pervasives.in_channel ->
(Header.t *
Alignment0.t Core.Std.Or_error.t Stream.t)
Core.Std.Or_error.t
read0 ic returns an error if a valid header cannot be read from ic or a pair containing a header and a stream of possibly errored (partially parsed) alignments. The stream stops after the first error.
val with_file0  : string ->
f:(Header.t ->
Alignment0.t Core.Std.Or_error.t Stream.t ->
'a Core.Std.Or_error.t) ->
'a Core.Std.Or_error.t
with_file fn ~f opens a BAM file for reading, applies f and closes the file after that, even if f raises an exception. Beware: the result of f should not lazily depend on the stream it receives as a second argument, since after the call to with_file the underlying channel is closed.
val write0  : Header.t ->
Alignment0.t Stream.t -> Pervasives.out_channel -> unit
write0 h xs oc writes the header h and (partially parsed) alignments xs to oc.
val read  : Pervasives.in_channel ->
(Header.t *
alignment Core.Std.Or_error.t Stream.t)
Core.Std.Or_error.t
read ic returns an error if a valid header cannot be read from ic or a pair containing a header and a stream of possibly errored alignments. The stream stops after the first error.
val with_file  : string ->
f:(Header.t ->
alignment Core.Std.Or_error.t Stream.t ->
'a Core.Std.Or_error.t) ->
'a Core.Std.Or_error.t
with_file fn ~f opens a BAM file for reading, applies f and closes the file after that, even if f raises an exception. Beware: the result of f should not lazily depend on the stream it receives as a second argument, since after the call to with_file the underlying channel is closed.
val write  : Header.t ->
alignment Stream.t ->
Pervasives.out_channel -> unit Core.Std.Or_error.t
write h xs oc writes the header h and the alignments xs to oc.
end

AltStyle によって変換されたページ (->オリジナル) /