flower 0.4 → 0.5
raw patch · 2 files changed
+49/−2 lines, 2 files
Files
- flower.cabal +1/−1
- src/Flower.hs +48/−1
flower.cabal view
@@ -1,5 +1,5 @@ Name: flower-Version: 0.4+Version: 0.5 License: GPL Cabal-Version: >= 1.6 Author: Ketil Malde
src/Flower.hs view
@@ -9,6 +9,7 @@ import Bio.Util (countIO) import Print+import Text.Printf import System.IO (stdout) import System.Environment (getArgs)@@ -18,6 +19,7 @@ import Data.ByteString.Char8 (pack,unpack,ByteString) import qualified Data.ByteString.Char8 as B import qualified Data.ByteString as B1+import qualified Data.ByteString.Lazy.Char8 as L import qualified Data.ByteString.Lazy as L1 import Data.Array.Unboxed@@ -47,7 +49,7 @@ ["-H"] -> putStr . sffToHistogramClip ["-i"] -> putStr . getHeader ["-s"] -> summarize-+ [] -> dumpText _ -> error ("Usage: flower -[f|h|H|i|q|r|R|s] <file.sff> [<file2.sff> ..]\n" ++" -r output reads in Fasta format\n" ++" -R output reads in Fasta format with associated .qual\n"@@ -64,6 +66,51 @@ -- trim keys if they match, eliminate reads that don't. trim_keys _ [] = [] trim_keys ch (s:ss) = maybe id ((:) . id) (trimKey ch s) $ trim_keys ch ss++-- ------------------------------------------------------------+-- No option - dump as text format+-- ------------------------------------------------------------+dumpText :: SFF -> IO ()+dumpText (SFF _ rs) = putStr . concat . map toText $ rs+ where toText :: ReadBlock -> String+ toText r = concat [ gt, B.unpack (read_name rh), nl+ , maybe "" ((\s->info++s++nl) . formatRN) $ decodeReadName (read_name rh)+ , let (lf,rt) = (clip_adapter_right rh, clip_adapter_left rh) + in if lf /= 0 || rt /= 0 then adapter ++ show lf ++ sp++ show rt else ""+ , clip, show (clip_qual_left rh), sp, show (clip_qual_right rh), nl+ , flows, unwords $ map show $ flowgram r, nl+ , index, unwords $ map show $ cumulative_index' r, nl+ , base, L.unpack (masked_bases' r), nl+ , qual, unwords $ map show $ L1.unpack (quality r), nl+ ]+ where rh = read_header r+ gt = ">"+ nl = "\n"+ sp = " "+ info = " Info: \t"+ clip = " Clip: \t"+ adapter = " Adap: \t"+ flows = " Flows:\t"+ index = " Index:\t"+ base = " Bases:\t"+ qual = " Quals:\t"+ 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 -- ------------------------------------------------------------ -- The -i option: Print header info