1
0
Fork 0
mirror of https://github.com/MillironX/beefblup.git synced 2024-11-13 03:03:08 +00:00

Add argument parsing to cli

This commit is contained in:
Thomas A. Christensen II 2021-06-19 11:50:26 -05:00
parent 1885aa15ef
commit 5c5ac1654c
Signed by: millironx
GPG key ID: 139C07724802BC5D
2 changed files with 48 additions and 1 deletions

View file

@ -4,6 +4,7 @@ authors = ["Thomas A. Christensen II <25492070+MillironX@users.noreply.github.co
version = "0.3.0"
[deps]
ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"

View file

@ -2,5 +2,51 @@
#=
exec julia --project="$(realpath "$(dirname "${BASH_SOURCE[0]}")")" "${BASH_SOURCE[0]}" "$@"
=#
# beefblup cli
# Provides a convenient CLI for using beefblup
# cSpell:includeRegExp #.*
# cSpell:includeRegExp ("""|''')[^\1]*\1
# Import packages
using BeefBLUP
BeefBLUP.beefblup()
using ArgParse
# If this is run without arguments, catch that before parsing
if isempty(ARGS)
BeefBLUP.beefblup()
return
end
# Setup the argument table
argsettings = ArgParseSettings()
@add_arg_table argsettings begin
"datafile"
help = "datasheet containing the pedigree, fixed effects, and response trait formatted in CSV"
required = true
arg_type = String
"resultsfile"
help = "filename for storing the results of the analysis"
required = false
arg_type = String
"--heritability", "-t"
help = "heritability of the response trait being analyzed"
required = true
arg_type = Float64
end
arguments = parse_args(argsettings)
println("Parsed args:")
for (arg,val) in arguments
println(" $arg => $val")
end
h2 = arguments["heritability"]
if isnothing(arguments["resultsfile"])
BeefBLUP.beefblup(arguments["datafile"], h2)
exit()
end
print(arguments["datafile"], arguments["resultsfile"], string(h2))
BeefBLUP.beefblup(arguments["datafile"], arguments["resultsfile"], h2)