package bio_io

  1. Overview
  2. Docs

Module Bio_io.Fasta_recordSource

A record type for FASTA files.

Overview

Example 1

If you have a fasta file something like this:

  >s1 apple pie
  ACTG
  actg

Then you would get a record something like this:

  Fasta_record.id record (* "s1" *) Fasta_record.desc record
    (* Some "apple pie" *) Fasta_record.seq record
  (* "ACTGactg" *)

Example 2

If you have a fasta file something like this:

  >s1
  ACTG
  actg

Then you would get a record something like this:

  Fasta_record.id record (* "s1" *) Fasta_record.desc record (* None *)
    Fasta_record.seq record
  (* "ACTGactg" *)

Example 3

To change a part of the Fasta_record use the with_* functions. E.g.,

 Fasta_record.with_id "apple" record 

would change give you a t with the id set to "apple".

API

Sourcetype t
include Ppx_sexp_conv_lib.Sexpable.S with type t := t
Sourceval t_of_sexp : Sexplib0__.Sexp.t -> t
Sourceval sexp_of_t : t -> Sexplib0__.Sexp.t
Sourceexception Exn of Base.string
Sourceval create : id:Base.string -> desc:Base.string Base.option -> seq:Base.string -> t

create ~id ~desc ~seq creates a new t. Shouldn't raise as literally any values of the correct type are accepted.

Sourceval of_header_exn : Base.string -> t

of_header_exn header returns a t from a FASTA header. May raise exceptions. Used internally for parsing FASTA files, but the code consuming the bio_io module probably won't need to use this function.

of_header header is like of_header_exn header except that it returns Or_error.t rather than raising exceptions.

Sourceval to_string : t -> Base.string

to_string t returns a string representation of t ready to print to a FASTA output file.

Sourceval to_string_nl : ?nl:Base.string -> t -> Base.string

to_string_nl t ~nl returns a string representation of t ready to print to a FASTA output file, including a trailing newline (nl) string. nl defaults to "\n".

Sourceval serialize : t -> Base.string

serialize t returns the Sexp of t as a string.

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

equal this other returns true if all fields of two ts are the same.

Sourceval (=) : t -> t -> Base.bool

Fasta_record.(this = other) is like equal this other.

Sourceval id : t -> Base.string

id t returns the id of the t.

desc t returns the desc (description) of the t.

Sourceval seq : t -> Base.string

seq t returns the seq of the t.

Sourceval seq_length : t -> Base.int

seq_length t returns the length of the seq of t.

If you construct a record by hand (e.g., with create), and there are spaces or other weird characters in the sequences, they will be counted in the length. E.g.,

  let r = Fasta_record.create ~id:"apple" ~desc:None ~seq:"a a" in
  assert (Int.(3 = Fasta_record.seq_length r))
Sourceval with_id : Base.string -> t -> t

with_id new_id t returns a t with new_id instead of the original id.

Sourceval with_seq : Base.string -> t -> t

with_seq new_seq t returns a t with new_seq instead of the original seq.

Sourceval with_desc : Base.string Base.option -> t -> t

with_desc new_desc t returns a t with new_desc instead of the original desc.

OCaml

Innovation. Community. Security.