Module Biocaml_fastq (.ml)

FASTQ data.

module Biocaml_fastq: 
sig

The Item Type


type item = {
   name : string;
   sequence : string;
   comment : string;
   qualities : string;
}
Type of FASTQ items.

The Error Types


module Error: 
sig

All errors generated by any function in the Fastq module are defined here.

  • `sequence_and_qualities_do_not_match (position, sequence, qualities) - given sequence and qualities at given position are of different lengths.
  • `wrong_name_line x - name line x does not start with '@'
  • `wrong_comment_line _ - comment line does not start with '+'
  • `incomplete_input (position, lines, s) - the input ended prematurely. Trailing contents, which cannot be used to fully construct an item, are provided: lines is any complete lines parsed and s is any final string not ending in a newline.

type fasta_pair_to_fastq = [ `cannot_convert_to_phred_score of int list
| `sequence_names_mismatch of string * string ]
type parsing = [ `incomplete_input of Biocaml_pos.t * string list * string option
| `sequence_and_qualities_do_not_match of Biocaml_pos.t * string * string
| `wrong_comment_line of Biocaml_pos.t * string
| `wrong_name_line of Biocaml_pos.t * string ]
The parsing errors.
type t = [ `cannot_convert_to_phred_score of int list
| `incomplete_input of Biocaml_pos.t * string list * string option
| `sequence_and_qualities_do_not_match of Biocaml_pos.t * string * string
| `sequence_names_mismatch of string * string
| `wrong_comment_line of Biocaml_pos.t * string
| `wrong_name_line of Biocaml_pos.t * string ]
Union of all possible errors.
val t_of_sexp : Sexplib.Sexp.t -> t
val sexp_of_t : t -> Sexplib.Sexp.t
val t_to_string : t -> string
Transform error to a human-readable string.
end

In_channel Functions


exception Error of Error.t
The only exception raised by this module.
val in_channel_to_item_stream : ?buffer_size:int ->
?filename:string ->
Pervasives.in_channel ->
(item, [> Error.parsing ]) Core.Result.t Stream.t
Parse an input-channel into a stream of item results.
val in_channel_to_item_stream_exn : ?buffer_size:int ->
?filename:string -> Pervasives.in_channel -> item Stream.t
Returns a stream of items. Stream.next will raise Error _ in case of any error.

To_string Function

This function converts item values to strings that can be dumped to a file, i.e. they contain full-lines, including all end-of-line characters.

val item_to_string : item -> string
Convert a item to a string.

Transforms


module Transform: 
sig

Lower-level transforms.
val string_to_item : ?filename:string ->
unit ->
(string,
(Biocaml_fastq.item, [> Biocaml_fastq.Error.parsing ]) Core.Result.t)
Biocaml_transform.t
Create a Biocaml_transform.t from arbitrary strings to item values.
val item_to_string : unit -> (Biocaml_fastq.item, string) Biocaml_transform.t
Create a Biocaml_transform.t from item values to strings.
val trim : [ `beginning of int | `ending of int ] ->
(Biocaml_fastq.item,
(Biocaml_fastq.item, [> `invalid_size of int ]) Core.Result.t)
Biocaml_transform.t
Create a Biocaml_transform.t that trims FASTQ items.
val fasta_pair_to_fastq : ?phred_score_offset:[ `offset33 | `offset64 ] ->
unit ->
(Biocaml_fasta.char_seq Biocaml_fasta.item *
Biocaml_fasta.int_seq Biocaml_fasta.item,
(Biocaml_fastq.item, [> Biocaml_fastq.Error.fasta_pair_to_fastq ])
Core.Result.t)
Biocaml_transform.t
Create a transform that builds item records thanks to sequences from Fasta.(char_seq item) values and qualities converted from Fasta.(int_seq item) values. The default Phred score encoding is `offset33 (like in Biocaml_phred_score).
val fastq_to_fasta_pair : ?phred_score_offset:[ `offset33 | `offset64 ] ->
unit ->
(Biocaml_fastq.item,
(Biocaml_fasta.char_seq Biocaml_fasta.item *
Biocaml_fasta.int_seq Biocaml_fasta.item,
[> `cannot_convert_ascii_phred_score of string ])
Core.Result.t)
Biocaml_transform.t
Create a transform that split a FASTQ item into to FASTA items (i.e. the inverse of Biocaml_fastq.Transform.fasta_pair_to_fastq).
end

S-Expressions


val item_of_sexp : Sexplib.Sexp.t -> item
val sexp_of_item : item -> Sexplib.Sexp.t
end