packages feed

dephd-0.1.4: src/FakeQual.hs

{-| This program reads a Fasta file, and generates a corresponding qual
    file with made-up quality values.  Useful when you want to combine 
    sequences with and without quality in the same analysis.
-}

{-# Language DeriveDataTypeable #-}

module Main where

import System.Console.CmdArgs
import qualified Data.ByteString.Lazy as B
import System.IO (stdin,stdout)
import Bio.Sequence

version = "fakequal v0.1.4, copyright 2010 Ketil Malde"

data Opts = O { qval :: Int, input :: [FilePath] } 
          deriving (Show,Data,Typeable)

modes = mode $ O { qval = 15 &= text "value to use for quality" & typ "Int" & flag "q"
                 , input = def &= args & typFile }
                 &= prog "fakequal" 
                 & text "generate fake quality information for fasta files"

main = do
  cf <- cmdArgs version [modes]
  -- print cf
  ss <- if null (input cf) then hReadFasta stdin
        else concat `fmap` mapM readFasta (input cf)
  hWriteQual stdout (map (addqual $ qval cf) ss)

addqual :: Int -> Sequence t -> Sequence t
addqual q (Seq h s _) = Seq h s (Just $ B.map (const $ fromIntegral q) s)