module MiGA::Cli::Action::Doctor::Databases

Public Instance Methods

check_sqlite3_database(db_file, metric, &blk) click to toggle source

Check the database in db_file maintains integrity for the tables saving metric (:ani or :aai) and call blk if the file is corrupt or doesn't contain the expected structure

# File lib/miga/cli/action/doctor/databases.rb, line 7
def check_sqlite3_database(db_file, metric, &blk)"select count(*) from #{metric}")
rescue SQLite3::SQLException, SQLite3::CorruptException
each_database_file(dataset, &blk) click to toggle source
# File lib/miga/cli/action/doctor/databases.rb, line 13
def each_database_file(dataset, &blk)
  ref_db = {
    haai: ['01.haai', :aai], aai: ['02.aai', :aai], ani: ['03.ani', :ani]
  qry_db = {
    haai: ['.haai.db', :aai], aai: ['.aai.db', :aai], ani: ['.ani.db', :ani]
  base = File.join(dataset.project.path, 'data', '09.distances')
  result = :distances
  if dataset.ref?
    file_db = "#{}.db"
    ref_db.each do |rank, v|
      dir, metric = *v
      file = File.join(base, dir, file_db)
      blk[file, metric, result, rank] if File.exist? file
    # Query databases for reference databases refer to taxonomy runs
    base = File.join(base, '05.taxonomy')
    result = :taxonomy
  qry_db.each do |rank, v|
    ext, metric = *v
    file = File.join(base, "#{}#{ext}")
    blk[file, metric, result, rank] if File.exist? file