Class: GeneValidator::GVArgValidation::Blast

Inherits:
Object
  • Object
show all
Defined in:
lib/genevalidator/arg_validation.rb

Overview

Validates BLAST Installation (And BLAST databases)

Constant Summary collapse

MINIMUM_BLAST_VERSION =

Use a fixed minimum version of BLAST+

'2.2.30+'
EXIT_BLAST_NOT_INSTALLED =

Use the following exit codes, or 1.

2
EXIT_BLAST_NOT_COMPATIBLE =
3
EXIT_NO_BLAST_DATABASE =
4

Class Method Summary collapse

Class Method Details

.assert_blast_installationObject



155
156
157
158
159
# File 'lib/genevalidator/arg_validation.rb', line 155

def assert_blast_installation
  # Validate BLAST installation
  assert_blast_installed
  assert_blast_compatible
end

.assert_local_blast_database_exists(db) ⇒ Object



178
179
180
181
182
183
184
# File 'lib/genevalidator/arg_validation.rb', line 178

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.'
  $stderr.puts '    Please ensure that the provided path is correct' \
               ' and then try again.'
  exit EXIT_NO_BLAST_DATABASE
end

.validate(opt) ⇒ Object



149
150
151
152
153
# File 'lib/genevalidator/arg_validation.rb', line 149

def validate(opt)
  assert_blast_installation
  warn_if_remote_database(opt)
  assert_local_blast_database_exists(opt[:db]) if opt[:db] !~ /remote/
end

.warn_if_remote_database(opt) ⇒ Object



161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/genevalidator/arg_validation.rb', line 161

def warn_if_remote_database(opt)
  return if opt[:db] !~ /remote/
  $stderr.puts # a blank line
  if !opt[:raw_sequences] &&
      (opt[:validations].include?('align') ||
       opt[:validations].include?('dup'))
    $stderr.puts 'Warning: Hit sequences will be fetched from remote' \
                 ' server.'
  else
    $stderr.puts 'Warning: BLAST will be carried out on remote server.'
  end
  $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
end