packages feed

flowsim 0.3.4 → 0.3.5

raw patch · 3 files changed

+15/−9 lines, 3 files

Files

flowsim.cabal view
@@ -1,5 +1,5 @@ Name:           flowsim-Version:        0.3.4+Version:        0.3.5 License:        GPL-2 License-file:   COPYING Cabal-Version:  >= 1.6
src/Duplicator.hs view
@@ -4,21 +4,27 @@  import System.IO import System.Environment (getArgs)-+import Control.Monad (when) import Bio.Sequence.Fasta+ import Statistics  main :: IO () main = do   args <- getArgs-  case args of [p] -> hReadFasta stdin >>= evalRandIO . dup (read p) >>= hWriteFasta stdout-               _ -> error "Usage: duplicator pr\n   where pr is the probability of recursively duplicating a sequence"+  case args of +       (p:rest) -> do+           let p' = read p +               i = case rest of [] -> hReadFasta stdin +                                [f] -> readFasta f+           when (p'<=0 || p'>=1) $ error "Probability should be between 0 and 1"+           i >>= evalRandIO . dup p' >>= hWriteFasta stdout+       _ -> error "Usage: duplicator pr\n   where pr is the (recursive) probability of duplicating a sequence"  dup :: RandomGen g => Double -> [Sequence] -> Rand g [Sequence] dup p (x:xs) = do   r <- getRandomR (0,1)-  if r < p -    then dup p (x:x:xs)-    else do ys <- dup p xs-            return (x:ys)+  ys <- if r < p then dup p (x:xs)+        else dup p xs+  return (x:ys) dup _ [] = return []         
src/Version.hs view
@@ -1,4 +1,4 @@ module Version where  version :: String-version = " v0.3.3, copyright 2010-2012 Ketil Malde"+version = " v0.3.5, copyright 2010-2012 Ketil Malde"