Class: Bioroebe::Taxonomy::CheckAvailable

Inherits:
Object
  • Object
show all
Includes:
Shared, FileUtils::Verbose
Defined in:
lib/bioroebe/taxonomy/info/check_available.rb

Overview

Bioroebe::Taxonomy::CheckAvailable

Constant Summary collapse

SHALL_WE_COPY =
#

SHALL_WE_COPY

Whether we shall copy or not.

#
true

Constants included from Constants

Bioroebe::Taxonomy::Constants::AA_DIR, Bioroebe::Taxonomy::Constants::ARRAY_PROJECT_FILES, Bioroebe::Taxonomy::Constants::Archaea_Taxonomy_ID, Bioroebe::Taxonomy::Constants::BASE, Bioroebe::Taxonomy::Constants::BASE_URL, Bioroebe::Taxonomy::Constants::BE_VERBOSE, Bioroebe::Taxonomy::Constants::Bacteria_Taxonomy_ID, Bioroebe::Taxonomy::Constants::CITATIONS, Bioroebe::Taxonomy::Constants::CURATED_DIR, Bioroebe::Taxonomy::Constants::DATA_DIR, Bioroebe::Taxonomy::Constants::DELNODES, Bioroebe::Taxonomy::Constants::DIVISION, Bioroebe::Taxonomy::Constants::Eukaryota_Taxonomy_ID, Bioroebe::Taxonomy::Constants::FILE_USE_THIS_DATABASE, Bioroebe::Taxonomy::Constants::GEM_DIR, Bioroebe::Taxonomy::Constants::GENCODE, Bioroebe::Taxonomy::Constants::INCOMING_DIR, Bioroebe::Taxonomy::Constants::INFO_DIR, Bioroebe::Taxonomy::Constants::LAST_INTERACTIVE_COMMAND, Bioroebe::Taxonomy::Constants::LOCALOME_DIR, Bioroebe::Taxonomy::Constants::LOCAL_MIRROR, Bioroebe::Taxonomy::Constants::MERGED, Bioroebe::Taxonomy::Constants::MODULE_PATH, Bioroebe::Taxonomy::Constants::NAMES, Bioroebe::Taxonomy::Constants::NAMES_SQL, Bioroebe::Taxonomy::Constants::NCBI_BASE, Bioroebe::Taxonomy::Constants::NODES, Bioroebe::Taxonomy::Constants::NODES_SQL, Bioroebe::Taxonomy::Constants::NT_DIR, Bioroebe::Taxonomy::Constants::POSTGRESQL_QUERY_SIZE, Bioroebe::Taxonomy::Constants::POSTGRE_LOGIN_COMMAND, Bioroebe::Taxonomy::Constants::PROJECT_DOC_DIR, Bioroebe::Taxonomy::Constants::SEQUENCES_DIR, Bioroebe::Taxonomy::Constants::SHARED_HOME, Bioroebe::Taxonomy::Constants::TAXONOMY_BROWSER, Bioroebe::Taxonomy::Constants::TEMP_DIR, Bioroebe::Taxonomy::Constants::TEST_DIR, Bioroebe::Taxonomy::Constants::TMP_DIR, Bioroebe::Taxonomy::Constants::URL1

Instance Method Summary collapse

Methods included from Shared

be_quiet, #be_verbose?, be_verbose?, #cd, #edit_login_file, #eliminate_tabulator, #ensure_that_download_dir_exists, #ensure_that_temp_dir_exists, #mkdir, #readlines, #set_pgpassword, #show_password, #show_time_now, #split_at, #split_at_tabulator, #tokenize

Methods included from Constants

#info_dir?, #work_directory?

Constructor Details

#initialize(optional_input = nil, run_already = true) ⇒ CheckAvailable

#

initialize

#


30
31
32
33
34
35
36
37
# File 'lib/bioroebe/taxonomy/info/check_available.rb', line 30

def initialize(
    optional_input = nil,
    run_already    = true
  )
  reset
  set_input(optional_input)
  run if run_already
end

Instance Method Details

#report_status_to_the_userObject

#

report_status_to_the_user

#


121
122
123
124
125
126
127
128
129
130
# File 'lib/bioroebe/taxonomy/info/check_available.rb', line 121

def report_status_to_the_user
  unless @array_duplicates.empty?
    e 'We found duplicates for these entries:'
    pp @array_duplicates
  end
  unless @array_no_match.empty?
    e 'We found no match for these entries:'
    pp @array_no_match
  end
end

#resetObject

#

reset

#


51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/bioroebe/taxonomy/info/check_available.rb', line 51

def reset
  # ======================================================================= #
  # === @shall_we_copy
  # ======================================================================= #
  @shall_we_copy    = SHALL_WE_COPY
  # ======================================================================= #
  # === @array_duplicates
  # ======================================================================= #
  @array_duplicates = []
  # ======================================================================= #
  # === @array_no_match
  # ======================================================================= #
  @array_no_match   = []
end

#runObject

#

run

#


135
136
137
138
139
140
141
142
143
# File 'lib/bioroebe/taxonomy/info/check_available.rb', line 135

def run
  if @input.nil?
  else
    @shall_we_copy = false
  end
  show_important_directories
  scan_info_directory
  report_status_to_the_user
end

#scan_info_directoryObject

#

scan_info_directory

#


81
82
83
84
85
86
# File 'lib/bioroebe/taxonomy/info/check_available.rb', line 81

def scan_info_directory
  Dir["#{INFO_DIR}*.INFO"].each {|entry|
    e "  → #{sfile(entry)} (#{sfancy(File.basename(entry))})"
    show_similar_entries_in_aa_dir(entry)
  }
end

#set_input(i) ⇒ Object

#

set_input

#


42
43
44
45
46
# File 'lib/bioroebe/taxonomy/info/check_available.rb', line 42

def set_input(i)
  i = i.first if i.is_a? Array
  i = i.to_s.dup if i
  @input = i
end

#show_important_directoriesObject

#

show_important_directories

#


69
70
71
72
73
74
75
76
# File 'lib/bioroebe/taxonomy/info/check_available.rb', line 69

def show_important_directories
  e 'We will now run through some important local directories.'
  e
  e "  #{sfancy(INFO_DIR)}"
  e "  #{sfancy(AA_DIR)}"
  e "  #{sfancy(LOCALOME_DIR)}"
  e
end

#show_similar_entries_in_aa_dir(i) ⇒ Object

#

show_similar_entries_in_aa_dir

#


91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/bioroebe/taxonomy/info/check_available.rb', line 91

def show_similar_entries_in_aa_dir(i)
  original_input = i.dup # Keep a copy of the original input.
  i = File.basename(i)
  _ = i.gsub(File.extname(i), '')
  query_string = AA_DIR+_+'*'
  result = Dir[query_string]
  unless result.empty?
    e "The corresponding match should be #{sfile(result.first.to_s)}"
    if result.size > 1
      e red('!!!')+' At least one more entry was '+
        'found though, at '+sfile(result[1])
      @array_duplicates << original_input
    else
      if @shall_we_copy
        e 'We will now copy these two entries.'
        copy(original_input, TEST_DIR)
        copy(result.first,   TEST_DIR)
      end
    end
  else
    ewarn 'Warning: no match was found for '+sfile(query_string)
    ewarn '(Original input was: '+sfancy(original_input)+')'
    @array_no_match << original_input
  end
  e
end