View Source Bio.Sequence.Rna (bio_ex_sequence v0.1.1)

A module for working with RNA.

This module doesn't contain a representative struct, as with Bio.Sequence.Dna. This is because there are multiple ways to interpret a string as RNA. Namely, it can either be single or double stranded. This is why the Bio.Sequence.RnaStrand and Bio.Sequence.RnaDoubleStrand modules exist.

However, this is the interface for dealing with things like complement/1 and reverse_complement/1.

Additionally, this module handles defining default conversions for the DNA sequence types into RNA sequence types (Bio.Sequence.DnaStrand and Bio.Sequence.DnaDoubleStrand). Conversions defined here are used by the Bio.Sequence.RnaStrand and Bio.Sequence.RnaDoubleStrand modules. The default conversions use conventional nucleotides and map them to their relevant DNA nucleotides:

a -> a
u -> t
g -> g
c -> c

Casing is preserved, so mixed case sequences will not be altered.

Example

iex>RnaStrand.new("uaUUg")
...>|> Bio.Polymer.convert(DnaStrand)
{:ok, %DnaStrand{sequence: "taTTg", length: 5}}

This is guaranteed, so you may encode these with intention and assume that they are preserved across conversions.

Summary

Functions

Provide the RNA complement to a sequence.

Provide the RNA reverse complement to a sequence.

Types

@type complementable() :: struct() | String.t()

Functions

Link to this function

complement(sequence, opts \\ [])

View Source
@spec complement(complementable(), keyword() | nil) ::
  {:ok, struct()} | {:error, Bio.AcidHelper.mismatch()}

Provide the RNA complement to a sequence.

Given a sequence that is either a binary or a Bio.Sequence.RnaStrand, returns the RNA complement as defined by the standard nucleotide complements.

Examples

iex>Rna.complement("auugacgu")
{:ok, "uaacugca"}

iex>RnaStrand.new("auugacgu")
...>|> Rna.complement()
{:ok, %RnaStrand{sequence: "uaacugca", length: 8, alphabet: Alpha.common()}}
Link to this function

reverse_complement(sequence)

View Source
@spec reverse_complement(sequence :: complementable()) :: complementable()

Provide the RNA reverse complement to a sequence.

Given a sequence that is either a binary or a Bio.Sequence.RnaStrand, returns the RNA reverse complement as defined by the standard nucleotide complements.

Examples

iex>Rna.reverse_complement("auugacgu")
"acgucaau"

iex>RnaStrand.new("auugacgu")
...>|> Rna.reverse_complement()
%RnaStrand{sequence: "acgucaau", length: 8}