ba-0.1.0.0: General bioinformatics algorithms library

Copyright(C) 2017 Ricky Elrod
LicenseBSD2 (see LICENSE file)
MaintainerRicky Elrod <ricky@elrod.me>
Stabilityexperimental
Portabilitylens
Safe HaskellNone
LanguageHaskell2010

Bio.Algorithm.Types

Contents

Description

We emphasize making illegal states unrepresentable. As such, creating something representing a particular kind of genetic string will be done by way of smart constructors. The default constructors will not be exported.

We represent three different kinds of genetic strings (as per Rosalind), DNA, RNA, and Protein.

A DNA is created with mkDNA, an RNA is created with mkRNA, and a Protein is created with mkProtein.

Because we don't export the constructors, pattern matching becomes impossible. To rectify this, we use PatternSynonyms and export patterns for each type. These are PDNA, PRNA, and PProtein, respectively. Internally, we represent sequences as lazy Texts, and this is what you deconstruct one using one of these pattern synonyms.

Synopsis

Macromolecule types

data DNA #

A DNA sequence. This is constructed using the mkDNA smart constructor below.

Instances

Eq DNA # 

Methods

(==) :: DNA -> DNA -> Bool #

(/=) :: DNA -> DNA -> Bool #

Ord DNA # 

Methods

compare :: DNA -> DNA -> Ordering #

(<) :: DNA -> DNA -> Bool #

(<=) :: DNA -> DNA -> Bool #

(>) :: DNA -> DNA -> Bool #

(>=) :: DNA -> DNA -> Bool #

max :: DNA -> DNA -> DNA #

min :: DNA -> DNA -> DNA #

Show DNA # 

Methods

showsPrec :: Int -> DNA -> ShowS #

show :: DNA -> String #

showList :: [DNA] -> ShowS #

Semigroup DNA # 

Methods

(<>) :: DNA -> DNA -> DNA #

sconcat :: NonEmpty DNA -> DNA #

stimes :: Integral b => b -> DNA -> DNA #

Monoid DNA # 

Methods

mempty :: DNA #

mappend :: DNA -> DNA -> DNA #

mconcat :: [DNA] -> DNA #

data RNA #

An RNA sequence. This is constructed using the mkRNA smart constructor below.

Instances

Eq RNA # 

Methods

(==) :: RNA -> RNA -> Bool #

(/=) :: RNA -> RNA -> Bool #

Ord RNA # 

Methods

compare :: RNA -> RNA -> Ordering #

(<) :: RNA -> RNA -> Bool #

(<=) :: RNA -> RNA -> Bool #

(>) :: RNA -> RNA -> Bool #

(>=) :: RNA -> RNA -> Bool #

max :: RNA -> RNA -> RNA #

min :: RNA -> RNA -> RNA #

Show RNA # 

Methods

showsPrec :: Int -> RNA -> ShowS #

show :: RNA -> String #

showList :: [RNA] -> ShowS #

Semigroup RNA # 

Methods

(<>) :: RNA -> RNA -> RNA #

sconcat :: NonEmpty RNA -> RNA #

stimes :: Integral b => b -> RNA -> RNA #

Monoid RNA # 

Methods

mempty :: RNA #

mappend :: RNA -> RNA -> RNA #

mconcat :: [RNA] -> RNA #

Patterns

pattern PDNA :: Text -> DNA #

Since raw constructors are not exported, we provide these a pattern for deconstructing DNA and RNA. This is one such pattern for DNA. Generally it should not be needed (use the lens combinators instead), but we provide it here anyway, and use it internally in some places.

pattern PRNA :: Text -> RNA #

And this is the same for RNA.

Prisms (DNA)

stringDNA :: Prism' String DNA #

lazyTextDNA :: Prism' Text DNA #

strictTextDNA :: Prism' Text DNA #

Prisms (RNA)

stringRNA :: Prism' String RNA #

lazyTextRNA :: Prism' Text RNA #

strictTextRNA :: Prism' Text RNA #

Transcription isomorphism

transcribe :: Iso' DNA RNA #

There is an isomorphism between DNA and RNA defined by RNA transcription and reverse-transcription.

reverseTranscribe :: Iso' RNA DNA #

A helper to reverse-transcribe back to DNA.

reverseTranscribe = from transcribe

Trivial isomorphisms

dnaIso :: Iso' DNA DNA #

DNA is, of course, isomorphic to itself under the identity function.

rnaIso :: Iso' RNA RNA #

RNA is, of course, isomorphic to itself under the identity function.

Helper Functions

mapDNA :: (AsDNA s, AsDNA t) => (s -> t) -> DNA -> Maybe DNA #

Map over a DNA sequence if possible. In general, prefer to use more "Lensy" ways of doing this.

mapRNA :: (AsRNA s, AsRNA t) => (s -> t) -> RNA -> Maybe RNA #

Map over an RNA sequence if possible. In general, prefer to use more "Lensy" ways of doing this.

isDNAChar :: Char -> Bool #

Helper function for helping to validate a valid DNA string.

isRNAChar :: Char -> Bool #

Helper function for helping to validate a valid RNA string.