elynx 0.2.2 → 0.3.0
raw patch · 5 files changed
+258/−436 lines, 5 filesdep ~aesondep ~basedep ~bytestring
Dependency ranges changed: aeson, base, bytestring, elynx-tools, optparse-applicative, slynx, tlynx
Files
- ChangeLog.md +11/−0
- README.md +68/−274
- app/Main.hs +105/−94
- app/Options.hs +33/−35
- elynx.cabal +41/−33
ChangeLog.md view
@@ -2,6 +2,17 @@ # Changelog for ELynx +## Version 0.3.1; in development+++## Version 0.3.0++- **`elynx-nexus`:** library to import and export Nexus files.+- **`elynx-tree`:** major refactor and big cleanup; use rose trees with branch+ labels.+- **`elynx-tree`:** provide zippers.++ ## Version 0.2.2 - Validation and repetition of previous analyses is finally possible with the
README.md view
@@ -2,9 +2,11 @@ # The ELynx Suite -Version: 0.2.2.+Version: 0.3.0. Reproducible evolution made easy. +<p align="center"><img src="https://travis-ci.org/dschrempf/elynx.svg?branch=master"/></p>+ A Haskell library and tool set for computational biology. The goal of ELynx is reproducible research. Evolutionary sequences and phylogenetic trees can be read, viewed, modified and simulated. The command line with all arguments is@@ -12,11 +14,12 @@ sums so that validation of past analyses is possible without the need to recompute the result. -The Elynx Suite consists of four library packages and three executables providing-a range of sub commands.+The Elynx Suite consists of library packages and executables providing a range+of sub commands. The library packages are: +- **elynx-nexus:** Nexus file support. - **elynx-markov:** Simulate multi sequence alignments along phylogenetic trees. - **elynx-seq:** Handle evolutionary sequences and multi sequence alignments. - **elynx-tools:** Tools for the provided executables.@@ -43,7 +46,7 @@ 2. Clone the ELynx repository. - git clone clone https://github.com/dschrempf/elynx+ git clone https://github.com/dschrempf/elynx 3. Navigate to the newly created `elynx` folder and build the binaries. This will take a while.@@ -62,15 +65,34 @@ [PATH](https://en.wikipedia.org/wiki/PATH_(variable)) environment variable. Then, they can be used directly. +# Documentation++Documentation is available on [Hackage](https://hackage.haskell.org/).++Libraries:++- [elynx-nexus](https://hackage.haskell.org/package/elynx-nexus)+- [elynx-markov](https://hackage.haskell.org/package/elynx-markov)+- [elynx-seq](https://hackage.haskell.org/package/elynx-seq)+- [elynx-tools](https://hackage.haskell.org/package/elynx-tools)+- [elynx-tree](https://hackage.haskell.org/package/elynx-tree)++Executables:++- [elynx](https://hackage.haskell.org/package/elynx)+- [slynx](https://hackage.haskell.org/package/slynx)+- [tlynx](https://hackage.haskell.org/package/tlynx)++ # SLynx Handle evolutionary sequences. - slynx --help+ slynx --help | head -n -16 - ELynx Suite version 0.2.1.+ ELynx Suite version 0.3.0. Developed by Dominik Schrempf.- Compiled on April 27, 2020, at 12:08 pm, UTC.+ Compiled on July 30, 2020, at 12:40 pm, UTC. Usage: slynx [-v|--verbosity VALUE] [-o|--output-file-basename NAME] [-f|--force] COMMAND@@ -95,6 +117,7 @@ sub-sample Sub-sample columns from multi sequence alignments. translate Translate from DNA to Protein or DNAX to ProteinX. + Available sequence file formats: - FASTA @@ -105,23 +128,6 @@ - Protein (amino acids) - ProteinX (amino acids; including gaps) - ProteinS (amino acids; including gaps, and translation stops)- - ProteinI (amino acids; including gaps, translation stops, and IUPAC codes)- - ELynx- ------ A Haskell library and tool set for computational biology. The goal of ELynx is- reproducible research. Evolutionary sequences and phylogenetic trees can be- read, viewed, modified and simulated. The command line with all arguments is- logged consistently, and automatically. Data integrity is verified using SHA256- sums so that validation of past analyses is possible without the need to- recompute the result.- - slynx Analyze, modify, and simulate evolutionary sequences.- tlynx Analyze, modify, and simulate phylogenetic trees.- elynx Validate and redo past analyses.- - Get help for sub commands:- slynx examine --help ## Concatenate@@ -130,9 +136,9 @@ slynx concatenate --help - ELynx Suite version 0.2.1.+ ELynx Suite version 0.3.0. Developed by Dominik Schrempf.- Compiled on April 27, 2020, at 12:08 pm, UTC.+ Compiled on July 30, 2020, at 12:40 pm, UTC. Usage: slynx concatenate (-a|--alphabet NAME) INPUT-FILE Concatenate sequences found in input files.@@ -143,23 +149,6 @@ -a,--alphabet NAME Specify alphabet type NAME INPUT-FILE Read sequences from INPUT-FILE -h,--help Show this help text- - - ELynx- ------ A Haskell library and tool set for computational biology. The goal of ELynx is- reproducible research. Evolutionary sequences and phylogenetic trees can be- read, viewed, modified and simulated. The command line with all arguments is- logged consistently, and automatically. Data integrity is verified using SHA256- sums so that validation of past analyses is possible without the need to- recompute the result.- - slynx Analyze, modify, and simulate evolutionary sequences.- tlynx Analyze, modify, and simulate phylogenetic trees.- elynx Validate and redo past analyses.- - Get help for sub commands:- slynx examine --help ## Examine@@ -168,9 +157,9 @@ slynx examine --help - ELynx Suite version 0.2.1.+ ELynx Suite version 0.3.0. Developed by Dominik Schrempf.- Compiled on April 27, 2020, at 12:08 pm, UTC.+ Compiled on July 30, 2020, at 12:40 pm, UTC. Usage: slynx examine (-a|--alphabet NAME) INPUT-FILE [--per-site] Examine sequences. If data is a multi sequence alignment, additionally analyze columns.@@ -182,23 +171,6 @@ INPUT-FILE Read sequences from INPUT-FILE --per-site Report per site summary statistics -h,--help Show this help text- - - ELynx- ------ A Haskell library and tool set for computational biology. The goal of ELynx is- reproducible research. Evolutionary sequences and phylogenetic trees can be- read, viewed, modified and simulated. The command line with all arguments is- logged consistently, and automatically. Data integrity is verified using SHA256- sums so that validation of past analyses is possible without the need to- recompute the result.- - slynx Analyze, modify, and simulate evolutionary sequences.- tlynx Analyze, modify, and simulate phylogenetic trees.- elynx Validate and redo past analyses.- - Get help for sub commands:- slynx examine --help ## Filter@@ -207,9 +179,9 @@ slynx filter-rows --help - ELynx Suite version 0.2.1.+ ELynx Suite version 0.3.0. Developed by Dominik Schrempf.- Compiled on April 27, 2020, at 12:08 pm, UTC.+ Compiled on July 30, 2020, at 12:40 pm, UTC. Usage: slynx filter-rows (-a|--alphabet NAME) INPUT-FILE [--longer-than LENGTH] [--shorter-than LENGTH] [--standard-characters]@@ -225,31 +197,14 @@ --standard-characters Only keep sequences containing at least one standard (i.e., non-IUPAC) character -h,--help Show this help text- - - ELynx- ------ A Haskell library and tool set for computational biology. The goal of ELynx is- reproducible research. Evolutionary sequences and phylogenetic trees can be- read, viewed, modified and simulated. The command line with all arguments is- logged consistently, and automatically. Data integrity is verified using SHA256- sums so that validation of past analyses is possible without the need to- recompute the result.- - slynx Analyze, modify, and simulate evolutionary sequences.- tlynx Analyze, modify, and simulate phylogenetic trees.- elynx Validate and redo past analyses.- - Get help for sub commands:- slynx examine --help Filter columns of multi sequence alignments with `filter-columns`. slynx filter-columns --help - ELynx Suite version 0.2.1.+ ELynx Suite version 0.3.0. Developed by Dominik Schrempf.- Compiled on April 27, 2020, at 12:08 pm, UTC.+ Compiled on July 30, 2020, at 12:40 pm, UTC. Usage: slynx filter-columns (-a|--alphabet NAME) INPUT-FILE [--standard-chars DOUBLE]@@ -263,23 +218,6 @@ --standard-chars DOUBLE Keep columns with a proportion standard (non-IUPAC) characters larger than DOUBLE in [0,1] -h,--help Show this help text- - - ELynx- ------ A Haskell library and tool set for computational biology. The goal of ELynx is- reproducible research. Evolutionary sequences and phylogenetic trees can be- read, viewed, modified and simulated. The command line with all arguments is- logged consistently, and automatically. Data integrity is verified using SHA256- sums so that validation of past analyses is possible without the need to- recompute the result.- - slynx Analyze, modify, and simulate evolutionary sequences.- tlynx Analyze, modify, and simulate phylogenetic trees.- elynx Validate and redo past analyses.- - Get help for sub commands:- slynx examine --help ## Simulate@@ -288,9 +226,9 @@ slynx simulate --help - ELynx Suite version 0.2.1.+ ELynx Suite version 0.3.0. Developed by Dominik Schrempf.- Compiled on April 27, 2020, at 12:08 pm, UTC.+ Compiled on July 30, 2020, at 12:40 pm, UTC. Usage: slynx simulate (-t|--tree-file Name) [-s|--substitution-model MODEL] [-m|--mixture-model MODEL] [-e|--edm-file NAME] @@ -352,27 +290,13 @@ where XX is 10, 20, 30, 40, 50, or 60; CXX models, Quang et al., 2008. -m "EDM(EXCHANGEABILITIES)" Arbitrary empirical distribution mixture (EDM) models.- Stationary distributions have to be provided with the -e option.+ Stationary distributions have to be provided with the -e or -p option. For example, LG exchangeabilities with stationary distributions given in FILE. -m "EDM(LG-Custom)" -e FILE+ LG exchangeabilities with site profiles (Phylobayes) given in FILES.+ -m "EDM(LG-Custom)" -p FILES For special mixture models, mixture weights are optional.- - ELynx- ------ A Haskell library and tool set for computational biology. The goal of ELynx is- reproducible research. Evolutionary sequences and phylogenetic trees can be- read, viewed, modified and simulated. The command line with all arguments is- logged consistently, and automatically. Data integrity is verified using SHA256- sums so that validation of past analyses is possible without the need to- recompute the result.- - slynx Analyze, modify, and simulate evolutionary sequences.- tlynx Analyze, modify, and simulate phylogenetic trees.- elynx Validate and redo past analyses.- - Get help for sub commands:- slynx examine --help ## Sub-sample@@ -381,9 +305,9 @@ slynx sub-sample --help - ELynx Suite version 0.2.1.+ ELynx Suite version 0.3.0. Developed by Dominik Schrempf.- Compiled on April 27, 2020, at 12:08 pm, UTC.+ Compiled on July 30, 2020, at 12:40 pm, UTC. Usage: slynx sub-sample (-a|--alphabet NAME) INPUT-FILE (-n|--number-of-sites INT)@@ -403,22 +327,6 @@ -h,--help Show this help text Create a given number of multi sequence alignments, each of which contains a given number of random sites drawn from the original multi sequence alignment.- - ELynx- ------ A Haskell library and tool set for computational biology. The goal of ELynx is- reproducible research. Evolutionary sequences and phylogenetic trees can be- read, viewed, modified and simulated. The command line with all arguments is- logged consistently, and automatically. Data integrity is verified using SHA256- sums so that validation of past analyses is possible without the need to- recompute the result.- - slynx Analyze, modify, and simulate evolutionary sequences.- tlynx Analyze, modify, and simulate phylogenetic trees.- elynx Validate and redo past analyses.- - Get help for sub commands:- slynx examine --help ## Translate@@ -427,9 +335,9 @@ slynx translate --help - ELynx Suite version 0.2.1.+ ELynx Suite version 0.3.0. Developed by Dominik Schrempf.- Compiled on April 27, 2020, at 12:08 pm, UTC.+ Compiled on July 30, 2020, at 12:40 pm, UTC. Usage: slynx translate (-a|--alphabet NAME) INPUT-FILE (-r|--reading-frame INT) (-u|--universal-code CODE)@@ -444,34 +352,17 @@ -u,--universal-code CODE universal code; one of: Standard, VertebrateMitochondrial. -h,--help Show this help text- - - ELynx- ------ A Haskell library and tool set for computational biology. The goal of ELynx is- reproducible research. Evolutionary sequences and phylogenetic trees can be- read, viewed, modified and simulated. The command line with all arguments is- logged consistently, and automatically. Data integrity is verified using SHA256- sums so that validation of past analyses is possible without the need to- recompute the result.- - slynx Analyze, modify, and simulate evolutionary sequences.- tlynx Analyze, modify, and simulate phylogenetic trees.- elynx Validate and redo past analyses.- - Get help for sub commands:- slynx examine --help # TLynx Handle phylogenetic trees in Newick format. - tlynx --help+ tlynx --help | head -n -16 - ELynx Suite version 0.2.1.+ ELynx Suite version 0.3.0. Developed by Dominik Schrempf.- Compiled on April 27, 2020, at 12:08 pm, UTC.+ Compiled on July 30, 2020, at 12:40 pm, UTC. Usage: tlynx [-v|--verbosity VALUE] [-o|--output-file-basename NAME] [-f|--force] COMMAND@@ -496,26 +387,10 @@ shuffle Shuffle a phylogenetic tree (keep coalescent times, but shuffle topology and leaves). simulate Simulate phylogenetic trees using birth and death processes (see also the 'coalesce' command for simulations using the coalescent process). + Available tree file formats: - Newick Standard: Branch support values are stored in square brackets after branch lengths. - Newick IqTree: Branch support values are stored as node names after the closing bracket of forests.- - Newick RevBayes Key-value pairs is provided in square brackets after node names as well as branch lengths. XXX: Key value pairs are IGNORED at the moment.- - ELynx- ------ A Haskell library and tool set for computational biology. The goal of ELynx is- reproducible research. Evolutionary sequences and phylogenetic trees can be- read, viewed, modified and simulated. The command line with all arguments is- logged consistently, and automatically. Data integrity is verified using SHA256- sums so that validation of past analyses is possible without the need to- recompute the result.- - slynx Analyze, modify, and simulate evolutionary sequences.- tlynx Analyze, modify, and simulate phylogenetic trees.- elynx Validate and redo past analyses.- - Get help for sub commands:- slynx examine --help ## Compare@@ -524,12 +399,12 @@ tlynx compare --help - ELynx Suite version 0.2.1.+ ELynx Suite version 0.3.0. Developed by Dominik Schrempf.- Compiled on April 27, 2020, at 12:08 pm, UTC.+ Compiled on July 30, 2020, at 12:40 pm, UTC. Usage: tlynx compare [-n|--normalize] [-b|--bipartitions] [-t|--intersect] - [-f|--newick-format FORMAT] NAME+ [-f|--newick-format FORMAT] NAMES Compare two phylogenetic trees (compute distances and branch-wise differences). Available options:@@ -540,27 +415,11 @@ -t,--intersect Compare intersections; i.e., before comparison, drop leaves that are not present in the other tree -f,--newick-format FORMAT- Newick tree format; see 'tlynx- --help' (default: Standard)- NAME Tree file+ Newick tree format: Standard, IqTree, or RevBayes;+ default: Standard; for detailed help, see 'tlynx+ --help'+ NAMES Tree files -h,--help Show this help text- - - ELynx- ------ A Haskell library and tool set for computational biology. The goal of ELynx is- reproducible research. Evolutionary sequences and phylogenetic trees can be- read, viewed, modified and simulated. The command line with all arguments is- logged consistently, and automatically. Data integrity is verified using SHA256- sums so that validation of past analyses is possible without the need to- recompute the result.- - slynx Analyze, modify, and simulate evolutionary sequences.- tlynx Analyze, modify, and simulate phylogenetic trees.- elynx Validate and redo past analyses.- - Get help for sub commands:- slynx examine --help ## Examine@@ -569,9 +428,9 @@ tlynx examine --help - ELynx Suite version 0.2.1.+ ELynx Suite version 0.3.0. Developed by Dominik Schrempf.- Compiled on April 27, 2020, at 12:08 pm, UTC.+ Compiled on July 30, 2020, at 12:40 pm, UTC. Usage: tlynx examine INPUT-FILE [-f|--newick-format FORMAT] Compute summary statistics of phylogenetic trees.@@ -581,26 +440,10 @@ -V,--version Show version INPUT-FILE Read trees from INPUT-FILE -f,--newick-format FORMAT- Newick tree format; see 'tlynx- --help' (default: Standard)+ Newick tree format: Standard, IqTree, or RevBayes;+ default: Standard; for detailed help, see 'tlynx+ --help' -h,--help Show this help text- - - ELynx- ------ A Haskell library and tool set for computational biology. The goal of ELynx is- reproducible research. Evolutionary sequences and phylogenetic trees can be- read, viewed, modified and simulated. The command line with all arguments is- logged consistently, and automatically. Data integrity is verified using SHA256- sums so that validation of past analyses is possible without the need to- recompute the result.- - slynx Analyze, modify, and simulate evolutionary sequences.- tlynx Analyze, modify, and simulate phylogenetic trees.- elynx Validate and redo past analyses.- - Get help for sub commands:- slynx examine --help ## Simulate@@ -609,9 +452,9 @@ tlynx simulate --help - ELynx Suite version 0.2.1.+ ELynx Suite version 0.3.0. Developed by Dominik Schrempf.- Compiled on April 27, 2020, at 12:08 pm, UTC.+ Compiled on July 30, 2020, at 12:40 pm, UTC. Usage: tlynx simulate [-t|--nTrees INT] [-n|--nLeaves INT] [-H|--height DOUBLE] [-M|--condition-on-mrca] [-l|--lambda DOUBLE] @@ -640,33 +483,17 @@ Summary statistics only: only print (NumberOfExtantChildren BranchLength) pairs for each branch of each tree. The trees are separated by a newline character. Sub-sampling: simulate one big tree with n'=round(n/rho), n'>=n, leaves, and randomly sample sub-trees with n leaves. Hence, with rho=1.0, the same tree is reported over and over again. Gernhard, T. (2008). The conditioned reconstructed process. Journal of Theoretical Biology, 253(4), 769–778. http://doi.org/10.1016/j.jtbi.2008.04.005- - ELynx- ------ A Haskell library and tool set for computational biology. The goal of ELynx is- reproducible research. Evolutionary sequences and phylogenetic trees can be- read, viewed, modified and simulated. The command line with all arguments is- logged consistently, and automatically. Data integrity is verified using SHA256- sums so that validation of past analyses is possible without the need to- recompute the result.- - slynx Analyze, modify, and simulate evolutionary sequences.- tlynx Analyze, modify, and simulate phylogenetic trees.- elynx Validate and redo past analyses.- - Get help for sub commands:- slynx examine --help # ELynx Validate and (optionally) redo past ELynx analyses. - elynx --help+ elynx --help | head -n -16 - ELynx Suite version 0.2.1.+ ELynx Suite version 0.3.0. Developed by Dominik Schrempf.- Compiled on April 27, 2020, at 12:08 pm, UTC.+ Compiled on July 30, 2020, at 12:40 pm, UTC. Usage: elynx COMMAND Validate and redo past ELynx analyses@@ -678,37 +505,4 @@ Available commands: validate Validate an ELynx analysis redo Redo an ELynx analysis- - - ELynx- ------ A Haskell library and tool set for computational biology. The goal of ELynx is- reproducible research. Evolutionary sequences and phylogenetic trees can be- read, viewed, modified and simulated. The command line with all arguments is- logged consistently, and automatically. Data integrity is verified using SHA256- sums so that validation of past analyses is possible without the need to- recompute the result.- - slynx Analyze, modify, and simulate evolutionary sequences.- tlynx Analyze, modify, and simulate phylogenetic trees.- elynx Validate and redo past analyses.- - Get help for sub commands:- slynx examine --help---# Library documentation--Documentation of the libraries can be found on [Hackage](https://hackage.haskell.org/):--- [elynx-markov](https://hackage.haskell.org/package/elynx-markov)-- [elynx-seq](https://hackage.haskell.org/package/elynx-seq)-- [elynx-tools](https://hackage.haskell.org/package/elynx-tools)-- [elynx-tree](https://hackage.haskell.org/package/elynx-tree)--Documentation of the executables is also available:--- [elynx](https://hackage.haskell.org/package/elynx)-- [slynx](https://hackage.haskell.org/package/slynx)-- [tlynx](https://hackage.haskell.org/package/tlynx)
app/Main.hs view
@@ -1,45 +1,40 @@+{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-}-{-# LANGUAGE OverloadedStrings #-} -{- |-Module : Main-Description : Validate elynx file-Copyright : (c) Dominik Schrempf 2020-License : GPL-3.0-or-later--Maintainer : dominik.schrempf@gmail.com-Stability : unstable-Portability : portable--Creation date: Wed Apr 22 21:08:25 2020.---}-+-- |+-- Module : Main+-- Description : Validate elynx file+-- Copyright : (c) Dominik Schrempf 2020+-- License : GPL-3.0-or-later+--+-- Maintainer : dominik.schrempf@gmail.com+-- Stability : unstable+-- Portability : portable+--+-- Creation date: Wed Apr 22 21:08:25 2020. module Main- ( main+ ( main, ) where -import Control.Monad-import Data.Aeson-import qualified Data.Aeson.Types as J-import qualified Data.ByteString.Char8 as B-import Data.Maybe-import Data.Version ( Version )-import Options.Applicative-import System.Environment ( withProgName- , withArgs- )--import ELynx.Tools--import SLynx.SLynx ( slynx )-import qualified SLynx.Options as S-import TLynx.TLynx ( tlynx )-import qualified TLynx.Options as T--import Options+import Control.Monad+import Data.Aeson+import qualified Data.Aeson.Types as J+import qualified Data.ByteString.Char8 as B+import Data.Maybe+import Data.Version (Version)+import ELynx.Tools+import Options+import Options.Applicative+import qualified SLynx.Options as S+import SLynx.SLynx (slynx)+import System.Environment+ ( withArgs,+ withProgName,+ )+import qualified TLynx.Options as T+import TLynx.TLynx (tlynx) parseProgName :: Value -> J.Parser String parseProgName = withObject "progName" $ \o -> o .: "progName"@@ -51,71 +46,86 @@ parseAllR "tlynx" v = T <$> (parseJSON v :: J.Parser (Reproduction (Arguments T.CommandArguments))) parseAllR p _ =- let err = unlines- [ "Could not parse program name:"- , p- , "Do you use the correct ELynx version?"- ]- in error err+ let err =+ unlines+ [ "Could not parse program name:",+ p,+ "Do you use the correct ELynx version?"+ ]+ in error err parse :: Show a => [String] -> Parser a -> a-parse s p = fromMaybe- (error $ "parse: could not parse command line arguments: " ++ show s)- (getParseResult res)- where res = execParserPure defaultPrefs (info p briefDesc) s+parse s p =+ fromMaybe+ (error $ "parse: could not parse command line arguments: " ++ show s)+ (getParseResult res)+ where+ res = execParserPure defaultPrefs (info p briefDesc) s -- Does the command line fit the saved arguments?-checkArgs- :: forall a- . (Eq a, Show a, Reproducible a)- => Reproduction a- -> IO (Either String ())+checkArgs ::+ forall a.+ (Eq a, Show a, Reproducible a) =>+ Reproduction a ->+ IO (Either String ()) checkArgs s = do- let r = reproducible s- p = parser @a- as = argsStr s+ let r = reproducible s+ p = parser @a+ as = argsStr s res = parse as p- return $ if res /= reproducible s- then Left $ unlines- ["Command line string and command arguments do not fit:", show as, show r]- else Right ()+ return $+ if res /= reproducible s+ then+ Left $+ unlines+ ["Command line string and command arguments do not fit:", show as, show r]+ else Right () -- Does the file match the base 16 checksum? checkFile :: FilePath -> B.ByteString -> IO (Either String ()) checkFile fp h = do h' <- hashFile fp- return $ if h' == h- then Right ()- else Left $ unlines- [ "SHA256 sum does not match for a file:"- , fp ++ " has check sum " ++ B.unpack h'- , "Stored check sum is " ++ B.unpack h- ]+ return $+ if h' == h+ then Right ()+ else+ Left $+ unlines+ [ "SHA256 sum does not match for a file:",+ fp ++ " has check sum " ++ B.unpack h',+ "Stored check sum is " ++ B.unpack h+ ] checkVersion :: Version -> Either String ()-checkVersion v = if v == version- then Right ()- else Left $ unlines- [ "Versions differ:"- , "Version in ELynx reproduction file: " ++ show v- , "Version of current executable: " ++ show version- ]+checkVersion v =+ if v == version+ then Right ()+ else+ Left $+ unlines+ [ "Versions differ:",+ "Version in ELynx reproduction file: " ++ show v,+ "Version of current executable: " ++ show version+ ] checkHash :: Reproducible a => Reproduction a -> Either String ()-checkHash r = if h == h'- then Right ()- else Left $ unlines- [ "ELynx reproduction file has been changed:"- , "Hash saved in file: " ++ show h- , "Hash calculated from file: " ++ show h'- ]- where- h = rHash r- h' = Just $ getReproductionHash r+checkHash r =+ if h == h'+ then Right ()+ else+ Left $+ unlines+ [ "ELynx reproduction file has been changed:",+ "Hash saved in file: " ++ show h,+ "Hash calculated from file: " ++ show h'+ ]+ where+ h = rHash r+ h' = Just $ getReproductionHash r -- Check if command line arguments and files check sums are matching.-validate- :: (Eq a, Show a, Reproducible a) => Reproduction a -> IO (Either String ())+validate ::+ (Eq a, Show a, Reproducible a) => Reproduction a -> IO (Either String ()) validate s = do chA <- checkArgs s let chV = checkVersion (rVersion s)@@ -130,7 +140,7 @@ getAllR :: FilePath -> IO AllReproductions getAllR fp = do eELynx <- eitherDecodeFileStrict fp :: IO (Either String Value)- elynx <- case eELynx of+ elynx <- case eELynx of Left err -> do putStrLn "Failed decoding the ELynx reproduction file." putStrLn "The following error occurred:"@@ -155,7 +165,7 @@ runValidate a = do let fp = vElynxFile a repr <- getAllR fp- val <- validateAllReproductions repr+ val <- validateAllReproductions repr case val of Left err -> do putStrLn "Failed validating the ELynx reproduction file."@@ -166,23 +176,24 @@ runRedo :: RedoArguments -> IO () runRedo a = do let fp = rElynxFile a- let f = rForce a+ let f = rForce a when (f == Force False) $ do putStrLn "Validate ELynx reproduction file before reanalysis." putStrLn "Use the --force (-f) option to skip this test." runValidate (ValidateArguments fp) repr <- getAllR fp let as = getArgs repr- as' <- if "-f" `notElem` as && "--force" `notElem` as- then do- putStrLn- "Force option required to redo analysis. Add -f (force) to arguments."- return $ "-f" : as- else return as+ as' <-+ if "-f" `notElem` as && "--force" `notElem` as+ then do+ putStrLn+ "Force option required to redo analysis. Add -f (force) to arguments."+ return $ "-f" : as+ else return as withProgName (getProgName repr) $ withArgs as' $ redo repr setForce :: Arguments a -> Arguments a-setForce (Arguments g l) = Arguments g { forceReanalysis = Force True } l+setForce (Arguments g l) = Arguments g {forceReanalysis = Force True} l redo :: AllReproductions -> IO () redo (S x) = slynx $ setForce $ reproducible x@@ -193,4 +204,4 @@ g <- execParser commandArguments case g of Validate a -> runValidate a- Redo a -> runRedo a+ Redo a -> runRedo a
app/Options.hs view
@@ -1,40 +1,36 @@-{-# LANGUAGE DeriveGeneric #-}--{- |-Module : Options-Description : Options for elynx validation and redo sub commands-Copyright : (c) Dominik Schrempf 2020-License : GPL-3.0-or-later--Maintainer : dominik.schrempf@gmail.com-Stability : unstable-Portability : portable--Creation date: Thu Apr 23 19:17:17 2020.---}+{-# LANGUAGE DeriveGeneric #-} +-- |+-- Module : Options+-- Description : Options for elynx validation and redo sub commands+-- Copyright : (c) Dominik Schrempf 2020+-- License : GPL-3.0-or-later+--+-- Maintainer : dominik.schrempf@gmail.com+-- Stability : unstable+-- Portability : portable+--+-- Creation date: Thu Apr 23 19:17:17 2020. module Options- ( AllReproductions(..)- , getProgName- , getArgs- , ValidateArguments(..)- , RedoArguments(..)- , CommandArguments(..)- , commandArguments+ ( AllReproductions (..),+ getProgName,+ getArgs,+ ValidateArguments (..),+ RedoArguments (..),+ CommandArguments (..),+ commandArguments, ) where -import Options.Applicative--import ELynx.Tools--import qualified SLynx.Options as S-import qualified TLynx.Options as T+import ELynx.Tools+import Options.Applicative+import qualified SLynx.Options as S+import qualified TLynx.Options as T -- | Collect all reproductions in one data type.-data AllReproductions = S (Reproduction (Arguments S.CommandArguments))- | T (Reproduction (Arguments T.CommandArguments))+data AllReproductions+ = S (Reproduction (Arguments S.CommandArguments))+ | T (Reproduction (Arguments T.CommandArguments)) -- | Get program name irrespective of which program has been run. getProgName :: AllReproductions -> String@@ -47,7 +43,7 @@ getArgs (T x) = argsStr x newtype ValidateArguments = ValidateArguments- { vElynxFile :: FilePath }+ {vElynxFile :: FilePath} deriving (Eq, Show, Generic) validateArguments :: Parser ValidateArguments@@ -57,8 +53,9 @@ validateDsc = ["Validate an ELynx analysis"] data RedoArguments = RedoArguments- { rElynxFile :: FilePath- , rForce :: Force }+ { rElynxFile :: FilePath,+ rForce :: Force+ } deriving (Eq, Show, Generic) redoArguments :: Parser RedoArguments@@ -70,8 +67,9 @@ inFileArg :: Parser FilePath inFileArg = strArgument $ metavar "ELYNX-FILE" -data CommandArguments = Validate ValidateArguments- | Redo RedoArguments+data CommandArguments+ = Validate ValidateArguments+ | Redo RedoArguments validateCommand :: Mod CommandFields CommandArguments validateCommand =
elynx.cabal view
@@ -1,40 +1,48 @@-cabal-version: 1.12-name: elynx-version: 0.2.2-license: GPL-3-license-file: LICENSE-copyright: Dominik Schrempf (2020)-maintainer: dominik.schrempf@gmail.com-author: Dominik Schrempf-homepage: https://github.com/dschrempf/elynx#readme-bug-reports: https://github.com/dschrempf/elynx/issues-synopsis: Validate and (optionally) redo ELynx analyses-description:- Please see the README on GitHub at <https://github.com/dschrempf/elynx>.-category: Bioinformatics-build-type: Simple+cabal-version: 2.2++-- This file has been generated from package.yaml by hpack version 0.34.2.+--+-- see: https://github.com/sol/hpack+--+-- hash: 50f818ff6abb7f056acee6c87a8f19f18892a8752f0f49c3ca76452a38458d8f++name: elynx+version: 0.3.0+synopsis: Validate and (optionally) redo ELynx analyses+description: Please see the README on GitHub at <https://github.com/dschrempf/elynx>.+category: Bioinformatics+homepage: https://github.com/dschrempf/elynx#readme+bug-reports: https://github.com/dschrempf/elynx/issues+author: Dominik Schrempf+maintainer: dominik.schrempf@gmail.com+copyright: Dominik Schrempf (2020)+license: GPL-3.0-or-later+license-file: LICENSE+build-type: Simple extra-source-files: README.md ChangeLog.md source-repository head- type: git- location: https://github.com/dschrempf/elynx+ type: git+ location: https://github.com/dschrempf/elynx executable elynx- main-is: Main.hs- hs-source-dirs: app- other-modules:- Options- Paths_elynx- default-language: Haskell2010- ghc-options: -Wall -fllvm -threaded -rtsopts -with-rtsopts=-N- -fwrite-ide-info- build-depends:- aeson >=1.4.7.1 && <1.5,- base >=4.13.0.0 && <4.14,- bytestring >=0.10.10.0 && <0.11,- elynx-tools >=0.2.2 && <0.3,- optparse-applicative >=0.15.1.0 && <0.16,- slynx >=0.2.2 && <0.3,- tlynx >=0.2.2 && <0.3+ main-is: Main.hs+ other-modules:+ Options+ Paths_elynx+ autogen-modules:+ Paths_elynx+ hs-source-dirs:+ app+ ghc-options: -Wall -fllvm -threaded -rtsopts -with-rtsopts=-N+ build-depends:+ aeson+ , base >=4.7 && <5+ , bytestring+ , elynx-tools+ , optparse-applicative+ , slynx+ , tlynx+ default-language: Haskell2010