packages feed

BiobaseXNA 0.6.3.1 → 0.7.0.0

raw patch · 8 files changed

+73/−67 lines, 8 filesdep +repadep ~PrimitiveArraydep ~bytestringdep ~file-embedPVP ok

version bump matches the API change (PVP)

Dependencies added: repa

Dependency ranges changed: PrimitiveArray, bytestring, file-embed, primitive

API changes (from Hackage documentation)

- Biobase.Primary: instance [overlap ok] Bounded Nuc
- Biobase.Primary: instance [overlap ok] Bounds Nuc
- Biobase.Primary: instance [overlap ok] Eq Primary
- Biobase.Primary: instance [overlap ok] Ord Primary
- Biobase.Primary: nU :: Nuc
- Biobase.Secondary.Diagrams: test :: (Int, [ExtPairIdx])
- Biobase.Secondary.Diagrams: test' :: [((Int, Int), (CTisomerism, Edge, Edge))]
+ Biobase.Primary: cgau :: [Nuc]
+ Biobase.Secondary.Vienna: isViennaPair :: Nuc -> Nuc -> Bool
- Biobase.Primary: type Primary = Arr0 DIM1 Nuc
+ Biobase.Primary: type Primary = Vector Nuc
- Biobase.Secondary.Constraint: bonusTable :: Double -> Double -> Constraint -> Arr0 DIM2 Double
+ Biobase.Secondary.Constraint: bonusTable :: Double -> Double -> Constraint -> Unboxed DIM2 Double
- Biobase.Secondary.Vienna: viennaPairTable :: Arr0 ((Z :. Nuc) :. Nuc) ViennaPair
+ Biobase.Secondary.Vienna: viennaPairTable :: Unboxed ((Z :. Nuc) :. Nuc) ViennaPair

Files

