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!
- class (Show a, Ring a, Unbox a, Prim a) => FoldFunctions a where
- stackOpt :: TurnerTables a -> Primary -> Table a -> Int -> Int -> a
- stackIdx :: TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
- hairpinOpt :: TurnerTables a -> Primary -> Int -> Int -> a
- hairpinIdx :: TurnerTables a -> Primary -> Int -> Int -> [a]
- largeInteriorLoopOpt :: TurnerTables a -> Primary -> Table a -> Int -> Int -> a
- largeInteriorLoopIdx :: TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
- tabbedInteriorLoopOpt :: TurnerTables a -> Primary -> Table a -> Int -> Int -> a
- tabbedInteriorLoopIdx :: TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
- bulgeLOpt :: TurnerTables a -> Primary -> Table a -> Int -> Int -> a
- bulgeLIdx :: TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
- bulgeROpt :: TurnerTables a -> Primary -> Table a -> Int -> Int -> a
- bulgeRIdx :: TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
- interior1xnLOpt :: TurnerTables a -> Primary -> Table a -> Int -> Int -> a
- interior1xnLIdx :: TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
- interior1xnROpt :: TurnerTables a -> Primary -> Table a -> Int -> Int -> a
- interior1xnRIdx :: TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
- multibranchIJLoopOpt :: TurnerTables a -> Primary -> Table a -> Int -> Int -> a
- multibranchIJLoopIdx :: TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
- multibranchUnpairedJOpt :: TurnerTables a -> Primary -> Table a -> Int -> Int -> a
- multibranchUnpairedJIdx :: TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
- multibranchKJHelixOpt :: TurnerTables a -> Primary -> Table a -> Int -> Int -> a
- multibranchKJHelixIdx :: TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Int, a)]
- multibranchAddKJHelixOpt :: TurnerTables a -> Primary -> Table a -> Table a -> Int -> Int -> a
- multibranchAddKJHelixIdx :: TurnerTables a -> Primary -> Table a -> Table a -> Int -> Int -> [(Int, a)]
- multibranchCloseOpt :: TurnerTables a -> Primary -> Table a -> Table a -> Int -> Int -> a
- multibranchCloseIdx :: TurnerTables a -> Primary -> Table a -> Table a -> Int -> Int -> [(Int, a)]
- externalLoopOpt :: TurnerTables a -> Primary -> Table a -> Int -> Int -> a
- externalLoopIdx :: TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]
- externalAddLoopOpt :: TurnerTables a -> Primary -> Table a -> Table a -> Int -> Int -> a
- externalAddLoopIdx :: TurnerTables a -> Primary -> Table a -> Table a -> Int -> Int -> [(Int, a)]
- calcNinio :: a -> a -> Int -> a
- calcTermAU :: a -> ViennaPair -> a
- calcLargeLoop :: 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)
Documentation
class (Show a, Ring a, Unbox a, Prim a) => FoldFunctions a whereSource
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.
stackOpt :: TurnerTables a -> Primary -> Table a -> Int -> Int -> aSource
stackIdx :: TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]Source
hairpinOpt :: TurnerTables a -> Primary -> Int -> Int -> aSource
hairpinIdx :: TurnerTables a -> Primary -> Int -> Int -> [a]Source
largeInteriorLoopOpt :: TurnerTables a -> Primary -> Table a -> Int -> Int -> aSource
largeInteriorLoopIdx :: TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]Source
tabbedInteriorLoopOpt :: TurnerTables a -> Primary -> Table a -> Int -> Int -> aSource
tabbedInteriorLoopIdx :: TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]Source
bulgeLOpt :: TurnerTables a -> Primary -> Table a -> Int -> Int -> aSource
bulgeLIdx :: TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]Source
bulgeROpt :: TurnerTables a -> Primary -> Table a -> Int -> Int -> aSource
bulgeRIdx :: TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]Source
interior1xnLOpt :: TurnerTables a -> Primary -> Table a -> Int -> Int -> aSource
interior1xnLIdx :: TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]Source
interior1xnROpt :: TurnerTables a -> Primary -> Table a -> Int -> Int -> aSource
interior1xnRIdx :: TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]Source
multibranchIJLoopOpt :: TurnerTables a -> Primary -> Table a -> Int -> Int -> aSource
multibranchIJLoopIdx :: TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]Source
multibranchUnpairedJOpt :: TurnerTables a -> Primary -> Table a -> Int -> Int -> aSource
multibranchUnpairedJIdx :: TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]Source
multibranchKJHelixOpt :: TurnerTables a -> Primary -> Table a -> Int -> Int -> aSource
multibranchKJHelixIdx :: TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Int, a)]Source
multibranchAddKJHelixOpt :: TurnerTables a -> Primary -> Table a -> Table a -> Int -> Int -> aSource
multibranchAddKJHelixIdx :: TurnerTables a -> Primary -> Table a -> Table a -> Int -> Int -> [(Int, a)]Source
multibranchCloseOpt :: TurnerTables a -> Primary -> Table a -> Table a -> Int -> Int -> aSource
multibranchCloseIdx :: TurnerTables a -> Primary -> Table a -> Table a -> Int -> Int -> [(Int, a)]Source
externalLoopOpt :: TurnerTables a -> Primary -> Table a -> Int -> Int -> aSource
externalLoopIdx :: TurnerTables a -> Primary -> Table a -> Int -> Int -> [(Cell, a)]Source
externalAddLoopOpt :: TurnerTables a -> Primary -> Table a -> Table a -> Int -> Int -> aSource
externalAddLoopIdx :: TurnerTables a -> Primary -> Table a -> Table a -> Int -> Int -> [(Int, a)]Source
calcNinio :: a -> a -> Int -> aSource
Calculate the ninio asymmetric malus. Can not be written using ring
functions alone as a min
or max
functions is required.
:: a | |
-> ViennaPair | |
-> a | Apply terminal AU penalty |
Applies a terminal AU/GU penalty, where required.
TODO shouldn't this be just: if CG||GC then one else termAU?
calcLargeLoop :: Int -> aSource
large hairpin loops >30 require special calculations that involve
floor
, rounding and other stuff that can not be handled by the Ring
class alone
type TurnerTables a = Turner2004 ViennaPair Nucleotide aSource
riap :: (Num a, Ix a, Bounded a) => PrimArray a Nucleotide -> a -> a -> ViennaPairSource
ringProductL :: (Ring a, Unbox a) => [a] -> aSource