Class: Bioroebe::Taxonomy::IsDNA

Inherits:
Object
  • Object
show all
Includes:
Shared
Defined in:
lib/bioroebe/taxonomy/info/is_dna.rb

Overview

Constant Summary

Constants included from Constants

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

Instance Attribute Summary collapse

Class Method Summary collapse

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(i = 'MGMGMGMMM', run_already = true) ⇒ IsDNA

#

initialize

#


35
36
37
38
39
40
41
42
# File 'lib/bioroebe/taxonomy/info/is_dna.rb', line 35

def initialize(
    i           = 'MGMGMGMMM',
    run_already = true
  )
  reset
  set_input(i)
  run if run_already
end

Instance Attribute Details

#n_entriesObject (readonly)

  • Prozente

    • min-Zeichen



30
31
32
# File 'lib/bioroebe/taxonomy/info/is_dna.rb', line 30

def n_entries
  @n_entries
end

Class Method Details

.[](i = ARGV) ⇒ Object

#

IsDNA

Class method for a more convenient output.

#


147
148
149
# File 'lib/bioroebe/taxonomy/info/is_dna.rb', line 147

def self.[](i = ARGV)
  return new(i).result
end

Instance Method Details

#determine_how_many_characters_we_haveObject

#

determine_how_many_characters_we_have

#


75
76
77
# File 'lib/bioroebe/taxonomy/info/is_dna.rb', line 75

def determine_how_many_characters_we_have
  @total_characters = @input.join('').size
end

#is_dna?Boolean

#

is_dna?

Query method to determine whether this is DNA or whether it is not.

#

Returns:

  • (Boolean)


92
93
94
# File 'lib/bioroebe/taxonomy/info/is_dna.rb', line 92

def is_dna?
  @result
end

#reportObject

#

report

Do a verbose report here.

#


101
102
103
104
105
106
107
108
# File 'lib/bioroebe/taxonomy/info/is_dna.rb', line 101

def report
  is_or_is_not_dna = ''
  if is_dna?
  else
    is_or_is_not_dna << steelblue('not ') 
  end
  erev 'The dataset is '+is_or_is_not_dna+rev+'DNA.'
end

#resetObject

#

reset (reset tag)

#


47
48
49
50
51
52
53
54
55
56
# File 'lib/bioroebe/taxonomy/info/is_dna.rb', line 47

def reset
  # ======================================================================= #
  # === @be_verbose
  # ======================================================================= #
  @be_verbose = false
  # ======================================================================= #
  # === @n_entries
  # ======================================================================= #
  @n_entries = 0
end

#result?Boolean Also known as: result

#

result?

#

Returns:

  • (Boolean)


113
114
115
# File 'lib/bioroebe/taxonomy/info/is_dna.rb', line 113

def result?
  @result
end

#runObject

#

run

#


120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/bioroebe/taxonomy/info/is_dna.rb', line 120

def run
  result = true
  # @input is an array.
  @input.each {|entry|
    splitted = entry.chars
    splitted.each {|inner_entry|
      @n_entries += 1
      if ARRAY_VALID_DNA_SEQUENCES.include? inner_entry
      else # else it can not be DNA.
        if @be_verbose
          e "Nope, #{sfancy(inner_entry)} is not DNA."
          pp splitted
        end
        result = false
        break
      end
    }
  }
  @result = result
  return result
end

#set_input(i) ⇒ Object

#

set_input

#


61
62
63
64
65
66
67
68
69
70
# File 'lib/bioroebe/taxonomy/info/is_dna.rb', line 61

def set_input(i)
  if File.exist? i
    if Object.const_defined? Taxonomy::ParseFasta
      i = Taxonomy::ParseFasta.new(i)
    end
  end if i.is_a? String
  i = [i].flatten
  @input = i
  determine_how_many_characters_we_have
end

#total_characters?Boolean Also known as: total_characters

#

total_characters?

#

Returns:

  • (Boolean)


82
83
84
# File 'lib/bioroebe/taxonomy/info/is_dna.rb', line 82

def total_characters?
  @total_characters
end