Class: Bioroebe::Base

Inherits:
Object
  • Object
show all
Includes:
BaseModule, ColoursForBase, InferTheNamespaceModule, InternalHashModule
Defined in:
lib/bioroebe/base/prototype/prototype.rb,
lib/bioroebe/base/base.rb,
lib/bioroebe/base/colours.rb

Overview

Bioroebe::Base

Constant Summary collapse

NAMESPACE =
#

Bioroebe::Base::NAMESPACE

#
inspect

Constants included from ColoursForBase

ColoursForBase::ARRAY_HTML_COLOURS_IN_USE

Instance Method Summary collapse

Methods included from BaseModule

#absolute_path, #default_file_read, #file_readlines

Methods included from InternalHashModule

#internal_hash?, #reset_the_internal_hash

Methods included from ColoursForBase

#colourize_this_aminoacid_sequence_for_the_commandline, #colourize_this_nucleotide_sequence, #disable_colours, #ecomment, #efancy, #egold, #enable_colours, #eorange, #eparse, #erev, #red, #remove_trailing_escape_part, #return_colour_for_nucleotides, #rev, #sdir, #set_will_we_use_colours, #sfancy, #sfile, #simp, #swarn, #use_colours?, #use_colours_within_the_bioroebe_namespace?

Methods included from InferTheNamespaceModule

#infer_the_namespace, #namespace?

Constructor Details

#initializeBase

#

initialize

#


37
38
39
# File 'lib/bioroebe/base/base.rb', line 37

def initialize
  reset
end

Instance Method Details

#append_what_into(what, into) ⇒ Object

#

append_what_into

#


109
110
111
# File 'lib/bioroebe/base/base.rb', line 109

def append_what_into(what, into)
  ::Bioroebe.append_what_into(what, into)
end

#can_base_pair?(a, b) ⇒ Boolean

#

can_base_pair?

This method will determine whether two nucleotides can base pair to one another, e. g. A=T or A=U and so forth.

A boolean value will be returned.

#

Returns:

  • (Boolean)


77
78
79
80
81
82
83
84
85
# File 'lib/bioroebe/base/base.rb', line 77

def can_base_pair?(a, b)
  _ = "#{a}#{b}" 
  case _
  when 'AT','TA','GC','CG','AU','UA'
    return true
  else
    return false
  end
end

#convert_global_env(i) ⇒ Object

#

convert_global_env

#


51
52
53
# File 'lib/bioroebe/base/base.rb', line 51

def convert_global_env(i)
  ::Bioroebe.convert_global_env(i)
end

#delete_file(i) ⇒ Object Also known as: remove_file, remove

#

delete_file

#


140
141
142
# File 'lib/bioroebe/base/prototype/prototype.rb', line 140

def delete_file(i)
  File.delete(i) if File.exist? i
end

#directory_to_the_codon_tables?Boolean

#

directory_to_the_codon_tables?

This method will return the directory to the codon-tables, a directory containing the individual .yml files.

#

Returns:

  • (Boolean)


93
94
95
# File 'lib/bioroebe/base/base.rb', line 93

def directory_to_the_codon_tables?
  "#{project_yaml_directory?}codon_tables/"
end

#is_on_roebe?Boolean Also known as: on_roebe?

#

is_on_roebe?

#

Returns:

  • (Boolean)


80
81
82
# File 'lib/bioroebe/base/prototype/prototype.rb', line 80

def is_on_roebe?
  ::Bioroebe.is_on_roebe?
end

#is_palindrome?(i) ⇒ Boolean Also known as: is_this_sequence_a_palindrome?

#

is_palindrome?

#

Returns:

  • (Boolean)


44
45
46
# File 'lib/bioroebe/base/base.rb', line 44

def is_palindrome?(i)
  ::Bioroebe.is_palindrome?(i)
end

#main_encoding?Boolean

#

main_encoding?

The main encoding in use. Currently this is hardcoded to UTF-8.

#

Returns:

  • (Boolean)


89
90
91
# File 'lib/bioroebe/base/prototype/prototype.rb', line 89

