Module: Bioroebe::Colourize

Defined in:
lib/bioroebe/colours/colourize_related_code.rb

Overview

Bioroebe::Colourize

Class Method Summary collapse

Class Method Details

.colourize_TAA_stop_codon(i = '', use_this_colour = :lightgreen) ⇒ Object

#

Bioroebe::Colourize.colourize_TAA_stop_codon

#


120
121
122
123
124
125
126
127
128
# File 'lib/bioroebe/colours/colourize_related_code.rb', line 120

def self.colourize_TAA_stop_codon(
    i               = '',
    use_this_colour = :lightgreen
  )
  return i.gsub(
    /(TA\n?A)/,
    '<span class="'+use_this_colour.to_s+'">\1</span>'
  )
end

.colourize_TAG_stop_codon(i = '', use_this_colour = :lightblue) ⇒ Object

#

Bioroebe::Colourize.colourize_TAG_stop_codon

#


107
108
109
110
111
112
113
114
115
# File 'lib/bioroebe/colours/colourize_related_code.rb', line 107

def self.colourize_TAG_stop_codon(
    i               = '',
    use_this_colour = :lightblue
  )
  return i.gsub(
    /(TA\n?G)/,
    '<span class="'+use_this_colour.to_s+'">\1</span>'
  )
end

.colourize_TGA_stop_codon(i = '', use_this_colour = :olivedrab) ⇒ Object

#

Bioroebe::Colourize.colourize_TGA_stop_codon

#


133
134
135
136
137
138
139
140
141
# File 'lib/bioroebe/colours/colourize_related_code.rb', line 133

def self.colourize_TGA_stop_codon(
    i               = '',
    use_this_colour = :olivedrab
  )
  return i.gsub(
    /(TG\n?A)/,
    '<span class="'+use_this_colour.to_s+'">\1</span>'
  )
end

.colourize_this_FASTA_sequence(i = ARGV) ⇒ Object

#

Bioroebe::Colourize.colourize_this_FASTA_sequence

#


82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/bioroebe/colours/colourize_related_code.rb', line 82

def self.colourize_this_FASTA_sequence(
    i = ARGV
  )
  if i.is_a? Array
    i = i.join(' ').strip
  end
  if i and File.file?(i)
    # unless Bioroebe.const_defined?(:ParseFasta)
    #   require 'bioroebe/fasta_and_fastq/parse_fasta/parse_fasta.rb'
    # end
    # i = Bioroebe::ParseFasta.new(i) { :be_quiet }.sequence?
    i = File.readlines(i).reject {|line|
      line.start_with?('#','>')
    }.join("\n")
  end
  result = colourize_TUG_start_codon(i)
  result = colourize_TAG_stop_codon(result)
  result = colourize_TAA_stop_codon(result)
  result = colourize_TGA_stop_codon(result)
  return result
end

.colourize_TUG_start_codon(i = '', use_this_colour = :mediumslateblue) ⇒ Object

#

Bioroebe::Colourize.colourize_TUG_start_codon

#


146
147
148
149
150
151
152
153
154
# File 'lib/bioroebe/colours/colourize_related_code.rb', line 146

def self.colourize_TUG_start_codon(
    i               = '',
    use_this_colour = :mediumslateblue
  )
  return i.gsub(
    /(TU\n?G)/,
  '<span class="'+use_this_colour.to_s+'">\1</span>'
  )
end

.generate_HTML_page_via_this_input(i) ⇒ Object

#

Bioroebe::Colourize.generate_HTML_page_via_this_input

This method will generate a .html page, using the default colourization rules defined in this file here.

#


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/bioroebe/colours/colourize_related_code.rb', line 26

def self.generate_HTML_page_via_this_input(i)
  require 'bioroebe/toplevel_methods/toplevel_methods.rb'
  if i.is_a? Array
    i = i.join(' ').strip
  end
  what = "<!DOCTYPE html>\n<html lang=\"en\"><head>"\
         "<title>Colourized FASTA Sequence</title><style>\n".dup
  what << "#{return_default_CSS_rules_to_use}\n\n"
  what << "</style>\n</head>\n<body>\n"
  result = colourize_this_FASTA_sequence(i)
  what << "#{result}</body></html>\n"
  # ======================================================================= #
  # The name of the generated file is determined by the input
  # argument given.
  # ======================================================================= #
  into = File.basename(i).delete_suffix(File.extname(i))+
         '.html'
  if File.exist? into
    e 'Can not store into an already existing file.'
  else
    e 'Storing into the file '+::Bioroebe.sfile(into)+' next.'
    ::Bioroebe.write_what_into(what, into)
  end
end

.return_default_CSS_rules_to_useObject

#

Bioroebe::Colourize.return_default_CSS_rules_to_use

#


54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/bioroebe/colours/colourize_related_code.rb', line 54

def self.return_default_CSS_rules_to_use
  return '.lightgreen {
color: lightgreen;
}

.lightblue {
color: lightblue;
}

.mediumslateblue {
color: lightblue;
}

.olivedrab {
color: olivedrab;
}

body {
background-color: black;
color: white;
font-family: monospace;
font-size: 2em;
}'
end