Module nimna_alignment

Module nimna_alignment

Alignment

This module provides constructors and accessors for Alignment objects, which represent multiple sequence alignments. Alignments are read from file using the alignment procedure, where the file can be any of the usual multiple sequence alignment formats.

Example usage

Let's read an alignment, and fold it into a consensus secondary structure.

import nimna

let
  align = alignment"algn.fasta"
  comp = compound align
  # Just use minimum free energy folding
  # with an alignment compound for the
  # consensus secondary structure.
  (energy, structure) = comp.mfe

Procs

proc alignment(path: string): Alignment {.
raises: [], tags: []
.}

Reads a sequence alignment from a file. The following formats are supported:

ClustalW, Stockholm 1.0, FASTA (Pearson), MAF

proc alignment(sequences, names: openArray[string]): Alignment {.
raises: [AssertionError], tags: []
.}
Creates an Alignment from a set of prealigned sequences and sequence names.
proc sequence(al: Alignment; idx: int): string {.
raises: [AssertionError], tags: []
.}
Returns the sequence at the idx'th position in an Alignment.
proc name(al: Alignment; idx: int): string {.
raises: [AssertionError], tags: []
.}
Returns the name at the idx'th position in an Alignment.

Iterators

iterator sequences(al: Alignment): string {.
raises: [], tags: []
.}
Iterates over sequences in an Alignment.
iterator names(al: Alignment): string {.
raises: [], tags: []
.}
Iterates over names in an Alignment.
iterator items(al: Alignment): string {.
raises: [], tags: []
.}
Alias for sequences.
iterator pairs(al: Alignment): tuple[name, sequence: string] {.
raises: [], tags: []
.}
Iterates over pairs of sequences and sequence names in an Alignment.

Templates

template len(al: Alignment): int
Returns the number of sequences in an Alignment.