ViennaRNA-bindings (empty) → 0.0.2.3
raw patch · 7 files changed
+180/−0 lines, 7 filesdep +arraydep +basesetup-changed
Dependencies added: array, base
Files
- BioInf/ViennaRNA/Bindings.hs +30/−0
- BioInf/ViennaRNA/Bindings/FFI/Fold.chs +33/−0
- BioInf/ViennaRNA/Bindings/FFI/PartFunc.chs +34/−0
- BioInf/ViennaRNA/Bindings/FFI/Utils.hs +12/−0
- LICENSE +19/−0
- Setup.hs +2/−0
- ViennaRNA-bindings.cabal +50/−0
+ BioInf/ViennaRNA/Bindings.hs view
@@ -0,0 +1,30 @@++-- | Bindings to important functions in the ViennaRNA library.++module BioInf.ViennaRNA.Bindings where++import qualified Data.Array.IArray as A++import BioInf.ViennaRNA.Bindings.FFI.Fold as FFI+import BioInf.ViennaRNA.Bindings.FFI.PartFunc as FFI++-- | Fold a sequence into an optimal secondary structure. Returns a pair of+-- energy and structure.++mfe :: String -> IO (Double,String)+mfe = ffiFold++-- | Given a sequence and a structure, returns the energy of the+-- sequence/structure pair.++eos :: String -> String -> IO Double+eos i s = ffiEnergyOfStructure i s 0++-- | Given a string, calculates the partition function for said string. Returns+-- the ensemble energy, a string with where each nucleotide position is+-- annotated with the strength of the potential pairing, and the whole base+-- pair probability table.++part :: String -> IO (Double,String,A.Array (Int,Int) Double)+part = ffiPartitionFunction+
+ BioInf/ViennaRNA/Bindings/FFI/Fold.chs view
@@ -0,0 +1,33 @@+{-# LANGUAGE ForeignFunctionInterface #-}++module BioInf.ViennaRNA.Bindings.FFI.Fold+ ( ffiFold+ , ffiEnergyOfStructure+ ) where++import Foreign.C.String+import Foreign.C.Types+import Foreign.Marshal.Alloc+import Foreign.Ptr+import GHC.Float+import Unsafe.Coerce++import BioInf.ViennaRNA.Bindings.FFI.Utils++++#include <ViennaRNA/fold.h>++ffiFold :: String -> IO (Double,String)+ffiFold inp = withCAString inp $ \cinp ->+ withCAString inp $ \struc -> do+ e <- {#call fold #} cinp struc+ s <- peekCAString struc+ return (cf2d e, s)++ffiEnergyOfStructure :: String -> String -> Int -> IO Double+ffiEnergyOfStructure inp struc verb =+ withCAString inp $ \i ->+ withCAString struc $ \s ->+ {#call energy_of_structure #} i s (fromIntegral verb :: CInt) >>= (return . cf2d)+
+ BioInf/ViennaRNA/Bindings/FFI/PartFunc.chs view
@@ -0,0 +1,34 @@+{-# LANGUAGE ForeignFunctionInterface #-}++module BioInf.ViennaRNA.Bindings.FFI.PartFunc+ ( ffiPartitionFunction+ ) where++import Foreign.C.String+import Foreign.C.Types+import Foreign.Marshal.Alloc+import Foreign.Marshal.Array+import Foreign.Ptr+import GHC.Float+import qualified Data.Array.IArray as A+import Unsafe.Coerce++import BioInf.ViennaRNA.Bindings.FFI.Utils++++#include <ViennaRNA/part_func.h>++ffiPartitionFunction :: String -> IO (Double,String,A.Array (Int,Int) Double)+ffiPartitionFunction i =+ withCAString i $ \ci ->+ withCAString i $ \cs -> do+ let n = length i+ let z = n * (n+1) `div` 2 +1+ e <- {#call pf_fold #} ci cs+ s <- peekCAString cs+ bp <- {#call export_bppm #}+ xs <- peekArray z (bp :: Ptr CDouble)+ let ar = A.accumArray (const id) 0 ((1,1),(n,n)) $ zip [ (ii,jj) | ii <- [n,n-1..1], jj <- [n,n-1..ii]] (drop 1 $ map unsafeCoerce xs)+ return (cf2d e, s, ar)+
+ BioInf/ViennaRNA/Bindings/FFI/Utils.hs view
@@ -0,0 +1,12 @@++module BioInf.ViennaRNA.Bindings.FFI.Utils where++import Foreign.C.Types+import GHC.Float+import Unsafe.Coerce++++cf2d :: CFloat -> Double+cf2d = float2Double . unsafeCoerce+
+ LICENSE view
@@ -0,0 +1,19 @@+ Disclaimer and Copyright++The programs, library and source code of the Vienna RNA Package are free+software. They are distributed in the hope that they will be useful+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ++Permission is granted for research, educational, and commercial use+and modification so long as 1) the package and any derived works are not+redistributed for any fee, other than media costs, 2) proper credit is+given to the authors and the Institute for Theoretical Chemistry of the +University of Vienna.++If you want to include this software in a commercial product, please contact +the authors. ++Note that the file ./lib/naview.c has its own copyright attached. +The ./Readseq/ directory contains a modified version of Don Gilbert's+public domain readseq program.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ ViennaRNA-bindings.cabal view
@@ -0,0 +1,50 @@+name: ViennaRNA-bindings+version: 0.0.2.3+synopsis: ViennaRNA v2 bindings+homepage: http://www.tbi.univie.ac.at/~choener/+license: OtherLicense+license-file: LICENSE+author: Christian Hoener zu Siederdissen (bindings) 2013, The ViennaRNA Team (library) 1994-2013+maintainer: choener@tbi.univie.ac.at+copyright: The ViennaRNA Team 1994-2013+category: Bioinformatics, FFI+build-type: Simple+cabal-version: >=1.8++description:+ Bindings to the ViennaRNA package, version 2.x.y.+ .+ Only a partial set of bindings is provided. If you need additional functions,+ please open an issue on github.+ .+ The ViennaRNA package needs to be installed. In addition, you should create a+ shared object from libRNA.a:+ .+ @mkdir tmp; ar -x /usr/lib/libRNA.a; rm svm.o; gcc -shared *.o -o libRNA.so@+ .+ Then, copy the resulting .so file into your library path or set+ @LD_LIBRARY_PATH@ appropriately. This is only necessary, if you want ghci+ support.+ .+ If you use this software, please cite:+ R. Lorenz, S.H. Bernhart, C. Hoener zu Siederdissen, H. Tafer, C. Flamm, P.F. Stadler and I.L. Hofacker (2011),+ "ViennaRNA Package 2.0", Algorithms for Molecular Biology: 6:26++library+ exposed-modules:+ -- public interfaces+ BioInf.ViennaRNA.Bindings+ -- the FFI+ BioInf.ViennaRNA.Bindings.FFI.Fold+ BioInf.ViennaRNA.Bindings.FFI.PartFunc+ BioInf.ViennaRNA.Bindings.FFI.Utils+ -- other-modules:+ build-depends:+ base == 4.* ,+ array+ build-tools:+ c2hs+ extra-libraries:+ RNA+ gomp+