packages feed

estreps 0.3 → 0.3.1

raw patch · 4 files changed

+10/−10 lines, 4 filesdep ~basedep ~bio

Dependency ranges changed: base, bio

Files

estreps.cabal view
@@ -1,5 +1,5 @@ Name:                estreps-Version:             0.3+Version:             0.3.1 License:             GPL License-file:        LICENSE Author:              Ketil Malde@@ -24,7 +24,7 @@ Executable rselect            Hs-source-dirs: src            Main-Is:        RSelect.lhs-           Build-Depends:  base>3, random, containers, bio>=0.3.3, bytestring+           Build-Depends:  base>3 && <4, random, containers, bio>=0.4, bytestring            ghc-options:    -Wall            Other-Modules:  Unigene 
src/RSelect.lhs view
@@ -49,7 +49,7 @@   n `seq` hPutStrLn stderr ("N = "++show n++", M = "++show m)   mapM_ (\o -> putStrLn "# cluster delimiter" >> hWriteFasta stdout o)  out -maybe_reverse :: Bool -> Sequence -> Sequence+maybe_reverse :: Bool -> Sequence Nuc -> Sequence Nuc maybe_reverse b = if b then revcompl else id  -- | choose elements according to a list of deltas
src/Repeats.lhs view
@@ -66,7 +66,7 @@                       return (k,rs,rl)  -- build clusters from [[Label]] and [Seq Label sdata]-clusters :: [[String]] -> [Sequence] -> [[Sequence]]+clusters :: [[String]] -> [Sequence a] -> [[Sequence a]] clusters labels seqs = map (map mylookup) labels     where smap = M.fromListWith (error "duplicate sequences in input!") $                  map (\s -> (B.dropWhile (=='>') $ seqlabel s,s)) seqs@@ -75,7 +75,7 @@                          Just x  -> x  -- extract words from clusters-debruijn :: Integral w => Int -> [Sequence] -> S.Set w+debruijn :: Integral w => Int -> [Sequence a] -> S.Set w debruijn k = foldl1' S.union . map (S.fromList . keys k . seqdata) -- slightly faster than: "foldl' (flip S.insert) S.empty . concatMap (keys k)" @@ -95,7 +95,7 @@ toMap = M.fromList . map (\x -> (x,1)) . S.toList  -- given word length k, calculate repeats from clusters-repeats :: Integral w => Int -> [[Sequence]] -> [(w,Int)]+repeats :: Integral w => Int -> [[Sequence a]] -> [(w,Int)] repeats k = filter ((>1).snd) . M.toList . freqs . map (debruijn k)  \end{code}
src/Unigene.hs view
@@ -7,19 +7,19 @@ import System.IO import qualified Data.ByteString.Lazy.Char8 as B -import Bio.Sequence (Sequence(..))+import Bio.Sequence (Sequence(..), Nuc, Unknown, castToNuc) import Bio.Sequence.Fasta (mkSeqs) import Data.List (groupBy)  -- Isn't this lazy?-ugRead :: FilePath -> IO [[Sequence]]+ugRead :: FilePath -> IO [[Sequence Nuc]] ugRead f = do   s <- B.readFile f   let ls = dropWhile B.null $ B.lines $ s   when (B.head (head ls) /= '#') (hPutStrLn stderr ("'"++f++"' does not look like Unigene format"))-  return (clusters $ ls)+  return $ map (map castToNuc) $ clusters $ ls -clusters :: [B.ByteString] -> [[Sequence]]+clusters :: [B.ByteString] -> [[Sequence Unknown]] clusters (l:ls) = if B.head l == '#'                    then map (mkSeqs . tail) $ groupBy (const (('#' /=) . B.head)) $ filter (not . B.null) (l:ls)                   else [mkSeqs (l:ls)]