def main_encoding?
  USE_THIS_ENCODING
end

#mkdir(i) ⇒ Object Also known as: create_directory

#

mkdir (mkdir tag)

#


53
54
55
# File 'lib/bioroebe/base/prototype/prototype.rb', line 53

def mkdir(i)
  ::Bioroebe.mkdir(i)
end

#move_file(this_file, target) ⇒ Object Also known as: rename

#

move_file

This method can be used to relocate or rename a file.

#


98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/bioroebe/base/prototype/prototype.rb', line 98

def move_file(
    this_file, target
  )
  if File.exist? this_file
    begin
      FileUtils.mv(this_file, target)
    rescue Exception => error
      pp error
    end
  else
    e rev+'No file exists at `'+sfile(this_file)+'`.'
  end
end

#mv(old, new) ⇒ Object

#

mv

Move/Rename a file or directory.

#


133
134
135
# File 'lib/bioroebe/base/prototype/prototype.rb', line 133

def mv(old, new)
  FileUtils.mv(old, new)
end

#no_file_exists_at(i) ⇒ Object

#

no_file_exists_at

#


158
159
160
# File 'lib/bioroebe/base/prototype/prototype.rb', line 158

def no_file_exists_at(i)
  ::Bioroebe.no_file_exists_at(i)
end

#no_newlines(i) ⇒ Object

#

no_newlines

This method will remove all newlines from a given (input) String.

#


150
151
152
153
# File 'lib/bioroebe/base/prototype/prototype.rb', line 150

def no_newlines(i)
  i.delete!(N) if i
  return i
end

#project_yaml_directory?Boolean Also known as: yaml_directory?

#

project_yaml_directory?

#

Returns:

  • (Boolean)


116
117
118
# File 'lib/bioroebe/base/base.rb', line 116

def project_yaml_directory?
  ::Bioroebe.project_yaml_directory?
end

#rds(i) ⇒ Object

#

rds

The abbreviation rds stands short for “remove double slashes”.

#


117
118
119
# File 'lib/bioroebe/base/prototype/prototype.rb', line 117

def rds(i)
  ::Bioroebe.rds(i)
end

#register_sigint(optional_display_this_message = nil) ⇒ Object

#

register_sigint

#


58
59
60
61
62
63
64
65
66
67
# File 'lib/bioroebe/base/base.rb', line 58

def register_sigint(
    optional_display_this_message = nil
  )
  Signal.trap('SIGINT') {
    if optional_display_this_message
      e optional_display_this_message
    end
    exit
  }
end

#resetObject

#

reset (reset tag)

#


60
61
62
63
64
65
# File 'lib/bioroebe/base/prototype/prototype.rb', line 60

def reset
  # ======================================================================= #
  # === @namespace
  # ======================================================================= #
  @namespace = NAMESPACE # We store the namespace here.
end

#return_pwdObject Also known as: return_working_directory

#

return_pwd

#


124
125
126
# File 'lib/bioroebe/base/prototype/prototype.rb', line 124

def return_pwd
  "#{Dir.pwd}/".squeeze('/')
end

#return_the_first_line_of_this_file(i) ⇒ Object

#

return_the_first_line_of_this_file

#


70
71
72
73
74
75
# File 'lib/bioroebe/base/prototype/prototype.rb', line 70

def return_the_first_line_of_this_file(i)
  if File.exist? i
    return File.open(i) {|this_file| this_file.readline.strip }
  end
  return i
end

#word_wrap(text, line_width = 80) ⇒ Object

#

word_wrap

#


123
124
125
126
127
128
# File 'lib/bioroebe/base/base.rb', line 123

def word_wrap(
    text,
    line_width = 80
  )
  return text.scan(/\S.{0,#{line_width}}\S(?=\s|$)|\S+/).join(N)
end

#write_what_into(what, into) ⇒ Object Also known as: save_file

#

write_what_into

This method can be used to write into a (local) file.

#


102
103
104
# File 'lib/bioroebe/base/base.rb', line 102

def write_what_into(what, into)
  ::Bioroebe.write_what_into(what, into)
end