packages feed

BiobaseFR3D 0.1.3.0 → 0.2.2.0

raw patch · 3 files changed

+78/−13 lines, 3 filesdep +containersdep ~BiobaseXNAPVP ok

version bump matches the API change (PVP)

Dependencies added: containers

Dependency ranges changed: BiobaseXNA

API changes (from Hackage documentation)

- Biobase.FR3D: LinFR3D :: ByteString -> ByteString -> [ExtPairIdx] -> LinFR3D
+ Biobase.FR3D: LinFR3D :: ByteString -> ByteString -> [(ExtPairIdx, ExtPair)] -> LinFR3D
- Biobase.FR3D: pairs :: LinFR3D -> [ExtPairIdx]
+ Biobase.FR3D: pairs :: LinFR3D -> [(ExtPairIdx, ExtPair)]

Files

Biobase/FR3D.hs view
@@ -14,6 +14,7 @@ import Data.ByteString.Char8 as BS import Data.List as L +import Biobase.Primary import Biobase.Secondary  @@ -47,7 +48,7 @@ data LinFR3D = LinFR3D   { pdbID :: ByteString   , sequence :: ByteString-  , pairs :: [ExtPairIdx] -- [(Int,Int,String)] -- TODO String -> CWW ?!+  , pairs :: [(ExtPairIdx,ExtPair)] -- we keep the ExtPair information as provided by the non-linearized FR3D data   } deriving (Show)  -- | The default format is a bit unwieldy; Linearization assumes that all@@ -62,10 +63,13 @@   } where       trans = snd $ L.mapAccumL ( \acc (x,y) -> (acc + 1 + BS.length y, (x,acc))                                 ) 0 chains-      f Basepair{..} =  ( ( maybe (-1) (\v -> v+seqpos1) $ L.lookup chain1 trans-                          , maybe (-1) (\v -> v+seqpos2) $ L.lookup chain2 trans )-                        , interaction-                        )+      f Basepair{..} =  (pi,p) where+        pi = ( ( maybe (-1) (\v -> v+seqpos1) $ L.lookup chain1 trans+               , maybe (-1) (\v -> v+seqpos2) $ L.lookup chain2 trans+               )+             , interaction+             )+        p = ( (mkNuc nucleotide1, mkNuc nucleotide2), interaction )  class RemoveDuplicatePairs a where   removeDuplicatePairs :: a -> a@@ -75,5 +79,44 @@     f Basepair{..} = (chain1,seqpos1) < (chain2,seqpos2)  instance RemoveDuplicatePairs LinFR3D where-  removeDuplicatePairs x@LinFR3D{..} = x{pairs = L.filter f pairs} where+  removeDuplicatePairs x@LinFR3D{..} = x{pairs = L.filter (f.fst) pairs} where     f ((x,y),_) = x<y++++-- ** Checking data structures++-- | Checks an FR3D file for correctness. Returns either a Left on errors or+-- Right FR3D if correct.+--+-- TODO chain existence check++checkFR3D fr3d@FR3D{..}+  | L.null xs = Right fr3d+  | otherwise = Left (fr3d,xs)+  where+    xs = [ x+         | x <- basepairs+         , let Just c1 = lookup (chain1 x) chains+         , let Just c2 = lookup (chain2 x) chains+         ,  seqpos1 x < 0+         || seqpos2 x < 0+         || seqpos1 x >= BS.length c1+         || seqpos2 x >= BS.length c2+         || nucleotide1 x /= c1 `BS.index` seqpos1 x+         || nucleotide2 x /= c2 `BS.index` seqpos2 x+         ]++checkLinFR3D linfr3d@LinFR3D{..}+  | L.null xs = Right linfr3d+  | otherwise = Left (linfr3d,xs)+  where+    xs = [ x+         | x@(pi,p) <- pairs+         ,  baseL pi < 0+         || baseR pi < 0+         || baseL pi >= BS.length sequence+         || baseR pi >= BS.length sequence+         || mkNuc (sequence `BS.index` baseL pi) /= baseL p+         || mkNuc (sequence `BS.index` baseR pi) /= baseR p+         ]
Biobase/FR3D/Import.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE RecordWildCards #-} {-# LANGUAGE OverloadedStrings #-}  -- | Importing of FR3D data. Both "basepairs" and "near interactions" are@@ -14,6 +15,7 @@ import Data.Iteratee.ListLike as I import Data.List as L import Data.Maybe+import qualified Data.Map as M import System.FilePath.Find as F  import Biobase.Secondary@@ -30,15 +32,26 @@   f = do     I.head -- fr3d header     I.head -- sequence header-    cs <- I.break ((/="#") . BS.take 1)+    cs' <- I.break ((/="#") . BS.take 1)     I.head -- basepairs header     xs <- stream2list -- and all basepairs+    let cs = L.map (second (BS.drop 1) . BS.span isAlphaNum . BS.drop 2) $ cs'     return FR3D       { pdbid = maybe "" (BS.take 4) $ listToMaybe xs-      , chains = L.map (second (BS.drop 1) . BS.span isAlphaNum . BS.drop 2) cs-      , basepairs = L.map bs2basepair $ xs+      , chains = cs+      , basepairs = {- L.map (fixSeqpos cs) . -} L.map bs2basepair $ xs       } +{-+ - This would be for fixing sequence position information, but it seems that+ - FR3D does not store this info consistently...+ -+fixSeqpos :: [(ByteString,ByteString)] -> Basepair -> Basepair+fixSeqpos cs bp@Basepair{..} = bp{seqpos1 = seqpos1 - cl M.! chain1, seqpos2 = seqpos2 - cl M.! chain2} where+  cl = M.fromList . snd . L.mapAccumL f 0 $ cs+  f acc x = (acc + BS.length (snd x), (fst x, acc))+-}+ -- | Helper function turning a bytestring line into a basepair entry  bs2basepair :: ByteString -> Basepair@@ -49,11 +62,11 @@     , nucleotide1 = BS.head $ ws!!2     , pdbnumber1  = maybe (-1) fst . readInt $ ws!!3     , chain1      = ws!!4-    , seqpos1     = maybe (-1) fst . readInt $ ws!!5+    , seqpos1     = maybe (-1) (subtract 1 . fst) . readInt $ ws!!5     , nucleotide2 = BS.head $ ws!!6     , pdbnumber2  = maybe (-1) fst . readInt $ ws!!7     , chain2      = ws!!8-    , seqpos2     = maybe (-1) fst . readInt $ ws!!9+    , seqpos2     = maybe (-1) (subtract 1 . fst) . readInt $ ws!!9     }   where ws = BS.words s 
BiobaseFR3D.cabal view
@@ -1,5 +1,5 @@ name:           BiobaseFR3D-version:        0.1.3.0+version:        0.2.2.0 author:         Christian Hoener zu Siederdissen maintainer:     choener@tbi.univie.ac.at homepage:       http://www.tbi.univie.ac.at/~choener/@@ -23,6 +23,14 @@                 in RNA 3D Structures, Michael Sarver; Craig L. Zirbel; Jesse                 Stombaugh; Ali Mokdad; Neocles B. Leontis. /Journal of                 Mathematical Biology/ (2008) 56:215–252.+                .+                Changes since any 0.1.*:+                .+                * Zero-based indexing (FR3D is one-based!) for sequence+                  positions. We do not change the nucleotide PDB number.+                .+                * Some sanity checks, a number of FR3D files fall through at+                  this and need to be checked for consistency   @@ -32,9 +40,10 @@   build-depends:     base >3 && <5,     bytestring,+    containers,     filemanip,     iteratee,-    BiobaseXNA >= 0.5.4+    BiobaseXNA >= 0.5.5    exposed-modules:     Biobase.FR3D