packages feed

fasta 0.6.0.0 → 0.6.1.0

raw patch · 3 files changed

+61/−8 lines, 3 filesdep +foldldep +lensdep +pipes-groupdep ~basePVP ok

version bump matches the API change (PVP)

Dependencies added: foldl, lens, pipes-group, pipes-text

Dependency ranges changed: base

API changes (from Hackage documentation)

+ Data.Fasta.Text.Lazy.Parse: pipesFasta :: MonadIO m => Producer Text m () -> Producer FastaSequence m ()
+ Data.Fasta.Text.Parse: pipesFasta :: MonadIO m => Producer Text m () -> Producer FastaSequence m ()

Files

fasta.cabal view
@@ -10,7 +10,7 @@ -- PVP summary:      +-+------- breaking API changes --                   | | +----- non-breaking API additions --                   | | | +--- code changes with no API change-version:             0.6.0.0+version:             0.6.1.0  -- A short (one-line) description of the package. synopsis:            A simple, mindless parser for fasta files.@@ -69,7 +69,11 @@                        text >=1.1.0 && <1.4,                        containers >= 0.5 && <0.6,                        split >= 0.2 && <0.3,-                       pipes >= 4.1 && < 4.2+                       pipes >= 4.1 && < 4.2,+                       pipes-group >= 1.0 && < 1.1,+                       pipes-text >= 0.0 && < 0.1,+                       lens >= 4.9 && < 4.10,+                       foldl >= 1.0 && < 1.1      -- Directories containing source files.   hs-source-dirs:      src
src/Data/Fasta/Text/Lazy/Parse.hs view
@@ -10,6 +10,7 @@  module Data.Fasta.Text.Lazy.Parse ( parseFasta                                   , parseCLIPFasta+                                  , pipesFasta                                   , removeNs                                   , removeN                                   , removeCLIPNs ) where@@ -20,8 +21,17 @@ import Text.Parsec import Text.Parsec.Text.Lazy import qualified Data.Map.Strict as Map+import qualified Data.Text as ST import qualified Data.Text.Lazy as T +-- Cabal+import Pipes+import qualified Pipes.Prelude as P+import qualified Pipes.Text as PT+import qualified Pipes.Group as PG+import Control.Lens (view)+import Control.Foldl (purely, mconcat)+ -- Local import Data.Fasta.Text.Lazy.Types @@ -80,6 +90,26 @@   where     eToV (Right x) = x     eToV (Left x)  = error ("Unable to parse fasta file\n" ++ show x)++-- | Parse a standard fasta file into strict text sequences for pipes. This is+-- the highly recommeded way of parsing, as it is computationally fast and+-- uses memory based on line length+pipesFasta :: (MonadIO m)+           => Producer ST.Text m ()+           -> Producer FastaSequence m ()+pipesFasta p = purely PG.folds mconcat ( view (PT.splits '>')+                                       . PT.drop (1 :: Int)+                                       $ p )+           >-> P.map toFasta+  where+    toFasta x = FastaSequence { fastaHeader = T.fromChunks+                                            . take 1+                                            . ST.lines+                                            $ x+                              , fastaSeq    = T.fromChunks+                                            . tail+                                            . ST.lines+                                            $ x }  -- | Remove Ns from a collection of sequences removeNs :: [FastaSequence] -> [FastaSequence]
src/Data/Fasta/Text/Parse.hs view
@@ -10,18 +10,26 @@  module Data.Fasta.Text.Parse ( parseFasta                              , parseCLIPFasta+                             , pipesFasta                              , removeNs                              , removeN                              , removeCLIPNs ) where  -- Built-in import Data.Char-import Control.Monad (void) import Text.Parsec import Text.Parsec.Text import qualified Data.Map.Strict as Map import qualified Data.Text as T +-- Cabal+import Pipes+import qualified Pipes.Prelude as P+import qualified Pipes.Text as PT+import qualified Pipes.Group as PG+import Control.Lens (view)+import Control.Foldl (purely, mconcat)+ -- Local import Data.Fasta.Text.Types @@ -29,8 +37,7 @@ eol = choice . map (try . string) $ ["\n\r", "\r\n", "\n", "\r"]  eoe :: Parsec T.Text u ()-eoe  = do-    lookAhead (void $ char '>') <|> eof+eoe = lookAhead (void $ char '>') <|> eof  fasta :: Parsec T.Text u FastaSequence fasta = do@@ -82,17 +89,29 @@     eToV (Right x) = x     eToV (Left x)  = error ("Unable to parse fasta file\n" ++ show x) +-- | Parse a standard fasta file into strict text sequences for pipes. This is+-- the highly recommeded way of parsing, as it is computationally fast and+-- uses memory based on line length+pipesFasta :: (MonadIO m) => Producer T.Text m () -> Producer FastaSequence m ()+pipesFasta p = purely PG.folds mconcat ( view (PT.splits '>')+                                       . PT.drop (1 :: Int)+                                       $ p )+           >-> P.map toFasta+  where+    toFasta x = FastaSequence { fastaHeader = head . T.lines $ x+                              , fastaSeq    = T.concat . tail . T.lines $ x }+ -- | Remove Ns from a collection of sequences removeNs :: [FastaSequence] -> [FastaSequence] removeNs = map (\x -> x { fastaSeq = noN . fastaSeq $ x })   where-    noN = T.map (\y -> if (y /= 'N' && y /= 'n') then y else '-')+    noN = T.map (\y -> if y /= 'N' && y /= 'n' then y else '-')  -- | Remove Ns from a sequence removeN :: FastaSequence -> FastaSequence removeN x = x { fastaSeq = noN . fastaSeq $ x }   where-    noN = T.map (\y -> if (y /= 'N' && y /= 'n') then y else '-')+    noN = T.map (\y -> if y /= 'N' && y /= 'n' then y else '-')  -- | Remove Ns from a collection of CLIP fasta sequences removeCLIPNs :: CloneMap -> CloneMap@@ -100,4 +119,4 @@   where     remove   ((!x, !y), !z)    = ((x, newSeq y), map newSeq z)     newSeq !x = x { fastaSeq = noN . fastaSeq $ x }-    noN = T.map (\y -> if (y /= 'N' && y /= 'n') then y else '-')+    noN = T.map (\y -> if y /= 'N' && y /= 'n' then y else '-')