Class: Bioroebe::Shell::Help
- Defined in:
- lib/bioroebe/shell/help/class.rb
Constant Summary collapse
- N_LEFT_PADDING =
#
N_LEFT_PADDING
How many space characters to pad to the left. Currently 4 ' ' space tokens.
#
4
- DEFAULT_MIDDLE_PADDING =
#
DEFAULT_MIDDLE_PADDING
#
25
- TITLE =
#
TITLE
This constant specifies the title that we will use for the bioshell help options.
#
"#{::Bioroebe.rev}BioShell Help Options:"
Constants inherited from Base
Constants included from ColoursForBase
ColoursForBase::ARRAY_HTML_COLOURS_IN_USE
Class Method Summary collapse
-
.[](i = '') ⇒ Object
# === Bioroebe::Shell::Help[] ========================================================================= #.
Instance Method Summary collapse
-
#add(i = '', append_this = nil) ⇒ Object
# === add (add tag) ========================================================================= #.
-
#build_help_string ⇒ Object
# === build_help_string.
-
#expanded_middle_padding? ⇒ Boolean
# === expanded_middle_padding?.
-
#initialize(use_colours = true, run_already = true) ⇒ Help
constructor
# === initialize.
-
#left_padding? ⇒ Boolean
# === left_padding? ========================================================================= #.
-
#middle_padding? ⇒ Boolean
# === middle_padding?.
-
#reset ⇒ Object
# === reset ========================================================================= #.
-
#run ⇒ Object
# === run ========================================================================= #.
-
#show_help(display_this = @_) ⇒ Object
(also: #display_result)
# === show_help.
-
#use_konsole? ⇒ Boolean
# === use_konsole? ========================================================================= #.
Methods inherited from Base
#append_what_into, #can_base_pair?, #convert_global_env, #delete_file, #directory_to_the_codon_tables?, #file_readlines, #infer_the_namespace, #is_on_roebe?, #is_palindrome?, #main_encoding?, #mkdir, #move_file, #mv, #namespace?, #no_file_exists_at, #no_newlines, #project_yaml_directory?, #rds, #register_sigint, #return_pwd, #return_the_first_line_of_this_file, #word_wrap, #write_what_into
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
#initialize(use_colours = true, run_already = true) ⇒ Help
#
initialize
The first argument determines whether we will use colours or not.
We can either use KDE Konsole colours, or the regular colours.
#
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/bioroebe/shell/help/class.rb', line 45 def initialize( use_colours = true, run_already = true ) reset @use_colours = use_colours # ======================================================================= # # The user may pass in a block, which usually means that the user # wants to display only some subcommands. # ======================================================================= # if block_given? yielded = yield if yielded unless yielded.empty? # ================================================================= # # @what_to_show can limit to show only some help-options. # ================================================================= # @what_to_show = yielded @what_to_show = @what_to_show.first if @what_to_show.is_a? Array if @what_to_show == '?' _ = "#{rev}You can provide an argument such as \"a\" "\ "or \"b\" and we will#{N}".dup _ << 'feedback all help options that start with '\ 'this letter.'+N+N _ << 'Example:'+N+N _ << ' help a'+N+N show_help(_) return end end end end run if run_already end |
Class Method Details
.[](i = '') ⇒ Object
#
Bioroebe::Shell::Help[]
#
138 139 140 |
# File 'lib/bioroebe/shell/help/class.rb', line 138 def self.[](i = '') new(i) end |
Instance Method Details
#add(i = '', append_this = nil) ⇒ Object
#
add (add tag)
#
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 |
# File 'lib/bioroebe/shell/help/class.rb', line 343 def add( i = '', append_this = nil ) original_append_this = nil original_append_this = append_this.dup if append_this # ======================================================================= # # Handle subcommands next. # ======================================================================= # unless @what_to_show == :everything # ===================================================================== # # Note that @what_to_show can be 'a' but also 'a-d', so # we must check whether it has a '-' token. # ===================================================================== # _ = @what_to_show # Keep track of what to show here. if _.include? '-' # Check for a "range"-like input here. splitted = _.split('-') start_position = splitted.first end_position = splitted.last range = (start_position .. end_position).to_a unless range.any? {|entry| i.delete('(').strip.start_with? entry } return end else unless i.delete('(').strip.start_with? _ return # ^^^ We exclude all entries that do NOT start with this character. end end end unless i.include? TITLE # ======================================================================= # # === Handle input that includes () # ======================================================================= # if i.include? '(' # Assume that we must parse it. # ===================================================================== # # First pad it. # ===================================================================== # regex_to_use = /^(\(.+?\)\w*)/ # See: http://rubular.com/r/AbZ0fGRTvd splitted = i.split(regex_to_use).reject(&:empty?) splitted[0] = splitted[0].ljust(middle_padding?) # ===================================================================== # # If the second half is too long, we will insert a newline # ===================================================================== # if splitted[1].size > 75 splitted[1] = splitted[1].gsub(/(.{1,75})(\s+|$)/, "\\1\n#{left_padding?} #{}").rstrip end i = splitted.join if use_colours? i.gsub!(regex_to_use, burlywood('\\1')+rev) end i.prepend(@left_padding) end # ======================================================================= # # Next, colourize the input if the user requested it so. # ======================================================================= # if append_this if append_this.is_a?(Hash) if append_this.has_key? :colourize # ================================================================= # # Use Konsole colours next. # ================================================================= # append_this = append_this.delete(:colourize) append_this = slateblue(append_this) if @use_colours i << append_this end end unless i.end_with? ' ' append_this = append_this.dup if append_this.frozen? append_this.prepend(' ') end if use_colours? i << sfancy(append_this) else i << append_this end unless original_append_this.is_a? Hash end @_ << i+N # This is mostly just an append-action. We will add a newline too. end |
#build_help_string ⇒ Object
#
build_help_string
Called from within the run() method.
#
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
# File 'lib/bioroebe/shell/help/class.rb', line 147 def build_help_string # ======================================================================= # # Add the title first # ======================================================================= # add TITLE+N # Add a newline to start with. # ======================================================================= # # a tag # ======================================================================= # add '(aasequence?) to show the amino acid sequence assigned' add '(align) to align two difference sequences to one another, '\ 'such as in "align 1 3"' add '(align_ORFS) to align all ORFs in the given main DNA sequence' add '(analyze_sequence) to analyze the main sequence for '\ 'special sequences' add '(aminoacid?) to show the long name of an aminoacid. '\ 'Usage: aminoacid? K' add '(ana)lyze to analyze a given aminoacid string. Will '\ 'show percentage of DNA used (if you use dna_analyze).' add '(aminoacids?) to show information about the aminoacids' add # ======================================================================= # # === b tag # ======================================================================= # add '(b)losum ','show blosum matrix (use e. g. "blosum62" to '\ 'show the values for this blosum)' add '(backtrack) translate into the most likely '\ 'DNA sequence, from the given aminoacid sequence' add '(bparse) to show all available genomes in the bio_lang file' add # ======================================================================= # # === c tag # ======================================================================= # add '(cat) to display the content of a file' add '(chop) to chop off some nucleotides from the end' add '(CpG?) to show which CpG islands may exist' add '(codon) to translate a RNA Codon into the proper Aminoacids' add '(codon?) similar to the above ^^^ but limited to only one '\ 'input-codon at a time' add '(codon_usage) to show the codon usage of your '\ 'DNA string' add '(codontable) to show the codon table' add '(codontables) to show all registered codon tables' add '(cola) to colourize a given aminoacid' add '(compact) to compact a FASTA (.fa / .fasta) file, '\ 'into a single line in the file' add '(complement) to find the complementary sequence of a '\ 'DNA strand' add '(cscheme) to colourize the nucleotides in the main '\ 'nucleotide colour scheme' add # ======================================================================= # # === d tag # ======================================================================= # add '(discover_all_palindromes) to discover all palindromes (min: 4, max: 10)' add # ======================================================================= # # === f tag # ======================================================================= # add '(files?) to get an overview where some various '\ 'important files are kept locally' add '(fasta) to parse some ', 'FASTA data' add '(find) to find a subsequence. Example: find ATG' add '(fr)ameshift to ', 'perform a frameshift (add '\ 'argument like 1, 2, 3)' add '(first) change the first nucleotide to another one' add '(find_gene) to find a gene in the given sequence' add # ======================================================================= # # === g tag # ======================================================================= # add '(gc_content) to calculate the GC content of a sequence '\ 'sequence (They will cut at that sequence. "rest?" '\ 'is an alias.)' add '(gff3?) to read and handle .gff or .gff3 files, through the '\ 'parser Bioroebe::Parser::GFF' add # ======================================================================= # # === h tag # ======================================================================= # add '(h)istory to show the ', 'input history' add # ======================================================================= # # === l tag # ======================================================================= # add '(load) to load the main string from a file' add '(list) age to list the age of different organisms' add '(ll) to get a listing of local files and directories' add # ======================================================================= # # === m tag # ======================================================================= # add '(ma)ss_weight to calculate weight of a Protein (Input must '+ 'be Aminoacids)' add '(mmasse) to display the molecular mass of an Aminoacid' add '(mt) ', 'to calculate the melting temperature' add '(multi_line) ', 'to assign a FASTA file with several lines' add # ======================================================================= # # === n tag # ======================================================================= # add '(nucleotides_table?) to show the molecular mass of '\ 'the Nucleotides' add # ======================================================================= # # === o tag # ======================================================================= # add '(orf?) ','to seek for ORFs in our target sequence' if ::Bioroebe.is_on_roebe? # Only relevant for my home system. add '(open) to open all my relevant files in an editor' end add # ======================================================================= # # === p tag # ======================================================================= # add '(palindrome) to generate a Palindrome. Input the length of the '\ 'palindrome which should be an even number such as "6" or "12".' add '(parse_fasta) to parse a fasta file. pfasta is an '\ 'alias. If input is omitted, we try to '\ 'find a fasta file in the working directory.' add '(pathways) to show metabolic pathways' add '(phosphorylation_sites?) to find phosphorylation sites '\ 'in the aminoacid sequence' add '(pitch) to show how long an alpha helix is (optionally '\ 'pass the amount of aminoacids into it)' add '(print_table) to print a useful mnemo-table' add '(pun)net ', 'show a punnet square' add '(pub)med to ', 'visit pubmed' add # ======================================================================= # # === q tag # ======================================================================= # add '(q) to exit/quit' # should always be last. e # ======================================================================= # # === r tag # ======================================================================= # add '(ra)ndom to generate random DNA or random '\ 'Aminoacids (the latter when given two arguments)' add '(rest)riction sites to show some restriction sites' add '(rest) <sequence> to find restriction sites within a given' add '(replay) to replay (or save) input-history' add '(reverse) to simply display the reversed main DNA sequence '\ 'presently in use' add '(reverse!) to not only display the reversed main DNA sequence '\ 'presently in use, but to also assign it as the new DNA sequence' # ======================================================================= # # === s tag # ======================================================================= # add '(save) to save the main string to a file' add '(seq)uence to assign a DNA sequence to use ' add '(sscompare) to ', 'compare two different strings, '\ 'with + and . characters - or | rather than +' add '(shuffle) to re-arrange the nucleotide string' add '(shine) to search for a ', colourize: 'Shine-Dalgarno Sequence' add '(sub)string to find the longest common substring of two strings' add '(shorten_aminoacid) to shorten a 3 letter Aminoacid to '\ '1 letter' add '(showorf) will show all ORFs in the given DNA sequence' add '(split) to split the sequence into chunks of n size, such as: split 3' add '(stop?) will show all STOP codons in the given '\ 'sequence' add # ======================================================================= # # === t tag # ======================================================================= # add '(tata?, TATA?) to find a TATA consensus sequence' add '(dna_translate) to give out the complementary '\ 'DNA sequence. Example: dna_translate GCATCTGCATTCGA' # This line belongs to dna_translate add '(to_protein) convert a DNA sequence to an Amino Acid Sequence.' add '(taxonomy) to list some taxonomy thingies' add '(to_rna) convert', 'DNA to RNA' add '(to_dna) convert', 'RNA to DNA' add '(t)ranslate to translate aminoacids into their long '\ 'form (i.e. A -> Alanin)' add # ======================================================================= # # === u tag # ======================================================================= # add '(upcase) to upcase the main sequence' add '(uncola) to uncolourize an amino acid again' add add 'Note that you can also simply input the name of an amino acid '\ 'and we will' add 'feedback its -R group.' add # ======================================================================= # # === Special instructions # ======================================================================= # add 'You can add and remove nucleotides in a simple manner, via +3 '\ 'or -3, too.' end |
#expanded_middle_padding? ⇒ Boolean
#
expanded_middle_padding?
As middle_padding but returns a String with the properly padded format.
#
117 118 119 |
# File 'lib/bioroebe/shell/help/class.rb', line 117 def ' ' * middle_padding? end |
#left_padding? ⇒ Boolean
#
left_padding?
#
124 125 126 |
# File 'lib/bioroebe/shell/help/class.rb', line 124 def left_padding? @left_padding end |
#middle_padding? ⇒ Boolean
#
middle_padding?
How much to pad in the middle.
#
107 108 109 |
# File 'lib/bioroebe/shell/help/class.rb', line 107 def middle_padding? @middle_padding end |
#reset ⇒ Object
#
reset
#
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/bioroebe/shell/help/class.rb', line 83 def reset # ======================================================================= # # === @_ # ======================================================================= # @_ = ''.dup # This is the output/result string. # ======================================================================= # # === @middle_padding # ======================================================================= # @middle_padding = DEFAULT_MIDDLE_PADDING # Must be a number. # ======================================================================= # # === @left_padding # ======================================================================= # @left_padding = ' ' * N_LEFT_PADDING # This one will be prepended to the displayed input. # ======================================================================= # # === @what_to_show # ======================================================================= # @what_to_show = :everything end |
#run ⇒ Object
#
run
#
434 435 436 437 |
# File 'lib/bioroebe/shell/help/class.rb', line 434 def run build_help_string show_help end |
#show_help(display_this = @_) ⇒ Object Also known as: display_result
#
show_help
This method will show the help subsection for the BioShell.
#
427 428 429 |
# File 'lib/bioroebe/shell/help/class.rb', line 427 def show_help(display_this = @_) e "#{display_this}#{N}" end |
#use_konsole? ⇒ Boolean
#
use_konsole?
#
131 132 133 |
# File 'lib/bioroebe/shell/help/class.rb', line 131 def use_konsole? true end |