Class: Bioroebe::Base

Inherits:
Object
  • Object
show all
Includes:
ColoursForBase
Defined in:
lib/bioroebe/base/namespace.rb,
lib/bioroebe/base/base.rb,
lib/bioroebe/base/misc.rb,
lib/bioroebe/base/colours.rb,
lib/bioroebe/base/initialize.rb,
lib/bioroebe/base/prototype/misc.rb,
lib/bioroebe/base/prototype/mkdir.rb,
lib/bioroebe/base/prototype/reset.rb,
lib/bioroebe/base/prototype/e_and_ee.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 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_use_colours, #sfancy, #sfile, #simp, #swarn, #use_colours?, #use_colours_within_the_bioroebe_namespace?

Constructor Details

#initializeBase

#

initialize

#

14
15
16
# File 'lib/bioroebe/base/initialize.rb', line 14

def initialize
  reset
end

Instance Method Details

#append_what_into(what, into) ⇒ Object

#

append_what_into

#

90
91
92
# File 'lib/bioroebe/base/misc.rb', line 90

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)

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

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

#

34
35
36
# File 'lib/bioroebe/base/misc.rb', line 34

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

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

#

delete_file

#

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

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)

74
75
76
# File 'lib/bioroebe/base/misc.rb', line 74

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

#file_readlines(i) ⇒ Object Also known as: readlines

#

file_readlines

#

114
115
116
# File 'lib/bioroebe/base/prototype/misc.rb', line 114

def file_readlines(i)
  File.readlines(i, encoding: main_encoding?)
end

#infer_the_namespaceObject

#

infer_the_namespace

This will assume the true namespace from the inspectable name.

#

106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/bioroebe/base/misc.rb', line 106

def infer_the_namespace
  _ = inspect.to_s.delete('<')
  _ = _.split(':0').first if _.include?(':0')
  if _.include? ' '
    _ = _.split(' ').first.delete('#')
    if _.include? ':'
      _ = _.split(':')[0 .. -2].reject {|entry| entry.empty? }.join('::')
    end
  end
  _.delete!('#') if _.include?('#')
  @namespace = _ # And assign it here.
end

#is_on_roebe?Boolean Also known as: on_roebe?

#

is_on_roebe?

#

Returns:

  • (Boolean)

29
30
31
# File 'lib/bioroebe/base/prototype/misc.rb', line 29

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)

23
24
25
26
27
28
# File 'lib/bioroebe/base/misc.rb', line 23

def is_palindrome?(i)
  unless ::Bioroebe.respond_to?(:is_palindrome?)
    require 'bioroebe/toplevel_methods/palindromes.rb'
  end
  ::Bioroebe.is_palindrome?(i)
end

#main_encoding?Boolean

#

main_encoding?

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

#

Returns:

  • (Boolean)

38
39
40
# File 'lib/bioroebe/base/prototype/misc.rb', line 38

def main_encoding?
  USE_THIS_ENCODING
end

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

#

mkdir (mkdir tag)

#

16
17
18
# File 'lib/bioroebe/base/prototype/mkdir.rb', line 16

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.

#

47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/bioroebe/base/prototype/misc.rb', line 47

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.

#

82
83
84
# File 'lib/bioroebe/base/prototype/misc.rb', line 82

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

#namespace?Boolean

#

namespace?

#

Returns:

  • (Boolean)

16
17
18
# File 'lib/bioroebe/base/misc.rb', line 16

def namespace?
  @namespace
end

#no_file_exists_at(i) ⇒ Object

#

no_file_exists_at

#

107
108
109
# File 'lib/bioroebe/base/prototype/misc.rb', line 107

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.

#

99
100
101
102
# File 'lib/bioroebe/base/prototype/misc.rb', line 99

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)

97
98
99
# File 'lib/bioroebe/base/misc.rb', line 97

def project_yaml_directory?
  ::Bioroebe.project_yaml_directory?
end

#rds(i) ⇒ Object

#

rds

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

#

66
67
68
# File 'lib/bioroebe/base/prototype/misc.rb', line 66

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

#register_sigint(optional_display_this_message = nil) ⇒ Object

#

register_sigint

#

41
42
43
44
45
46
47
48
# File 'lib/bioroebe/base/misc.rb', line 41

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)

#

19
20
21
22
23
24
# File 'lib/bioroebe/base/prototype/reset.rb', line 19

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

#return_pwdObject Also known as: return_working_directory

#

return_pwd

#

73
74
75
# File 'lib/bioroebe/base/prototype/misc.rb', line 73

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

#return_the_first_line_of_this_file(i) ⇒ Object

#

return_the_first_line_of_this_file

#

18
19
20
21
22
23
# File 'lib/bioroebe/base/prototype/misc.rb', line 18

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

#

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

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.

#

83
84
85
# File 'lib/bioroebe/base/misc.rb', line 83

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