package bio_io

  1. Overview
  2. Docs

Module Fastq.RecordSource

A record type for FASTQ files.

Overview

Very similar to the Fasta.Record.t. See that module for more details.contents

Fields

For the "header" line, the id is everything up to the first space, and the desc is everything after. Note, that desc is optional. E.g.,

  @this_is_the_id this is the desc
   ^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^
   id ----------| Some desc -----|

The other possibly weird field is extra. It is simply everything on the line following the + (i.e., the third line of the 4 line FASTQ file).

It is currently NOT a parse error if the sequence length and quality string length are different lengths. This may change in the future.

API

Sourcetype t
include Sexplib0.Sexpable.S with type t := t
Sourceval t_of_sexp : Sexplib0.Sexp.t -> t
Sourceval sexp_of_t : t -> Sexplib0.Sexp.t
Sourceval create : id:Base.string -> desc:Base.string Base.option -> seq:Base.string -> qual:Base.string -> extra:Base.string Base.option -> t

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

Sourceval to_string : t -> Base.string

to_string t returns a string representation of t ready to print to a FASTQ 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 FASTQ output file, including a trailing newline (nl) string. nl defaults to "\n".

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

Fastq.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 qual : t -> Base.string

qual t returns the qual of t.

extra t returns the extra of the t if there is one. It is whatever is after the + line. Technically it should be the same ID+desc found in the header line, but this library just treats it as a blob of data.

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 =
    Fastq.Record.create ~id:"apple" ~desc:None ~seq:"a a" ~qual:". ."
      ~extra:None
  in
  assert (Int.(3 = Fastq.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.

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

with_qual new_qual t returns a t with new_qual instead of the original qual.

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

with_extra new_extra t returns a t with new_extra instead of the original extra.

Sourceval rev : t -> t

rev t returns the reverse of t. I.e., the seq and the qual are reversed.

Sourceval comp : t -> t

comp t returns the complement of t. I.e., the seq is complemented. Uses IUPAC conventions. Any "base" (char) that isn't part of the IUPAC passes through unchanged. Note that comp does not round-trip.

Sourceval rev_comp : t -> t

rev_comp t returns the reverse complement of t. I.e., the seq is reverse complemented, and the quality score is reversed to match it. Uses IUPAC conventions. Any "base" (char) that isn't part of the IUPAC passes through unchanged. Note that rev_comp does not round-trip.