module Filter.Options
( FilterRowsArguments (..)
, FilterColsArguments (..)
, FilterRows
, FilterCols
, filterRowsArguments
, filterColsArguments
) where
import Control.Applicative
import Control.Monad.Logger
import Control.Monad.Trans.Reader
import Options.Applicative
import Tools
import ELynx.Data.Alphabet.Alphabet
data FilterRowsArguments = FilterRowsArguments
{ frAlphabet :: Alphabet
, frInFile :: Maybe FilePath
, frLonger :: Maybe Int
, frShorter :: Maybe Int
, frStandard :: Bool }
data FilterColsArguments = FilterColsArguments
{ fcAlphabet :: Alphabet
, fcInFile :: Maybe FilePath
, fcStandard :: Maybe Double }
type FilterRows = LoggingT (ReaderT FilterRowsArguments IO)
type FilterCols = LoggingT (ReaderT FilterColsArguments IO)
filterRowsArguments :: Parser FilterRowsArguments
filterRowsArguments = FilterRowsArguments
<$> alphabetOpt
<*> optional inFileArg
<*> filterLongerThanOpt
<*> filterShorterThanOpt
<*> filterStandardChars
filterLongerThanOpt :: Parser (Maybe Int)
filterLongerThanOpt = optional $ option auto $
long "longer-than" <>
metavar "LENGTH" <>
help "Only keep sequences longer than LENGTH"
filterShorterThanOpt :: Parser (Maybe Int)
filterShorterThanOpt = optional $ option auto $
long "shorter-than" <>
metavar "LENGTH" <>
help "Only keep sequences shorter than LENGTH"
filterStandardChars :: Parser Bool
filterStandardChars = switch $
long "standard-characters" <>
help "Only keep sequences containing at least one standard (i.e., non-IUPAC) character"
filterColsArguments :: Parser FilterColsArguments
filterColsArguments = FilterColsArguments
<$> alphabetOpt
<*> optional inFileArg
<*> filterStandardOpt
filterStandardOpt :: Parser (Maybe Double)
filterStandardOpt = optional $ option auto $
long "standard-chars" <>
metavar "DOUBLE" <>
help "Keep columns with a proportion standard (non-IUPAC) characters larger than DOUBLE in [0,1]"
inFileArg :: Parser FilePath
inFileArg = strArgument $
metavar "INPUT-FILE" <>
help "Read sequences from INPUT-FILE"