biosff 0.2 → 0.3.1
raw patch · 4 files changed
+24/−11 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Bio.Sequence.SFF_filters: avg :: Integral a => [a] -> Double
+ Bio.Sequence.SFF_filters: clipFlows :: ReadBlock -> Int -> ReadBlock
+ Bio.Sequence.SFF_filters: clipSeq :: ReadBlock -> Int -> ReadBlock
+ Bio.Sequence.SFF_filters: discard_dots :: Double -> DiscardFilter
+ Bio.Sequence.SFF_filters: discard_empty :: DiscardFilter
+ Bio.Sequence.SFF_filters: discard_key :: String -> DiscardFilter
+ Bio.Sequence.SFF_filters: discard_length :: Int -> DiscardFilter
+ Bio.Sequence.SFF_filters: discard_mixed :: DiscardFilter
+ Bio.Sequence.SFF_filters: dlength :: [a] -> Double
+ Bio.Sequence.SFF_filters: find_primer :: String -> ReadBlock -> Int
+ Bio.Sequence.SFF_filters: flx_linker :: [Char]
+ Bio.Sequence.SFF_filters: qual20 :: Int -> ReadBlock -> Int
+ Bio.Sequence.SFF_filters: rapid_adapter :: [Char]
+ Bio.Sequence.SFF_filters: rna_adapter :: [Char]
+ Bio.Sequence.SFF_filters: rna_adapter2 :: [Char]
+ Bio.Sequence.SFF_filters: rna_adapter3 :: [Char]
+ Bio.Sequence.SFF_filters: sigint :: ReadBlock -> Int
+ Bio.Sequence.SFF_filters: ti_adapter_b :: [Char]
+ Bio.Sequence.SFF_filters: ti_linker :: [Char]
+ Bio.Sequence.SFF_filters: trim_primer :: String -> TrimFilter
+ Bio.Sequence.SFF_filters: trim_qual20 :: Int -> TrimFilter
+ Bio.Sequence.SFF_filters: trim_sigint :: TrimFilter
+ Bio.Sequence.SFF_filters: type DiscardFilter = ReadBlock -> Bool
+ Bio.Sequence.SFF_filters: type TrimFilter = ReadBlock -> ReadBlock
Files
- biosff.cabal +3/−3
- src/Bio/Sequence/SFF.hs +7/−5
- src/Flower/Main.hs +10/−2
- src/Flower/Options.hs +4/−1
biosff.cabal view
@@ -1,5 +1,5 @@ Name: biosff-Version: 0.2+Version: 0.3.1 Synopsis: Library and executables for working with SFF files Description: The library contains the functionality for reading and writing SFF files (sequencing data from 454 and Ion Torrent). It duplicates@@ -23,8 +23,8 @@ Tag: 0.2 Library- Exposed-modules: Bio.Sequence.SFF- Other-modules: Bio.Sequence.SFF_name, Bio.Sequence.SFF_filters+ Exposed-modules: Bio.Sequence.SFF, Bio.Sequence.SFF_filters+ Other-modules: Bio.Sequence.SFF_name Build-depends: base >= 3 && < 5, biocore >= 0.1, binary, bytestring, array Hs-Source-Dirs: src Ghc-Options: -Wall
src/Bio/Sequence/SFF.hs view
@@ -189,11 +189,13 @@ -- | Write 'ReadBlock's to a file handle. writeReads :: Handle -> Int -> [ReadBlock] -> IO Int32 writeReads _ _ [] = return 0-writeReads h i (r:rs) = do- LBC.hPut h $ encode (RBI i r)- c <- writeReads h i rs- return $! (c+1)-+writeReads h i xs = go 0 xs+ where go c (r:rs) = do+ LBC.hPut h $ encode (RBI i r)+ let c' = c+1+ c' `seq` go c' rs+ go c [] = return c+ data RBI = RBI Int ReadBlock -- | Wrapper for ReadBlocks since they need additional information
src/Flower/Main.hs view
@@ -20,7 +20,8 @@ import qualified Data.ByteString.Lazy as L1 import Data.Array.Unboxed-import Data.Array.ST+import Data.Array.Unsafe -- unsafeFreeze is deprecated in D.A.ST+import Data.Array.ST hiding (unsafeFreeze) import Control.Monad.ST import Control.Monad.State @@ -52,7 +53,7 @@ on (O.fastq o) (\h -> mapM_ (L1.hPut h . L1.concat . map toFastQ . 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 9999 ["A","C","G","T"] . histogram (B.unpack $ flow c) . map flowgram . tr $ r) =<< inp)+ on (O.histogram o) (\h -> mapM_ (\(SFF c r) -> hPutStrLn h . (case O.plot o of Just str -> showPlot str 1000; Nothing -> showHist 9999) ["A","C","G","T"] . histogram (B.unpack $ flow c) . map flowgram . tr $ r) =<< inp) on (O.histpos o) (\h -> mapM_ (\(SFF _ r) -> hPutStrLn h . showHist 549 [] . histpos 549 . 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) @@ -239,6 +240,13 @@ g' <- unsafeFreeze g t' <- unsafeFreeze t return [a',c',g',t']++-- ouput a histogram in gnuplot format+showPlot :: String -> Int -> [String] -> [Hist] -> String+showPlot cmds mx hd hs = "set style data lines\nset logscale y\nset xlabel 'Flow value'\nset ylabel 'Count'\nset xtic 1\n\n"++cmds+ ++"\n\nplot "+ ++ concat (intersperse "," [" '-' ti "++show c | c <- hd]) ++ "\n"+ ++ unlines [ unlines [showFFloat (Just 2) (fromIntegral sc/100::Double) ""++"\t"++show (h!sc) | sc <- [0..fromIntegral mx]] ++ "e\n" | h <- hs] showHist :: Int -> [String] -> [Hist] -> String showHist mx hd hs = (if not (null hd) then concat (intersperse "\t" ("Score":hd)) ++ "\n" else "") ++
src/Flower/Options.hs view
@@ -4,11 +4,12 @@ import System.Console.CmdArgs import Control.Monad (when)-import Data.Maybe (isJust)+import Data.Maybe (isJust, isNothing) data Opts = Opts { trimKey :: Bool , trim :: Bool+ , plot :: Maybe String , summarize :: Maybe FilePath , filters :: Maybe FilePath , info :: Maybe FilePath@@ -38,6 +39,7 @@ , flowgram = def &= help "Output flowgram information in tabular form" &= typFile &= name "F" &= optdef , histogram = def &= help "Output histogram of flow values by nucleotide" &= typFile &= name "h" &= optdef , histpos = def &= help "Output histogram of flow values by flow cycle" &= typFile &= name "H" &= optdef+ , plot = Nothing &= help "Output gnuplot script for visualization" &= opt "" , text = def &= help "Output SFF information as text (default)" &= typFile &= name "T" &= optdef , inputs = def &= args &= typFile } @@ -50,5 +52,6 @@ -- print o let outs = filter isJust $ map ($o) [summarize,filters,info,fasta,fqual,fastq,flowgram,histogram,histpos,text] when ((length $ filter (==Just "-") $ outs) > 1) $ error "If you specify more than one output format, you need to specify output files"+ when (isJust (plot o) && isNothing (histogram o)) $ error "Gnuplot output only supported for histograms" let o' = if null outs then o { text = Just "-" } else o return o'