ViennaRNA-bindings 0.1.1.1 → 0.1.2.0
raw patch · 5 files changed
+67/−12 lines, 5 files
Files
- BioInf/ViennaRNA/Bindings.hs +4/−0
- BioInf/ViennaRNA/Bindings/FFI/CoFold.chs +29/−7
- ViennaRNA-bindings.cabal +2/−5
- cbits/ffiwrap_part_func.c +28/−0
- changelog +4/−0
BioInf/ViennaRNA/Bindings.hs view
@@ -55,3 +55,7 @@ copart :: String -> Int -> IO (CofoldF,String,A.Array (Int,Int) Double) copart s c = ffiCoPartitionFunction c s +copartConstrained :: String -> String -> Int -> IO (CofoldF,String,A.Array (Int,Int) Double)+copartConstrained sq str c = ffiCoPartitionConstrained c sq str++
BioInf/ViennaRNA/Bindings/FFI/CoFold.chs view
@@ -5,6 +5,7 @@ ( ffiCoFold , ffiCoEnergyOfStructure , ffiCoPartitionFunction+ , ffiCoPartitionConstrained , CofoldF (..) ) where @@ -78,18 +79,39 @@ setCutPoint cutpoint let n = length i let z = n * (n+1) `div` 2 +1- eF <- co_pf_fold_p ci cs >>= peek -- {#call co_pf_fold #} ci cs+ eF <- co_pf_fold_p ci cs >>= peek s <- peekCAString cs bp <- {#call export_co_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 (eF, s, ar) -foreign import ccall "co_pf_fold" co_pf_fold_p :: CString -> CString -> IO CofoldFPtr+-- | Constrained partition function+--+-- NOTE the wrapped C function we @foreign import@ use very dirty+-- return-pointer-from-stack stuff. We should fix that. On the other hand, it just+-- works, because we immediately peek into the structure and marshall to Haskell. -#c-cofoldF * co_pf_fold_p (char * inp, char * str)-{ return & co_pf_fold (inp, str);-}-#endc+ffiCoPartitionConstrained :: Int -> String -> String -> IO (CofoldF,String,A.Array (Int,Int) Double)+ffiCoPartitionConstrained cutpoint sq st =+ withCAString sq $ \csq ->+ withCAString st $ \cst -> do+ print sq+ print st+ print cutpoint+ setCutPoint cutpoint+ let n = length sq+ let z = n * (n+1) `div` 2 +1+ eF <- co_pf_fold_constrained_p csq cst 1 >>= peek+ s <- peekCAString cst+ bp <- {#call export_co_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 (eF, s, ar)++++foreign import ccall "ffiwrap_co_pf_fold" co_pf_fold_p :: CString -> CString -> IO CofoldFPtr++foreign import ccall "ffiwrap_co_pf_fold_constrained" co_pf_fold_constrained_p :: CString -> CString -> Int -> IO CofoldFPtr
ViennaRNA-bindings.cabal view
@@ -1,12 +1,12 @@ name: ViennaRNA-bindings-version: 0.1.1.1+version: 0.1.2.0 synopsis: ViennaRNA v2 bindings homepage: http://www.tbi.univie.ac.at/~choener/ license: OtherLicense license-file: LICENSE author: Christian Hoener zu Siederdissen (bindings) 2013-4, The ViennaRNA Team (library) 1994-2014 maintainer: choener@tbi.univie.ac.at-copyright: The ViennaRNA Team 1994-2013+copyright: The ViennaRNA Team 1994-2014 category: Bioinformatics, FFI build-type: Simple cabal-version: >=1.8@@ -73,7 +73,6 @@ BioInf.ViennaRNA.Bindings.FFI.Fold BioInf.ViennaRNA.Bindings.FFI.PartFunc BioInf.ViennaRNA.Bindings.FFI.Utils- -- other-modules: build-depends: base == 4.* , array@@ -94,6 +93,4 @@ cc-options: include-dirs: include includes: config.h--- RNA--- gomp
cbits/ffiwrap_part_func.c view
@@ -1,8 +1,36 @@ +// functions wrapped in here need a C-wrapper because they do "more work"+// before they can be called from C.++#include <stdio.h>+ #include "part_func.h"+#include "part_func_co.h" +// wrap the RNAfold constrained partition function+ float ffiwrap_pf_fold_constrained (const char *sequence, char *structure, int constrained) { return pf_fold_par (sequence, structure, 0, 1, constrained, 0);+}++// wrap the RNAcofold constrained partition function.+//+// TODO the current implementation makes me cry.++cofoldF * ffiwrap_co_pf_fold_constrained (char *sequence, char *structure, int constrained)+{+ cofoldF x = co_pf_fold_par (sequence, structure, 0, 1, constrained);+ return &x;+}++// wrap RNAcofold partition function+//+// TODO the current implementation makes me cry.++cofoldF * ffiwrap_co_pf_fold (char * inp, char * str)+{+ cofoldF x = co_pf_fold (inp, str);+ return &x; }
changelog view
@@ -1,3 +1,7 @@+0.1.2.0++- constrained cofold partition function added+ 0.1.1.1 - export everything in the bindings