Class: Bioroebe::Base
- Inherits:
-
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
Direct Known Subclasses
AminoacidsMassTable, CalculateBlosumScore, CalculateMeltingTemperatureForMoreThanThirteenNucleotides, ColourSchemeDemo, ColourizeHydrophilicAndHydrophobicAminoacids, ColourizeSequence, CommandlineApplication, DetectMinimalCodon, DetermineAntigenicAreas, Dotplot, FastaParser, Ncbi, Punnet, SanitizeCodonFrequency, SanitizeNucleotideSequence, Shell::Help, ShowRestrictionEnzymes
Constant Summary
collapse
- NAMESPACE =
#
Bioroebe::Base::NAMESPACE
#
inspect
ColoursForBase::ARRAY_HTML_COLOURS_IN_USE
Instance Method Summary
collapse
#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
#initialize ⇒ Base
14
15
16
|
# File 'lib/bioroebe/base/initialize.rb', line 14
def initialize
reset
end
|
Instance Method Details
#append_what_into(what, into) ⇒ Object
#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.
#
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
#delete_file(i) ⇒ Object
Also known as:
remove_file, remove
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.
#
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
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_namespace ⇒ Object
#
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 = _ end
|
#is_on_roebe? ⇒ Boolean
Also known as:
on_roebe?
#is_palindrome?(i) ⇒ Boolean
Also known as:
is_this_sequence_a_palindrome?
#main_encoding? ⇒ Boolean
#
main_encoding?
The main encoding in use. Currently this is hardcoded to UTF-8.
#
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
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
16
17
18
|
# File 'lib/bioroebe/base/misc.rb', line 16
def namespace?
@namespace
end
|
#no_file_exists_at(i) ⇒ Object
#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?
#
#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
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
|
#reset ⇒ Object
19
20
21
22
23
24
|
# File 'lib/bioroebe/base/prototype/reset.rb', line 19
def reset
@namespace = NAMESPACE end
|
#return_pwd ⇒ Object
Also known as:
return_working_directory
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
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.
#