packages feed

flower 0.6.5 → 0.7

raw patch · 6 files changed

+67/−28 lines, 6 filesdep ~bio

Dependency ranges changed: bio

Files

flower.cabal view
@@ -1,5 +1,5 @@ Name:           flower-Version:        0.6.5+Version:        0.7 License:        GPL Cabal-Version:  >= 1.6 Author:         Ketil Malde@@ -22,10 +22,11 @@                 invalid region.  This was likely a one-time bug in the 454 software, so this program                 is probably not so useful any more. -HomePage:       http://blog.malde.org/index.php/flower/+HomePage:       http://biohaskell.org/Applications/Flower -- Source-Repository: http//malde.org/~ketil/biohaskell/flower Build-Type:     Simple Tested-with:    GHC==6.8.3, GHC==6.12.1+Extra-Source-Files:  test.sh  -- Data-files:     README Executable     flower@@ -33,23 +34,26 @@     Other-Modules:  Print, Metrics, Options, Fork     Hs-Source-Dirs: src     Ghc-Options:    -Wall -threaded-    Build-Depends:  bio >= 0.4.8, base >=3 && <5, array >= 0.1, bytestring >= 0.9.1, binary == 0.4.*, random, cmdargs >= 0.5, containers, mtl+    Build-Depends:  bio >= 0.4.9, base >=3 && <5, array >= 0.1, bytestring >= 0.9.1, binary == 0.4.*, random, cmdargs >= 0.5, containers, mtl  Executable     flowselect     Main-Is:        FlowSelect.hs     Other-Modules:  Metrics     Hs-Source-Dirs: src     Ghc-Options:    -Wall+    Build-Depends:  bio >= 0.4.9, random, base >= 3 && < 5     Extensions:     ExistentialQuantification  Executable     frecover     Main-Is:        FRecover.hs     Hs-Source-Dirs: src+    Build-Depends:  bio >= 0.4.9, base >= 3 && < 5     Ghc-Options:    -Wall  Executable     frename     Main-Is:        FRename.hs     Hs-Source-Dirs: src+    Build-Depends:  bio >= 0.4.9, base >= 3 && < 5, bytestring >= 0.9.1     Ghc-Options:    -Wall  Executable     flowt@@ -59,4 +63,5 @@       Ghc-Options:     -Wall -fno-warn-unused-do-bind     else       Ghc-Options:     -Wall+    Build-Depends:  bio >= 0.4.9, base >= 3 && < 5, cmdargs >= 0.5, containers, bytestring >= 0.9.1     Extensions:     DeriveDataTypeable
src/Flower.hs view
@@ -1,10 +1,11 @@ -- FlowEr - FLOWgram ExtractoR- module Main (main) where  import Bio.Sequence.SFF+import Bio.Sequence.SFF_filters import Bio.Sequence.Fasta import Bio.Sequence.FastQ (hWriteSangerQ,hWriteIllumina)+import Bio.Sequence.SeqData (seqdata) -- import Bio.Util (countIO)  import Print@@ -54,7 +55,8 @@       on (O.text o)      (\h -> mapM_ (hPutStrLn h . dumpText . tr . rs) =<< inp)       on (O.fastq o)     (\h -> mapM_ (hWriteSangerQ h . map rbToSequence . tr . rs) =<< inp)       on (O.illumina o)  (\h -> mapM_ (hWriteIllumina h . map rbToSequence . tr . rs) =<< inp)-      on (O.summarize o) (\h -> mapM_ (L1.hPut h . summarize . tr . rs) =<< inp)+      on (O.summarize o) (\h -> mapM_ (L1.hPut h . summarize . tr . rs) =<< inp)  -- should we trim?+      on (O.filters o)   (\h -> mapM_ (L1.hPut h . sum_filters . rs) =<< inp)       on (O.histogram o) (\h -> mapM_ (\(SFF c r) -> hPutStrLn h . showHist . histogram (B.unpack $ flow c) . map flowgram . tr $ r) =<< inp)       on (O.flowgram o)  (\h -> mapM_ (\(SFF c r) -> L1.hPut h . L1.fromChunks . intersperse (B.pack "\n") . concatMap (showread c) $ r) =<< inp) @@ -69,7 +71,7 @@ mkTrimmer :: Opts -> Trimmer mkTrimmer o = case (O.trimKey o, O.trim o) of         (True,True) -> error "Please specify only one of --trim and --trimkey"-        (True,False) -> \r -> trimFromTo 4 (num_bases $ read_header r) r+        (True,False) -> \r -> trimFromTo 5 (num_bases $ read_header r) r         (False,True) -> trim         (False,False) -> id @@ -86,7 +88,7 @@                           , clip,     show (clip_qual_left rh), sp, show (clip_qual_right rh), nl                           , flows,    B.unpack $ B.unwords $ map fi $ flowgram r, nl                           , idx,      unwords $ map show $ cumulative_index' r, nl-                          , base,     L.unpack (masked_bases' r), nl+                          , base,     L.unpack (seqdata . rbToSequence $ r), nl                           , qual,     unwords $ map show $ L1.unpack (quality r), nl                              ]           where rh = read_header r@@ -103,18 +105,6 @@                 formatRN (ReadName (yr,mo,dy) (h,m,s) r' x y) =                    printf "%4d-%02d-%02d %02d:%02d:%02d R%d (%d,%d)" yr mo dy h m s r' x y ---- Get the bases, but lower case masked bases.  Also in biolib's SFF.hs (sans prime),--- so this is only for backwards compatibility with biolib <= 0.4.6.-masked_bases' :: ReadBlock -> SeqData-masked_bases' rb = let-  l = fromIntegral $ clip_qual_left $ read_header rb-  r = fromIntegral $ clip_qual_right $ read_header rb-  s = bases rb-  in L.concat [ L.map toLower $ L.take (l-1) s-              , L.take r (L.drop (l-1) s)-              , L.map toLower $ L.drop r s]- cumulative_index' :: ReadBlock -> [Int] cumulative_index' = scanl1 (+) . map fromIntegral . B1.unpack . flow_index @@ -133,7 +123,7 @@ -- ----------------------------------------------------------  -- | Summarize each read on one line of output-summarize :: [ReadBlock] -> L1.ByteString+summarize :: [ReadBlock] -> L.ByteString summarize rs = do   L.concat [ L.pack "# name........\tdate......\ttime....\treg\ttrim_l\ttrim_r\tx_loc\ty_loc\tlen\tK2\ttrimK2\tncount\tavgQ\ttravgQ\n"            , toLazyByteString . mconcat . map sum1 $ rs]@@ -163,6 +153,25 @@                         , fromByteString (fi $ quals $ flowgram r), fromByteString (fi $ quals $ flowgram tr)                         , putInt (n_count r)                         , avg_qual $ quality r, avg_qual $ quality tr]) ++ [nl]++-- ----------------------------------------------------------+-- The --filters option, summarize filters+-- ----------------------------------------------------------+sum_filters ::  [ReadBlock] -> L1.ByteString+sum_filters rs = toLazyByteString $ mconcat (header:map sumf1 rs)+  where +    header = fromByteString $ B.pack "# name..... \tlength \tl_trim \tr_trim \tE K D M L\tSig Q20 Adp\n"+    sumf1 rb = let+      rh = read_header rb+      rn = read_name rh+      nb = fromIntegral $ num_bases rh+      (cl,cr) = (fromIntegral $ clip_qual_left rh, fromIntegral $ clip_qual_right rh)+      dfs = mconcat $ intersperse (char ' ') $+            map (\f -> if f rb then char '+' else char ' ') +            [discard_empty, discard_key "tcag", discard_dots 0.05, discard_mixed, discard_length 186]+      tfs = mconcat $ intersperse (char ' ') $ map (\f -> putInt3 (f rb))+            [sigint, qual20 10, find_primer rapid_adapter]+      in mconcat (intersperse (char '\t') [fromByteString rn, putInt nb, putInt cl, putInt cr, dfs, tfs]++[char '\n'])  -- ---------------------------------------------------------- -- The -F option: Output the sequence of flows, one flow per line
src/Flowt.hs view
@@ -30,7 +30,7 @@ splitRes (EndWith e) = ([],e)  trim :: ReadBlock -> ReadBlock-trim = id -- trimFromTo 4 10000 <- this trims to last base called position!+trim = id -- trimFromTo 4 10000 <- this trims to last base called position! (use trimKey?)  data Options = O { thresh :: Double                  , fplen  :: Int@@ -46,7 +46,7 @@            , clusters  = True &= help "output complete clusters"            , input  = def  &= args &= typFile }          &= program "flowt"-         &= summary "flowt v0.6 - filter out reads from duplicate clones in 454 sequencing."+         &= summary "flowt v0.7 - filter out reads from duplicate clones in 454 sequencing."  vlog :: Bool -> String -> IO () vlog v s = when v (hPutStr stderr s >> hFlush stderr)
src/Options.hs view
@@ -10,6 +10,7 @@             { trimKey :: Bool             , trim    :: Bool             , summarize :: Maybe FilePath+            , filters :: Maybe FilePath             , info    :: Maybe FilePath             , fasta   :: Maybe FilePath             , fqual  :: Maybe FilePath@@ -29,6 +30,7 @@   { trimKey = False &= help "Trim only the TCAG key sequence"   , trim    = False &= help "Trim quality using clipping information"     &= name "t"   , summarize = def   &= help "Output per sequence summary information"   &= typFile &= optdef+  , filters   = def   &= help "Output filtering information"              &= typFile &= optdef   , info    = def   &= help "Output brief overview of the contents"       &= typFile &= optdef   , fasta   = def   &= help "Output FASTA-formatted sequences"            &= typFile &= name "f" &= optdef   , fqual    = def   &= help "Output phred qualities"                      &= typFile &= name "q" &= optdef@@ -39,14 +41,14 @@   , text      = def &= help "Output SFF information as text (default)"    &= typFile &= name "T" &= optdef   , inputs  = def &= args &= typFile   } -  &= summary "flower v0.6.5 - Extract information from SFF files" +  &= summary "flower v0.7 - Extract information from SFF files"    &= program "flower"  getArgs :: IO Opts getArgs = do   o <- cmdArgs opts    -- print o-  let outs = filter isJust $ map ($o) [summarize,info,fasta,fqual,fastq,illumina,flowgram,histogram,text]+  let outs = filter isJust $ map ($o) [summarize,filters,info,fasta,fqual,fastq,illumina,flowgram,histogram,text]   when ((length $ filter (==Just "-") $ outs) > 1) $ error "If you specify more than one output format, you need to specify output files"   let o' = if null outs then o { text = Just "-" } else o   return o'
src/Print.hs view
@@ -1,7 +1,7 @@ module Print      (      Builder, toLazyByteString, mconcat, fromByteString, char-    , putInt, putInt2, putDate, putTime, putFix+    , putInt, putInt2, putInt3, putDate, putTime, putFix     ) where   import Data.Binary.Builder@@ -23,15 +23,17 @@ -- zero padded ints  putInt2 :: Int -> Builder-putInt2 x = fromByteString (int2s!x)+putInt2 x | x<100 = fromByteString (int2s!x)+          | otherwise = fromByteString (pack "xx")  putInt3 :: Int -> Builder-putInt3 x = fromByteString (int3s!x)+putInt3 x | x<1000 = fromByteString (int3s!x)+          | otherwise = fromByteString (pack "xxx")  ints, int2s, int3s :: Array Int ByteString ints  = listArray (0,999) [pack (show i) | i <- [0..999::Int]] int2s = listArray (0,99) (map (pack . ('0':) . show) [0..9::Int]++[pack (show i) | i <- [10..99::Int]])-int3s = listArray (0,999) (map (pack . ('0':) . ('0':) . show) [0..9::Int] ++ map (pack . ('0':) . show ) [10..99::Int] ++ map (pack . show) [100..999::Int])+int3s = listArray (0,999) (map (pack . (' ':) . (' ':) . show) [0..9::Int] ++ map (pack . (' ':) . show ) [10..99::Int] ++ map (pack . show) [100..999::Int])  putDate :: Int -> Int -> Int -> Builder putDate y m d = mconcat [putInt y, dash, putInt2 m, dash, putInt2 d]
+ test.sh view
@@ -0,0 +1,21 @@+#!/bin/bash+#+# This script downloads test data, and checks that flower produces consistent+# output.+get_data(){+	wget http://malde.org/~ketil/test.sff+	wget http://malde.org/~ketil/test.md5+}++cabal configure+cabal build++get_data++# run tests:++dist/build/flower/flower -f=test.fasta -q=test.qual -Q=test.fastq -T=test.txt test.sff+md5sum test.{fasta,qual,fastq,txt} > new.md5++diff -u test.md5 new.md5 && echo "Test succeessful" || echo "TEST FAILED"+