Skip to content

Commit

Permalink
clean exit for missing input files
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrofeijao committed Nov 17, 2017
1 parent 7439570 commit 54ba887
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/MentaLiST.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ end
#### Main COMMAND functions:
function call_mlst(args)
include("build_db_functions.jl")
# check if the files exist:
check_files([args["db"];args["files"]])
info("Opening kmer database ... ")
kmer_db, loci, loci2alleles, k, profile = open_db(args["db"])
info("Opening fastq file(s) ... ")
Expand Down Expand Up @@ -173,6 +175,7 @@ end

function build_db(args)
include("build_db_functions.jl")
check_files(args["fasta_files"])
k::Int8 = args["k"]
info("Opening FASTA files ... ")
results, loci = kmer_class_for_each_locus(k, args["fasta_files"], !args["disable_compression"])
Expand Down
8 changes: 8 additions & 0 deletions src/build_db_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ using OpenGene
end
include("db_graph.jl")

function check_files(files)
dont_exist = [file for file in files if !isfile(file)]
if length(dont_exist) > 0
Lumberjack.warn("The following input file(s) could not be found: $(join(dont_exist,',')), aborting ...")
exit(-1)
end
end

function complement_alleles(vector, m)
comp_vector = Int16[]
expected::Int16 = 1
Expand Down

0 comments on commit 54ba887

Please sign in to comment.