{-# LANGUAGE DeriveGeneric #-}
module TLynx.Shuffle.Options
( ShuffleArguments (..),
shuffleArguments,
)
where
import Data.Aeson
import ELynx.Tools.Options
import ELynx.Tools.Reproduction
import GHC.Generics
import Options.Applicative
import TLynx.Parsers
data ShuffleArguments = ShuffleArguments
{ ShuffleArguments -> NewickFormat
nwFormat :: NewickFormat,
ShuffleArguments -> Int
nReplicates :: Int,
ShuffleArguments -> FilePath
inFile :: FilePath,
ShuffleArguments -> SeedOpt
argsSeed :: SeedOpt
}
deriving (ShuffleArguments -> ShuffleArguments -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ShuffleArguments -> ShuffleArguments -> Bool
$c/= :: ShuffleArguments -> ShuffleArguments -> Bool
== :: ShuffleArguments -> ShuffleArguments -> Bool
$c== :: ShuffleArguments -> ShuffleArguments -> Bool
Eq, Int -> ShuffleArguments -> ShowS
[ShuffleArguments] -> ShowS
ShuffleArguments -> FilePath
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [ShuffleArguments] -> ShowS
$cshowList :: [ShuffleArguments] -> ShowS
show :: ShuffleArguments -> FilePath
$cshow :: ShuffleArguments -> FilePath
showsPrec :: Int -> ShuffleArguments -> ShowS
$cshowsPrec :: Int -> ShuffleArguments -> ShowS
Show, forall x. Rep ShuffleArguments x -> ShuffleArguments
forall x. ShuffleArguments -> Rep ShuffleArguments x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ShuffleArguments x -> ShuffleArguments
$cfrom :: forall x. ShuffleArguments -> Rep ShuffleArguments x
Generic)
instance Reproducible ShuffleArguments where
inFiles :: ShuffleArguments -> [FilePath]
inFiles = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShuffleArguments -> FilePath
inFile
outSuffixes :: ShuffleArguments -> [FilePath]
outSuffixes ShuffleArguments
_ = [FilePath
".tree"]
getSeed :: ShuffleArguments -> Maybe SeedOpt
getSeed = forall a. a -> Maybe a
Just forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShuffleArguments -> SeedOpt
argsSeed
setSeed :: ShuffleArguments -> SeedOpt -> ShuffleArguments
setSeed ShuffleArguments
a SeedOpt
s = ShuffleArguments
a {argsSeed :: SeedOpt
argsSeed = SeedOpt
s}
parser :: Parser ShuffleArguments
parser = Parser ShuffleArguments
shuffleArguments
cmdName :: FilePath
cmdName = FilePath
"shuffle"
cmdDsc :: [FilePath]
cmdDsc =
[ FilePath
"Shuffle a phylogenetic tree (keep coalescent times, but shuffle topology and leaves)."
]
instance FromJSON ShuffleArguments
instance ToJSON ShuffleArguments
shuffleArguments :: Parser ShuffleArguments
shuffleArguments :: Parser ShuffleArguments
shuffleArguments = NewickFormat -> Int -> FilePath -> SeedOpt -> ShuffleArguments
ShuffleArguments forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser NewickFormat
newickFormat forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Int
n forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser FilePath
file forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser SeedOpt
seedOpt
n :: Parser Int
n :: Parser Int
n =
forall a. ReadM a -> Mod OptionFields a -> Parser a
option forall a. Read a => ReadM a
auto forall a b. (a -> b) -> a -> b
$
forall (f :: * -> *) a. HasName f => FilePath -> Mod f a
long FilePath
"replicates"
forall a. Semigroup a => a -> a -> a
<> forall (f :: * -> *) a. HasName f => Char -> Mod f a
short Char
'n'
forall a. Semigroup a => a -> a -> a
<> forall (f :: * -> *) a. HasMetavar f => FilePath -> Mod f a
metavar FilePath
"N"
forall a. Semigroup a => a -> a -> a
<> forall (f :: * -> *) a. HasValue f => a -> Mod f a
value Int
1
forall a. Semigroup a => a -> a -> a
<> forall (f :: * -> *) a. FilePath -> Mod f a
help
FilePath
"Number of trees to generate"
file :: Parser FilePath
file :: Parser FilePath
file =
forall s. IsString s => Mod ArgumentFields s -> Parser s
strArgument forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a. HasMetavar f => FilePath -> Mod f a
metavar FilePath
"TREE-FILE" forall a. Semigroup a => a -> a -> a
<> forall (f :: * -> *) a. FilePath -> Mod f a
help FilePath
"File containing a Newick tree"