package bio_io

  1. Overview
  2. Docs
A library for reading and writing common file formats used in bioinformatics like FASTA files

Install

Dune Dependency

Authors

Maintainers

Sources

0.5.1.tar.gz
md5=6cc64d38a9cba13754cae52db1ade85d
sha512=5008a30225ec306378e282dab2c00d545949be0e778e4b352c5e29012e08f88acef4ed75cf03a55276b657a057355399be3a55ea77d58231a03efc66a03a8b13

doc/bio_io/Bio_io/Btab/In_channel/index.html

Module Btab.In_channelSource

In_channel for Btab records.

For more general info, see the Bio_io.Record_in_channel module mli file.

For some examples, see Bio_io.Fasta.In_channel. Those are for the FASTA files, but the API is the same..

include Record_in_channel.S with type record := Record.t

API

Sourcetype t
Sourceval stdin : t

create_exn file_name opens an t on the standard input channel.

Sourceval create_exn : Base.string -> t

create_exn file_name opens an input channel on the file specified by file_name.

create file_name opens an input channel on the file specified by file_name.

Sourceval close_exn : t -> Base.unit

close_exn t Close the t. Raises if the call fails.

close t is like close_exnt t except that it shouldn't raise.

Sourceval with_file_exn : Base.string -> f:(t -> 'a) -> 'a

with_file_exn file_name ~f executes ~f on the channel created from file_name and closes it afterwards.

Sourceval with_file : Base.string -> f:(t -> 'a) -> 'a Base.Or_error.t

with_file file_name ~f is like with_file_exn file_name ~f except that it shouldn't raise.

Sourceval equal : t -> t -> Base.bool

equal t1 t2 compares t1 and t2 for equality.

Sourceval input_record_exn : t -> Record.t Base.option

input_record_exn t returns Some record if there is a record to return. If there are no more records, None is returned. Exn is raised on bad input.

input_record t is like input_record_exn t except that it should not raise exceptions.

Folding over records

Sourceval fold_records_exn : t -> init:'a -> f:('a -> Record.t -> 'a) -> 'a

fold_records_exn t ~init ~f reduces all records from a t down to a single value of type 'a.

Sourceval fold_records : t -> init:'a -> f:('a -> Record.t -> 'a) -> 'a Base.Or_error.t

fold_records t ~init ~f is like fold_records_exn t ~init ~f except that it should not raise exceptions. Rather than deal with exceptions inside the reducing function, you must deal with them at the end when handling the return value.

Sourceval foldi_records_exn : t -> init:'a -> f:(Base.int -> 'a -> Record.t -> 'a) -> 'a

Like fold_records_exn t ~init ~f except that f is provided the 0-based record index as its first argument. See fold_records_exn.

Sourceval foldi_records : t -> init:'a -> f:(Base.int -> 'a -> Record.t -> 'a) -> 'a Base.Or_error.t

Like foldi_records_exn t ~init ~f except that it shouldn't raise. See foldi_records_exn.

Folding with file name

Sourceval with_file_fold_records_exn : Base.string -> init:'a -> f:('a -> Record.t -> 'a) -> 'a

with_file_fold_records_exn file_name ~init ~f is like fold_records_exn t ~init ~f except that it is passed a file name, and it manages t automatically. See with_file.

Sourceval with_file_fold_records : Base.string -> init:'a -> f:('a -> Record.t -> 'a) -> 'a Base.Or_error.t

with_file_fold_records file_name ~init ~f is like fold_records t ~init ~f except that it is passed a file name, and it manages t automatically. See with_file.

Sourceval with_file_foldi_records_exn : Base.string -> init:'a -> f:(Base.int -> 'a -> Record.t -> 'a) -> 'a

with_file_foldi_records_exn file_name ~init ~f is like foldi_records_exn t ~init ~f except that it is passed a file name, and it manages t automatically. See with_file.

Sourceval with_file_foldi_records : Base.string -> init:'a -> f:(Base.int -> 'a -> Record.t -> 'a) -> 'a Base.Or_error.t

with_file_foldi_records file_name ~init ~f is like fold'_records t ~init ~f except that it is passed a file name, and it manages t automatically. See with_file.

Iterating over records

The iter functions are like the fold functions except they do not take an init value and the f function returns unit insead of some other value 'a, and thus return unit rather than a value 'a.

They are mainly called for side effects.

Sourceval iter_records_exn : t -> f:(Record.t -> Base.unit) -> Base.unit

iter_records_exn t ~f calls f on each record in t. As f returns unit this is generally used for side effects.

Sourceval iter_records : t -> f:(Record.t -> Base.unit) -> Base.unit Base.Or_error.t

iter_records t ~f is like iter_records_exn t ~f except that it shouldn't raise.

Sourceval iteri_records_exn : t -> f:(Base.int -> Record.t -> Base.unit) -> Base.unit

iteri_records_exn t ~f is like iteri_records_exn t ~f except that f is passed in the 0-indexed record index as its first argument.

Sourceval iteri_records : t -> f:(Base.int -> Record.t -> Base.unit) -> Base.unit Base.Or_error.t

iteri_records t ~f is like iteri_records_exn t ~f except that it shouldn't raise.

Iterating with file name

Sourceval with_file_iter_records_exn : Base.string -> f:(Record.t -> Base.unit) -> Base.unit

with_file_iter_records_exn file_name ~init ~f is like iter_records_exn t ~init ~f except that it is passed a file name, and it manages t automatically. See with_file.

Sourceval with_file_iter_records : Base.string -> f:(Record.t -> Base.unit) -> Base.unit Base.Or_error.t

with_file_iter_records file_name ~init ~f is like iter_records t ~init ~f except that it is passed a file name, and it manages t automatically. See with_file.

Sourceval with_file_iteri_records_exn : Base.string -> f:(Base.int -> Record.t -> Base.unit) -> Base.unit

with_file_iteri_records_exn file_name ~init ~f is like iteri_records_exn t ~init ~f except that it is passed a file name, and it manages t automatically. See with_file.

Sourceval with_file_iteri_records : Base.string -> f:(Base.int -> Record.t -> Base.unit) -> Base.unit Base.Or_error.t

with_file_iteri_records file_name ~init ~f is like iteri_records t ~init ~f except that it is passed a file name, and it manages t automatically. See with_file.

Getting records as a list

These functions return lists of recordss.

Sourceval records_exn : t -> Record.t Base.List.t

With file name

Sourceval with_file_records_exn : Base.string -> Record.t Base.List.t

Getting records as a sequence

These are a bit different:

* There are no with_file versions as you would have to do some fiddly things to keep the channel open, making them not so nice to use.

* Each record that is yielded is wrapped in an Or_error.t. This is different from the iter, fold, and other non _exn functions in which case the entire result is wrapped in an Or_error.t, letting you ignore errors in the passed in ~f function and deal with failure once.

Sourceval record_sequence_exn : t -> Record.t Base.Sequence.t

record_sequence_exn t returns a Sequence.t of record. May raise exceptions.

record_sequence t is like record_sequence_exn t except that instead of raising exceptions, each item of the sequence is a record Or_error.t rather than an "unwrapped" record. This could make things annoying to deal with. If you don't want exceptions, you could instead wrap your entire sequence processing pipeline in a call to with_file and handle the Or_error.t in that way. See the pipelines usage examples for more info.

OCaml

Innovation. Community. Security.