Use Julia error/warn systems instead of printing to stdout

develop
parent f985f4a700
commit 610c80e7c9
Signed by: millironx
GPG Key ID: 139C07724802BC5D

@ -1,8 +1,8 @@
id,birthdate,dam,sire,year,sex,weaning_weight id,birthdate,dam,sire,year,sex,species,weaning_weight
1,1/1/1990,,,1990,male,354 1,1/1/1990,,,1990,male,cow,354
2,1/1/1990,,,1990,female,251 2,1/1/1990,,,1990,female,cow,251
3,1/1/1991,,1,1991,male,327 3,1/1/1991,,1,1991,male,cow,327
4,1/1/1991,,1,1991,female,328 4,1/1/1991,,1,1991,female,cow,328
5,1/1/1991,2,1,1991,male,301 5,1/1/1991,2,1,1991,male,cow,301
6,1/1/1991,2,,1991,female,270 6,1/1/1991,2,,1991,female,cow,270
7,1/1/1992,,,1992,male,330 7,1/1/1992,,,1992,male,cow,330

1 id birthdate dam sire year sex species weaning_weight
2 1 1/1/1990 1990 male cow 354
3 2 1/1/1990 1990 female cow 251
4 3 1/1/1991 1 1991 male cow 327
5 4 1/1/1991 1 1991 female cow 328
6 5 1/1/1991 2 1 1991 male cow 301
7 6 1/1/1991 2 1991 female cow 270
8 7 1/1/1992 1992 male cow 330

@ -0,0 +1,13 @@
using Gtk
openpath = open_dialog_native(
"Select a datasheet")
# GtkNullContainer(),
# ("*.csv", GtkFileFilter("*.csv", name="Comma-separated values"))
# )
# savepath = save_dialog_native(
# "Save your results",
# GtkNullContainer(),
# (GtkFileFilter("*.txt", name="Results file"),
# "*.txt")
# )

@ -18,7 +18,6 @@ using Gtk
# Main entry-level function - acts just like the script # Main entry-level function - acts just like the script
function beefblup() function beefblup()
### Prompt User
# Ask for an input spreadsheet # Ask for an input spreadsheet
path = open_dialog_native( path = open_dialog_native(
"Select a beefblup worksheet", "Select a beefblup worksheet",
@ -75,10 +74,7 @@ fixedfx = select(data, Not([:id, :birthdate, :sire, :dam]))[:,1:end-1]
# Find any columns that need to be deleted # Find any columns that need to be deleted
for i in 1:ncol(fixedfx) for i in 1:ncol(fixedfx)
if length(unique(fixedfx[:,i])) <= 1 if length(unique(fixedfx[:,i])) <= 1
colname = names(fixedfx)[i] @warn string("column '", names(fixedfx[i]), "' does not have any unique animals and will be removed from this analysis")
print("Column '")
print(colname)
print("' does not have any unique animals and will be removed from this analysis\n")
deletecols!(fixedfx,i) deletecols!(fixedfx,i)
end end
end end
@ -92,9 +88,7 @@ end
# If there are more groups than animals, then the analysis cannot continue # If there are more groups than animals, then the analysis cannot continue
if sum(numgroups) >= numanimals if sum(numgroups) >= numanimals
println("There are more contemporary groups than animals. The analysis will throw(ErrorException("there are more contemporary groups than animals"))
now abort.")
exit()
end end
# Define a "normal" animal as one of the last in the groups, provided that # Define a "normal" animal as one of the last in the groups, provided that

Loading…
Cancel
Save