Biobase/Primary.hs view
@@ -32,16 +32,13 @@ import qualified Data.Vector.Generic.Mutable as VGM import qualified Data.Vector.Unboxed as VU -import Data.ExtShape-import Data.PrimitiveArray-import Data.PrimitiveArray.Zero.Unboxed-import "PrimitiveArray" Data.Array.Repa.Index-import "PrimitiveArray" Data.Array.Repa.Shape+import Data.Array.Repa.ExtShape+import Data.Array.Repa.Index+import Data.Array.Repa.Shape  import Biobase.Primary.Bounds  - -- * Convert different types of sequence representations to the internal -- "Primary Structure" representation @@ -51,24 +48,11 @@ class MkPrimary a where   mkPrimary :: a -> Primary -type Primary = Arr0 DIM1 Nuc+type Primary = VU.Vector Nuc -instance Eq Primary where-  xs == ys-    | bx==by = sliceEq xs zeroDim ys zeroDim bx-    | otherwise = False-    where (_,bx) = bounds xs-          (_,by) = bounds ys -instance Ord Primary where-  xs <= ys-    | bx==by    = toList xs <= toList ys-    | otherwise = bx<=by-    where (_,Z:.bx) = bounds xs-          (_,Z:.by) = bounds ys  - -- * Efficient nucleotide encoding  -- A 'Nuc'leotide is simply an Int wrapped up. 'nIMI' provides for@@ -78,13 +62,13 @@ newtype Nuc = Nuc {unNuc :: Int}   deriving (Eq,Ord,Ix) -(nN : nA : nC : nG : nT : nIMI : nUndefined : _) = map Nuc [0 .. ]-nU = nT+(nN : nA : nC : nG : nT : nU : nIMI : nUndefined : _) = map Nuc [0 .. ] -acgt = [nA..nT]-acgu = acgt-nacgt = [nN..nT]-nacgu = nacgt+acgt = [nA,nC,nG,nT]+acgu = [nA,nC,nG,nU]+cgau = [nC,nG,nA,nU]+nacgt = nN:acgt+nacgu = nN:acgu  -- | Translate between 'Char's and 'Nuc's. @@ -180,6 +164,7 @@   subDim (sh1:.Nuc n1) (sh2:.Nuc n2) = subDim sh1 sh2 :. Nuc (n1-n2)   rangeList (sh1:.Nuc n1) (sh2:.Nuc n2) = [ sh:.Nuc n | sh <- rangeList sh1 sh2, n <- [n1 .. (n1+n2)]] +{- -- | The bounded instance from GHC proper. Captures all defined symbols.  instance Bounded Nuc where@@ -194,6 +179,9 @@   minExtended = nN   maxExtended = nT ++-}+ -- | Enum  instance Enum Nuc where@@ -203,7 +191,7 @@ -- ** Instances for 'MkPrimary'  instance MkPrimary String where-  mkPrimary xs = fromList (Z:.0) (Z:.length xs -1) $ map mkNuc xs+  mkPrimary = VU.fromList . map mkNuc  instance MkPrimary BS.ByteString where   mkPrimary = mkPrimary . BS.unpack@@ -215,5 +203,5 @@   mkPrimary = mkPrimary . T.unpack  instance MkPrimary [Nuc] where-  mkPrimary xs = fromList (Z:.0) (Z:.length xs -1) xs+  mkPrimary = VU.fromList 
Biobase/Primary/Hashed.hs view
@@ -14,8 +14,6 @@ import qualified Data.Vector.Generic.Mutable as VGM import qualified Data.Vector.Unboxed as VU -import Data.PrimitiveArray- import Biobase.Primary  @@ -42,9 +40,9 @@ -- for 'ps'. We could in O(1) create a vector from a Primary ...  mkHashedPrimary :: (Nuc,Nuc) -> Primary -> HashedPrimary-mkHashedPrimary (l,u) ps' = assert (VU.all (\p -> l<=p && p<=u) ps) $ HashedPrimary idx where+mkHashedPrimary (l,u) ps = assert (VU.all (\p -> l<=p && p<=u) ps) $ HashedPrimary idx where   idx   = VU.sum $ VU.zipWith f ps (VU.enumFromStepN (VU.length ps -1) (-1) (VU.length ps))   f p c = (unNuc p - unNuc l) * (cnst^c)   cnst = unNuc u - unNuc l + 1-  ps = VU.fromList $ toList ps' {-# INLINE mkHashedPrimary #-}+
Biobase/Secondary.hs view
@@ -17,8 +17,8 @@  module Biobase.Secondary where -import "PrimitiveArray" Data.Array.Repa.Index-import "PrimitiveArray" Data.Array.Repa.Shape+import Data.Array.Repa.Index+import Data.Array.Repa.Shape import Data.Char (toLower, toUpper) import Data.Ix (Ix(..)) import Data.List as L@@ -346,3 +346,4 @@   {-# INLINE updR #-}   {-# INLINE updP #-}   {-# INLINE updT #-}+
Biobase/Secondary/Constraint.hs view
@@ -7,16 +7,17 @@  module Biobase.Secondary.Constraint where +import Data.Array.Repa.Index+import Data.Array.Repa.Shape import Data.Char (toLower) import Data.Primitive.Types import qualified Data.Vector.Generic as VG import qualified Data.Vector.Generic.Mutable as VGM import qualified Data.Vector.Unboxed as VU+import Prelude as P  import Data.PrimitiveArray-import Data.PrimitiveArray.Zero.Unboxed-import "PrimitiveArray" Data.Array.Repa.Index-import "PrimitiveArray" Data.Array.Repa.Shape+import Data.PrimitiveArray.Zero  import Biobase.Secondary.Diagrams @@ -51,7 +52,7 @@ -- TODO and again, we should parametrize over "Energy", "Score", etc (that is, -- Prim a) -bonusTable :: Double -> Double -> Constraint -> Arr0 DIM2 Double+bonusTable :: Double -> Double -> Constraint -> Unboxed DIM2 Double bonusTable bonus malus (Constraint constraint) = arr where   arr = fromAssocs zeroDim (Z:.n:.n) 0 $ bonusBr ++ bonusAn ++ bonusBa ++ malusBr ++ malusAn ++ malusX   n = VU.length constraint -1@@ -109,8 +110,9 @@ -- * Instances  instance MkConstraint String where-  mkConstraint xs = mkConstraint . VU.fromList . map toLower $ xs+  mkConstraint xs = mkConstraint . VU.fromList . P.map toLower $ xs  instance MkConstraint (VU.Vector Char) where   mkConstraint cs = Constraint $ VU.zip cs ks where     (D1S ks) = mkD1S cs+
Biobase/Secondary/Diagrams.hs view
@@ -4,17 +4,12 @@  -- | Types for RNA secondary structure. Types vary from the simplest array -- (D1Secondary) to rather complex ones.------ TODO The complex ones are still coming in from other libraries.------ TODO can we use Char8 instead of Char?------ TODO prepare for extended RNA secondary structures!  {-# LANGUAGE RecordWildCards #-}  module Biobase.Secondary.Diagrams where + import qualified Data.Vector.Unboxed as VU import Data.List (sort,groupBy,sortBy) import Data.Tuple.Select (sel1,sel2)@@ -90,6 +85,7 @@  d2Grouping ((i,j),_) ((k,l),_) = i<=k && j>=l +{- test :: (Int,[ExtPairIdx]) test = (20,test') @@ -102,7 +98,7 @@   , ((2,18),(trans,sugar,sugar))   , ((15,18),(cis,sugar,sugar))   ]-+-}  -- * Instances for D1S @@ -200,3 +196,4 @@     g k (s:st) (x:xs)       | r==x = (s,k) : g (k+1) st xs     g a b c = error $ show (a,b,c)+
Biobase/Secondary/PseudoKnots.hs view
@@ -59,3 +59,4 @@  instance RemovePseudoKnots [ExtPairIdx] where   removeByCounting = VU.toList . removeByCounting . VU.fromList+
Biobase/Secondary/Vienna.hs view
@@ -10,6 +10,8 @@  module Biobase.Secondary.Vienna where +import Data.Array.Repa.Index+import Data.Array.Repa.Shape import Data.Ix import Data.Primitive.Types import Data.Tuple (swap)@@ -17,12 +19,11 @@ import qualified Data.Vector.Generic as VG import qualified Data.Vector.Generic.Mutable as VGM import qualified Data.Vector.Unboxed as VU+import Prelude as P -import Data.ExtShape+import Data.Array.Repa.ExtShape import Data.PrimitiveArray as PA-import Data.PrimitiveArray.Zero.Unboxed as PA-import "PrimitiveArray" Data.Array.Repa.Index-import "PrimitiveArray" Data.Array.Repa.Shape+import Data.PrimitiveArray.Zero as PA  import Biobase.Primary import Biobase.Primary.Bounds@@ -70,15 +71,14 @@   subDim (sh1:.ViennaPair n1) (sh2:.ViennaPair n2) = subDim sh1 sh2 :. (ViennaPair $ n1-n2)   rangeList (sh1:.ViennaPair n1) (sh2:.ViennaPair n2) = [sh:.ViennaPair n | sh <- rangeList sh1 sh2, n <- [n1 .. (n1+n2)]] -(vpNP:vpCG:vpGC:vpGU:vpUG:vpAU:vpUA:vpNS:vpUndefined:_) = map ViennaPair [0..]+(vpNP:vpCG:vpGC:vpGU:vpUG:vpAU:vpUA:vpNS:vpUndefined:_) = P.map ViennaPair [0..]  class MkViennaPair a where   mkViennaPair :: a -> ViennaPair   fromViennaPair :: ViennaPair -> a  instance MkViennaPair (Nuc,Nuc) where-  mkViennaPair (b1,b2) = viennaPairTable `PA.index` (Z:.b1:.b2)-  {-+  mkViennaPair (b1,b2) -- = viennaPairTable `PA.index` (Z:.b1:.b2)     | b1==nC&&b2==nG = vpCG     | b1==nG&&b2==nC = vpGC     | b1==nG&&b2==nU = vpGU@@ -86,7 +86,6 @@     | b1==nA&&b2==nU = vpAU     | b1==nU&&b2==nA = vpUA     | otherwise = vpNS-  -}   {-# INLINE mkViennaPair #-}   fromViennaPair p     | p==vpCG = (nC,nG)@@ -98,7 +97,18 @@     | otherwise = error "non-standard pairs can't be backcasted"   {-# INLINE fromViennaPair #-} -viennaPairTable :: Arr0 (Z:.Nuc:.Nuc) ViennaPair+isViennaPair :: Nuc -> Nuc -> Bool+isViennaPair a b = f a b where+  f l r =  l==nC && r==nG+        || l==nG && r==nC+        || l==nA && r==nU+        || l==nU && r==nA+        || l==nG && r==nU+        || l==nU && r==nG+  {-# INLINE f #-}+{-# INLINE isViennaPair #-}++viennaPairTable :: Unboxed (Z:.Nuc:.Nuc) ViennaPair viennaPairTable = fromAssocs (Z:.nN:.nN) (Z:.nU:.nU) vpNS   [ (Z:.nC:.nG , vpCG)   , (Z:.nG:.nC , vpGC)@@ -144,7 +154,7 @@     | x ==' ' = readsPrec p (y:xs)     | Just n <- (x:y:[]) `lookup` s2p = [(n,xs)]     | otherwise = []-    where s2p = (map swap pairToString)+    where s2p = (P.map swap pairToString)   @@ -168,3 +178,4 @@ cguaP = [vpCG..vpUA] cgnsP = [vpCG..vpNS] pairToString = [(vpCG,"CG"),(vpGC,"GC"),(vpUA,"UA"),(vpAU,"AU"),(vpGU,"GU"),(vpUG,"UG"),(vpNS,"NS"),(vpNP,"NP")]+
BiobaseXNA.cabal view
@@ -1,9 +1,9 @@ name:           BiobaseXNA-version:        0.6.3.1+version:        0.7.0.0 author:         Christian Hoener zu Siederdissen maintainer:     choener@tbi.univie.ac.at homepage:       http://www.tbi.univie.ac.at/~choener/-copyright:      Christian Hoener zu Siederdissen, 2011-2012+copyright:      Christian Hoener zu Siederdissen, 2011-2013 category:       Bioinformatics synopsis:       Efficient RNA/DNA representations license:        GPL-3@@ -13,11 +13,14 @@ cabal-version:  >= 1.6.0 description:                 This is a base library for bioinformatics with emphasis on RNA-                and DNA primary structure and related tools. Provided are-                efficient encodings for short sequences, as required by RNA-                folding tools. Extended RNA secondary structures can be-                represented as well.+                and DNA primary structure.                 .+                Provided are efficient encodings for short sequences, as+                required by RNA folding tools. Extended RNA secondary+                structures can be represented as well.+                .+                .+                .                 Contains data from:                 .                 Frequency and isostericity of RNA base pairs@@ -30,8 +33,12 @@                 .                 .                 .-                New in 0.6.2.0+                new in 0.7                 .+                * updated to PrimitiveArray >= 0.5+                .+                new in 0.6.2.0+                .                 * Updated to PrimitiveArray >= 0.2.0.0  extra-source-files:@@ -41,15 +48,16 @@ library   build-depends:     base >3 && <5,-    bytestring     >= 0.9           ,+    bytestring     >= 0.10          ,     containers     >= 0.4           ,     csv            == 0.1.2         ,-    file-embed     >= 0.0.4         ,-    primitive      >= 0.4           ,+    file-embed     >= 0.0.4.7       ,+    primitive      >= 0.5           ,+    repa           >= 3.2           ,     text           >= 0.11          ,     tuple          >= 0.2           ,     vector         >= 0.10          ,-    PrimitiveArray >= 0.4.0.1+    PrimitiveArray >= 0.5    exposed-modules:     Biobase.Primary