packages feed

biohazard 1.0.3 → 1.0.4

raw patch · 3 files changed

+17/−30 lines, 3 filesdep ~basedep ~containersdep ~stmPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: base, containers, stm

API changes (from Hackage documentation)

- Bio.Iteratee.Builder: instance GHC.Show.Show Bio.Iteratee.Builder.BB

Files

biohazard.cabal view
@@ -1,5 +1,5 @@ Name:                biohazard-Version:             1.0.3+Version:             1.0.4 Synopsis:            bioinformatics support library Description:         This is a collection of modules I separated from                      various bioinformatics tools.@@ -15,7 +15,7 @@  Cabal-version:       >= 1.10 Build-type:          Simple-Tested-with:         GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.1, GHC == 8.4.1+Tested-with:         GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.1, GHC == 8.4.1, GHC == 8.4.3  source-repository head   type:     git
src/Bio/Bam/Writer.hs view
@@ -214,6 +214,6 @@   where     store_loop bb tk = do (bb',tk') <- fillBuffer bb tk                           case tk' of TkEnd -> return (bb',tk')-                                      _     -> do bb'' <- expandBuffer 0 bb'+                                      _     -> do bb'' <- expandBuffer (128*1024) bb'                                                   store_loop bb'' tk' 
src/Bio/Iteratee/Builder.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE ForeignFunctionInterface #-} -- | Buffer builder to assemble Bgzf blocks.  The idea is to serialize--- stuff (BAM and BCF) into a buffer, then Bgzf chunks from the buffer.+-- stuff (BAM and BCF) into a buffer, then bgzf chunks from the buffer. -- We use a large buffer, and we always make sure there is plenty of -- space in it (to avoid redundant checks). @@ -24,10 +24,10 @@  import qualified Data.ByteString            as B import qualified Data.ByteString.Unsafe     as B-import qualified Data.Vector.Storable       as VS+import qualified Data.Vector.Storable       as V  -- | We manage a large buffer (multiple megabytes), of which we fill an--- initial portion.  We remeber the size, the used part, and two marks+-- initial portion.  We remember the size, the used part, and two marks -- where we later fill in sizes for the length prefixed BAM or BCF -- records.  We move the buffer down when we yield a piece downstream, -- and when we run out of space, we simply move to a new buffer.@@ -41,9 +41,6 @@              , mark   :: {-# UNPACK #-} !Int            -- offset of mark              , mark2  :: {-# UNPACK #-} !Int }          -- offset of mark2 -instance Show BB where-    show bb = show (size bb, off bb, used bb, mark bb, mark2 bb)- -- | Things we are able to encode.  Taking inspiration from -- binary-serialise-cbor, we define these as a lazy list-like thing and -- consume it in a interpreter.@@ -70,7 +67,7 @@ data BclSpecialType = BclNucsBin | BclNucsWide | BclNucsAsc | BclNucsAscRev | BclQualsBin | BclQualsAsc | BclQualsAscRev  data BclArgs = BclArgs BclSpecialType-                       {-# UNPACK #-} !(VS.Vector Word8)  -- bcl matrix+                       {-# UNPACK #-} !(V.Vector Word8)   -- bcl matrix                        {-# UNPACK #-} !Int                -- stride                        {-# UNPACK #-} !Int                -- first cycle                        {-# UNPACK #-} !Int                -- last cycle@@ -80,8 +77,9 @@ newBuffer :: Int -> IO BB newBuffer sz = mallocForeignPtrBytes sz >>= \ar -> return $ BB ar sz 0 0 maxBound maxBound --- | Creates a new buffer, copying the content from an old one, with--- higher capacity.+-- | Creates a new buffer, copying the active content from an old one,+-- with higher capacity.  The size of the new buffer is twice the free+-- space in the old buffer, but at least @minsz@. expandBuffer :: Int -> BB -> IO BB expandBuffer minsz b = do     let sz' = max (2 * (size b - used b)) minsz@@ -116,29 +114,17 @@         | size bb0 - used bb0 < 1024 = expandBuffer (1024*1024) bb0 `ioBind` \bb' -> go' bb' k (appEndo f TkEnd)         | otherwise                  =                                               go' bb0 k (appEndo f TkEnd) -    -- we arrive here because we ran out of buffer space, so we always expand it.-    go1 bb0 k tk = expandBuffer (1024*1024) bb0 `ioBind` \bb' -> go' bb' k tk-     go' bb0 k tk = fillBuffer bb0 tk `ioBind` \(bb',tk') -> flush_blocks tk' bb' k -     -- We can flush anything that is between 'off' and the lower of 'mark'     -- and 'used'.  When done, we bump 'off'.     flush_blocks tk bb k         | min (mark bb) (used bb) - off bb < maxBlockSize =             case tk of TkEnd -> liftI $ go bb k-                       _     -> expandBuffer (2 * size bb) bb `ioBind` \bb' ->-                                go1 bb' k tk--        | otherwise = flush_blocks1 tk bb k--    flush_blocks1 tk bb k-        | min (mark bb) (used bb) - off bb < maxBlockSize =-            case tk of TkEnd -> liftI $ go bb k-                       _     -> go1 bb k tk-+                       _     -> -- we arrive here because we ran out of buffer space, so we expand it.+                                expandBuffer (1024*1024) bb `ioBind` \bb' -> go' bb' k tk         | otherwise =-            eneeCheckIfDone (flush_blocks1 tk bb { off = off bb + maxBlockSize }) $+            eneeCheckIfDone (flush_blocks tk bb { off = off bb + maxBlockSize }) $                 k $ Chunk [compressChunk' lv (buffer bb) (off bb) maxBlockSize]      final_flush bb mx k@@ -180,8 +166,9 @@                                go_fast p bb (use + 8) tk'          TkString   s tk'-            -- Too big, can't handle.  We will get progressively bigger-            -- buffers and eventually handle it.+            -- Too big, can't handle.  By returning with unfinished+            -- business, we will get progressively bigger buffers and+            -- eventually handle it.             | B.length s > size bb - use -> return (bb { used = use },tk1)              | otherwise  -> do let ln = B.length s@@ -220,7 +207,7 @@ loop_bcl_special :: Ptr Word8 -> BclArgs -> IO Int loop_bcl_special p (BclArgs tp vec stride u v i) = -    VS.unsafeWith vec $ \q -> case tp of+    V.unsafeWith vec $ \q -> case tp of         BclNucsBin -> do             nuc_loop p stride (plusPtr q i) u v             return $ (v - u + 2) `div` 2