View Source Bio.Sequence.Dna (bio_ex_sequence v0.1.1)
A module for working with DNA.
This module doesn't contain a representative struct, as with Bio.Sequence.Rna
.
This is because there are multiple ways to interpret a string as DNA. Namely, it
can either be single or double stranded. This is why the
Bio.Sequence.DnaStrand
and Bio.Sequence.DnaDoubleStrand
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.RnaStrand
and
Bio.Sequence.RnaDoubleStrand
). Conversions defined here are used by the
Bio.Sequence.DnaStrand
and Bio.Sequence.DnaDoubleStrand
modules.
The default conversions use conventional nucleotides and map them to their relevant RNA nucleotides:
a -> a
t -> u
g -> g
c -> c
Casing is preserved, so mixed case sequences will not be altered.
Example
iex>DnaStrand.new("taTTg")
...>|> Bio.Polymer.convert(RnaStrand)
{:ok, %RnaStrand{sequence: "uaUUg", length: 5}}
This is guaranteed, so you may encode these with intention and assume that they are preserved across conversions.
Summary
Functions
Provide the DNA complement to a sequence.
Provide the DNA reverse complement to a sequence.
Types
@type msg() :: atom()
Functions
Provide the DNA complement to a sequence.
Given a sequence that is either a binary or a Bio.Sequence.DnaStrand
,
returns the DNA complement as defined by the standard nucleotide complements.
Examples
iex>Dna.complement("attgacgt")
{:ok, "taactgca"}
iex>DnaStrand.new("attgacgt")
...>|> Dna.complement()
{:ok, %DnaStrand{sequence: "taactgca", length: 8, alphabet: Bio.Sequence.Alphabets.Dna.common()}}
Provide the DNA reverse complement to a sequence.
Given a sequence that is either a binary or a Bio.Sequence.DnaStrand
,
returns the DNA reverse complement as defined by the standard nucleotide
complements.
Examples
iex>Dna.reverse_complement!("attgacgt")
"acgtcaat"
iex>DnaStrand.new("attgacgt")
...>|> Dna.reverse_complement!()
%DnaStrand{sequence: "acgtcaat", length: 8}