lib/genevalidator/arg_validation.rb in genevalidator-1.6.2 vs lib/genevalidator/arg_validation.rb in genevalidator-1.6.3
- old
+ new
@@ -24,11 +24,10 @@
assert_validations_arg
check_num_threads
export_bin_dirs unless @opt[:bin].nil?
-
Blast.validate(opt) unless @opt[:test]
assert_mafft_installation
end
# Return `true` if the given command exists and is executable.
@@ -51,11 +50,12 @@
@opt[:num_threads] = Integer(@opt[:num_threads])
unless @opt[:num_threads] > 0
$stderr.puts 'Number of threads can not be lower than 0'
end
return unless @opt[:num_threads] > 256
- $stderr.puts "Number of threads set at #{@opt[:num_threads]} is unusually high."
+ $stderr.puts "Number of threads set at #{@opt[:num_threads]} is" \
+ ' unusually high.'
end
def assert_BLAST_output_files
return unless @opt[:blast_xml_file] || @opt[:blast_tabular_file]
if @opt[:blast_xml_file]
@@ -67,12 +67,12 @@
end
def assert_output_dir_does_not_exist
output_dir = "#{@opt[:input_fasta_file]}.html"
return unless File.exist?(output_dir)
- $stderr.puts "The output directory already exists for this fasta file.\n"
- $stderr.puts "Please remove the following directory: #{output_dir}\n"
+ $stderr.puts 'The output directory already exists for this fasta file.'
+ $stderr.puts "\nPlease remove the following directory: #{output_dir}\n"
$stderr.puts "You can run the following command to remove the folder.\n"
$stderr.puts "\n $ rm -r #{output_dir} \n"
exit 1
end
@@ -100,28 +100,31 @@
def assert_input_sequence
fasta_content = IO.binread(@opt[:input_fasta_file])
type = BlastUtils.type_of_sequences(fasta_content)
return if type == :nucleotide || type == :protein
- $stderr.puts '*** Error: The input files does not contain just protein or'
- $stderr.puts ' nucleotide data. Please correct this and try again.'
+ $stderr.puts '*** Error: The input files does not contain just protein'
+ $stderr.puts ' or nucleotide data.'
+ $stderr.puts ' Please correct this and try again.'
exit 1
end
def export_bin_dirs
@opt[:bin].each do |bin|
- if File.directory?(bin)
+ bin = File.expand_path(bin)
+ if File.exist?(bin) && File.directory?(bin)
add_to_path(bin)
else
$stderr.puts '*** The following bin directory does not exist:'
$stderr.puts " #{bin}"
end
end
end
## Checks if dir is in $PATH and if not, it adds the dir to the $PATH.
def add_to_path(bin_dir)
+ return unless bin_dir
return if ENV['PATH'].split(':').include?(bin_dir)
ENV['PATH'] = "#{bin_dir}:#{ENV['PATH']}"
end
def assert_mafft_installation
@@ -155,15 +158,15 @@
assert_blast_compatible
end
def warn_if_remote_database(db)
return if db !~ /remote/
- $stderr.puts # a blank line
+ $stderr.puts # a blank line
$stderr.puts 'Warning: BLAST will be carried out on remote servers.'
$stderr.puts 'This may take quite a bit of time.'
$stderr.puts 'You may want to install a local BLAST database for' \
' faster analyses.'
- $stderr.puts # a blank line
+ $stderr.puts # a blank line
end
def assert_local_blast_database_exists(db)
return if system("blastdbcmd -db #{db} -info > /dev/null 2>&1")
$stderr.puts '*** No BLAST database found at the provided path.'