package biocaml
Install
Dune Dependency
Authors
Maintainers
Sources
md5=486aeb3e552dabae85839e2af30d6c52
sha512=4ed2df0b7cbd80bd6e29bd8fee9d2dacd9379ad0f4ff142bd8e16ade3f1507f6cc7cbe4c614943b8feb8fa4705935695cb458606b0da813dbf255b1e566a43cf
doc/biocaml.unix/Biocaml_unix/Bam/index.html
Module Biocaml_unix.Bam
Source
Read and write BAM format.
The implementation does its best to comply with the official specification.
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 Sam
module.
BAM header files contain a plain text SAM header, plus additional information related to the encoding of the file.
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.
val read0 :
Core_kernel.In_channel.t ->
(Header.t * Alignment0.t Core_kernel.Or_error.t Stream.t)
Core_kernel.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_kernel.Or_error.t Stream.t ->
'a Core_kernel.Or_error.t) ->
'a Core_kernel.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.
write0 h xs oc
writes the header h
and (partially parsed) alignments xs
to oc
.
val read :
Core_kernel.In_channel.t ->
(Header.t * alignment Core_kernel.Or_error.t Stream.t) Core_kernel.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_kernel.Or_error.t Stream.t ->
'a Core_kernel.Or_error.t) ->
'a Core_kernel.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 ->
Core_kernel.Out_channel.t ->
unit Core_kernel.Or_error.t
write h xs oc
writes the header h
and the alignments xs
to oc
.