-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | RNA secondary structure prediction
--
-- Provides the folding functions as used in the ViennaRNA package. Here,
-- they are in Haskell form to be used by Haskell programs.
--
--
-- - This is a release aimed at testing Data.Vector - Expect major
-- performance issues with GHC < 6.13!
--
@package RNAFold
@version 0.0.2.1
-- | These functions are implementations of RNA secondary structure folding
-- as described in Bompfuenewere et al., 2006, Variations on RNA
-- folding and alignment
--
-- We have all the facilities needed for folding with the RNA parameter
-- of Turner 2004 http:rna.urmc.rochester.eduNNDBturner04/
-- but consider only double dangles which correspond to the
-- ViennaRNA package option -d2. They are a bit easier to
-- implement and are what is used for partition function calculations. In
-- addition, it seems unlikely to see a statiscally relevant improvement
-- in predication with -d1 or -d3.
--
-- All functions work on an algebraic ring structure. This should make it
-- easier to implement certain functionality without having to rewrite
-- all the functions given here. Try deriving a new Ring instance
-- first and see if it just works.
--
-- These functions do quite well, performancewise. GHC-HEAD with
-- -Odph and -fllvm takes 14.4s, while the highly optimized
-- viennaRNA package (the yet unpublished 2.0 version) takes about 1-2s
-- on a sequence of length 1000.
--
-- NOTE For GHC <= 6.12.3 you should copy the default instances into
-- your instance BLA, otherwise the resulting code will be slow. Or you
-- could just wait for the new GHC to arrive! The new one produces good
-- code without such stuff.
--
-- TODO single nucleotide bulges:
-- http:rna.urmc.rochester.eduNNDBturner04/bulge.html ,
-- check what Vienna 2.0 does!
module BioInf.RNAFold.Functions
-- | The folding functions. It could happen that we need different folding
-- functions with the same type, hence the class-based approach. The
-- default instance uses the usual ring methods.
class (Show a, Ring a, Unbox a, Prim a) => FoldFunctions a
stackOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> a
stackIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
hairpinOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Int -> Int -> a
hairpinIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Int -> Int -> [a]
largeInteriorLoopOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> a
largeInteriorLoopIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
tabbedInteriorLoopOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> a
tabbedInteriorLoopIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
bulgeLOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> a
bulgeLIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
bulgeROpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> a
bulgeRIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
interior1xnLOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> a
interior1xnLIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
interior1xnROpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> a
interior1xnRIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
multibranchIJLoopOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> a
multibranchIJLoopIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
multibranchUnpairedJOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> a
multibranchUnpairedJIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
multibranchKJHelixOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> a
multibranchKJHelixIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Int, a)]
multibranchAddKJHelixOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Table a -> Int -> Int -> a
multibranchAddKJHelixIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Table a -> Int -> Int -> [(Int, a)]
multibranchCloseOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Table a -> Int -> Int -> a
multibranchCloseIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Table a -> Int -> Int -> [(Int, a)]
externalLoopOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> a
externalLoopIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
externalAddLoopOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Table a -> Int -> Int -> a
externalAddLoopIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Table a -> Int -> Int -> [(Int, a)]
calcNinio :: (FoldFunctions a) => a -> a -> Int -> a
calcTermAU :: (FoldFunctions a) => a -> ViennaPair -> a
calcLargeLoop :: (FoldFunctions a) => Int -> a
type Table a = PrimArray Cell a
type TurnerTables a = Turner2004 ViennaPair Nucleotide a
ringSumL :: (Ring a, Unbox a) => [a] -> a
pair :: Primary -> Int -> Int -> ViennaPair
riap :: (Num a, Ix a, Bounded a) => PrimArray a Nucleotide -> a -> a -> ViennaPair
ringProductL :: (Ring a, Unbox a) => [a] -> a
tabbedInteriorLoopDistances :: Int -> Int -> Vector (Int, Int)
-- | ViennaRNA folding based on an algebraic ring structure. This should
-- combine the goals of few lines of codes, multiple different folding
-- functions and extensibility.
--
-- NOTE Assume that you want '-d 3' for folding with dangles. Then you
-- can just instanciate the folding functions, replacing only those
-- functions where the folding changes based on the new dangle options.
--
-- NOTE compile with: -fno-method-sharing
module BioInf.RNAFold
-- | Folding works on unboxed values of a Ring-type for which a
-- FoldFunctions instance does exist. By default, we have this for Energy
-- values. Again, we use a class as we could be interested in
-- probabilistic backtracking or something like that.
type ResultTables a = (Table a, Table a, Table a, Table a, Table a)
type Pairlist = [(Int, Int)]
class (FoldFunctions a) => Fold a
fold :: (Fold a) => TurnerTables a -> Primary -> (ResultTables a)
foldST :: (Fold a) => TurnerTables a -> Primary -> ST s (ResultTables a)
backtrack :: (Fold a) => TurnerTables a -> Primary -> (ResultTables a) -> a -> [(Secondary, a)]
module BioInf.RNAFold.Energy
-- | The folding functions. It could happen that we need different folding
-- functions with the same type, hence the class-based approach. The
-- default instance uses the usual ring methods.
class (Show a, Ring a, Unbox a, Prim a) => FoldFunctions a
stackOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> a
stackIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
hairpinOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Int -> Int -> a
hairpinIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Int -> Int -> [a]
largeInteriorLoopOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> a
largeInteriorLoopIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
tabbedInteriorLoopOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> a
tabbedInteriorLoopIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
bulgeLOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> a
bulgeLIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
bulgeROpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> a
bulgeRIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
interior1xnLOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> a
interior1xnLIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
interior1xnROpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> a
interior1xnRIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
multibranchIJLoopOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> a
multibranchIJLoopIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
multibranchUnpairedJOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> a
multibranchUnpairedJIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
multibranchKJHelixOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> a
multibranchKJHelixIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Int, a)]
multibranchAddKJHelixOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Table a -> Int -> Int -> a
multibranchAddKJHelixIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Table a -> Int -> Int -> [(Int, a)]
multibranchCloseOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Table a -> Int -> Int -> a
multibranchCloseIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Table a -> Int -> Int -> [(Int, a)]
externalLoopOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> a
externalLoopIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
externalAddLoopOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Table a -> Int -> Int -> a
externalAddLoopIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Table a -> Int -> Int -> [(Int, a)]
calcNinio :: (FoldFunctions a) => a -> a -> Int -> a
calcTermAU :: (FoldFunctions a) => a -> ViennaPair -> a
calcLargeLoop :: (FoldFunctions a) => Int -> a
class (FoldFunctions a) => Fold a
fold :: (Fold a) => TurnerTables a -> Primary -> (ResultTables a)
foldST :: (Fold a) => TurnerTables a -> Primary -> ST s (ResultTables a)
backtrack :: (Fold a) => TurnerTables a -> Primary -> (ResultTables a) -> a -> [(Secondary, a)]
instance Fold Energy
instance FoldFunctions Energy
-- | Temporary hackery until all base libraries understand newtype Energy.
-- And yes, for testing too.
module BioInf.RNAFold.EnergyInt
-- | The folding functions. It could happen that we need different folding
-- functions with the same type, hence the class-based approach. The
-- default instance uses the usual ring methods.
class (Show a, Ring a, Unbox a, Prim a) => FoldFunctions a
stackOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> a
stackIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
hairpinOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Int -> Int -> a
hairpinIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Int -> Int -> [a]
largeInteriorLoopOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> a
largeInteriorLoopIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
tabbedInteriorLoopOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> a
tabbedInteriorLoopIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
bulgeLOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> a
bulgeLIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
bulgeROpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> a
bulgeRIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
interior1xnLOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> a
interior1xnLIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
interior1xnROpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> a
interior1xnRIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
multibranchIJLoopOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> a
multibranchIJLoopIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
multibranchUnpairedJOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> a
multibranchUnpairedJIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
multibranchKJHelixOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> a
multibranchKJHelixIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Int, a)]
multibranchAddKJHelixOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Table a -> Int -> Int -> a
multibranchAddKJHelixIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Table a -> Int -> Int -> [(Int, a)]
multibranchCloseOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Table a -> Int -> Int -> a
multibranchCloseIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Table a -> Int -> Int -> [(Int, a)]
externalLoopOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> a
externalLoopIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
externalAddLoopOpt :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Table a -> Int -> Int -> a
externalAddLoopIdx :: (FoldFunctions a) => TurnerTables a -> Primary -> Table a -> Table a -> Int -> Int -> [(Int, a)]
calcNinio :: (FoldFunctions a) => a -> a -> Int -> a
calcTermAU :: (FoldFunctions a) => a -> ViennaPair -> a
calcLargeLoop :: (FoldFunctions a) => Int -> a
class (FoldFunctions a) => Fold a
fold :: (Fold a) => TurnerTables a -> Primary -> (ResultTables a)
foldST :: (Fold a) => TurnerTables a -> Primary -> ST s (ResultTables a)
backtrack :: (Fold a) => TurnerTables a -> Primary -> (ResultTables a) -> a -> [(Secondary, a)]
instance Fold Int
instance FoldFunctions Int
instance Ring Int
-- | Given a sequence and a structure, evaluate the energy.
--
-- TODO switch to 'SSTree [Energy]' type!
module BioInf.RNAEval
-- | Sum up a complete (sub-) tree.
rnaEval :: ViennaTables -> String -> String -> Int
-- | Evaluate the energy of a secondary structure tree with sequence. We
-- abuse the normal folding functions with a dummy table full of (one ::
-- Energy). This is probably slower than another method but quickly
-- written.
--
-- TODO this is basically crapfuck ;-) Should use the FoldFunctions
-- directly instead of that strange table. Should not xxxOpt either.
annotateWithEnergy :: ViennaTables -> Primary -> SSTree () -> SSTree [Int]
-- | convert an annotated tree into strings that explain each score.
--
-- TODO this is a stupid name
explainTree :: Primary -> SSTree [Int] -> [String]