Copyright | (C) 2017 Ricky Elrod |
---|---|
License | BSD2 (see LICENSE file) |
Maintainer | Ricky Elrod <ricky@elrod.me> |
Stability | experimental |
Portability | lens |
Safe Haskell | None |
Language | Haskell2010 |
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 Text
s, and this is what you
deconstruct one using one of these pattern synonyms.
- data DNA
- data RNA
- pattern PDNA :: Text -> DNA
- pattern PRNA :: Text -> RNA
- stringDNA :: Prism' String DNA
- lazyTextDNA :: Prism' Text DNA
- strictTextDNA :: Prism' Text DNA
- lazyBSDNA :: Prism' ByteString DNA
- strictBSDNA :: Prism' ByteString DNA
- stringRNA :: Prism' String RNA
- lazyTextRNA :: Prism' Text RNA
- strictTextRNA :: Prism' Text RNA
- lazyBSRNA :: Prism' ByteString RNA
- strictBSRNA :: Prism' ByteString RNA
- transcribe :: Iso' DNA RNA
- reverseTranscribe :: Iso' RNA DNA
- dnaIso :: Iso' DNA DNA
- rnaIso :: Iso' RNA RNA
- mapDNA :: (AsDNA s, AsDNA t) => (s -> t) -> DNA -> Maybe DNA
- mapRNA :: (AsRNA s, AsRNA t) => (s -> t) -> RNA -> Maybe RNA
- isDNAChar :: Char -> Bool
- isRNAChar :: Char -> Bool
Macromolecule types
A DNA
sequence. This is constructed using the mkDNA
smart constructor
below.
An RNA
sequence. This is constructed using the mkRNA
smart constructor
below.
Patterns
Prisms (DNA)
lazyTextDNA :: Prism' Text DNA #
strictTextDNA :: Prism' Text DNA #
lazyBSDNA :: Prism' ByteString DNA #
strictBSDNA :: Prism' ByteString DNA #
Prisms (RNA)
lazyTextRNA :: Prism' Text RNA #
strictTextRNA :: Prism' Text RNA #
lazyBSRNA :: Prism' ByteString RNA #
strictBSRNA :: Prism' ByteString RNA #
Transcription isomorphism
transcribe :: Iso' DNA RNA #
reverseTranscribe :: Iso' RNA DNA #
A helper to reverse-transcribe back to DNA
.
reverseTranscribe = from transcribe
Trivial isomorphisms
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.