Class: Bioroebe::Shell::Help
- Inherits:
-
CommandlineApplication
- Object
- Base
- CommandlineApplication
- 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
- RAW_TITLE =
#
RAW_TITLE
#
'BioShell Help Options:'
- TITLE =
#
TITLE
This constant specifies the title that we will use for the bioshell help options. Since as of November 2023 this constant is not as important anymore, as we return the title dynamically, via RAW_TITLE.
#
"#{::Bioroebe.rev}#{RAW_TITLE}"
Constants inherited from CommandlineApplication
CommandlineApplication::OLD_VERBOSE_VALUE
Constants included from ColoursForBase
ColoursForBase::ARRAY_HTML_COLOURS_IN_USE
Constants inherited from Base
Class Method Summary collapse
-
.[](i = ARGV) ⇒ 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 ========================================================================= #.
-
#result? ⇒ Boolean
# === result? ========================================================================= #.
-
#run ⇒ Object
# === run ========================================================================= #.
-
#set_use_colours(i = true) ⇒ Object
# === set_use_colours ========================================================================= #.
-
#show_help(display_this = @_) ⇒ Object
(also: #display_result)
# === show_help.
-
#title? ⇒ Boolean
# === title? ========================================================================= #.
-
#use_konsole? ⇒ Boolean
# === use_konsole? ========================================================================= #.
Methods inherited from CommandlineApplication
#all_aminoacids?, #append_what_into, #at_home?, #be_silent, #be_verbose?, #cat, #ccliner, #change_directory, #cliner, #codon_table_dataset?, #codon_to_aminoacid, #codons_for?, #colourize_this_dna_sequence, #complement, #cp, #disable_warnings, #download_dir?, #editor?, #enable_warnings, #ensure_that_the_base_directories_exist, #esystem, #extract, #is_this_a_start_codon?, #is_this_a_stop_codon?, #leading_five_prime, #load_bioroebe_yaml_file, #log_directory?, #one_letter_to_long_name, #one_to_three, #only_numbers?, #open_in_browser, #opnerev, #opnn, #pad_with_double_quotes, #pad_with_single_quotes, #partner_nucleotide, #remove_numbers, #remove_trailing_ansii_escape_code, #return_all_possible_start_codons, #return_array_of_one_letter_aminoacids, #return_cheerful_person, #return_chunked_display, #return_ubiquitin_sequence, #runmode?, #set_be_verbose, #set_runmode, #start_codon?, #stop_codons?, #strict_filter_away_invalid_aminoacids, #taxonomy_download_directory?, #three_to_one, #to_rna, #trailing_three_prime, #use_opn?, #verbose_truth, #was_or_were, #without_extname, #write_what_into
Methods included from BaseModule
#absolute_path, #default_file_read, #file_readlines
Methods included from CommandlineArguments
#commandline_arguments?, #commandline_arguments_that_are_files?, #e, #first?, #first_non_hyphen_argument?, #remove_hyphens_from_the_commandline_arguments, #return_commandline_arguments_as_string, #return_commandline_arguments_that_are_not_files, #return_entries_without_two_leading_hyphens, #select_commandline_arguments, #select_entries_starting_with_two_hyphens, #set_commandline_arguments
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 inherited from Base
#append_what_into, #can_base_pair?, #convert_global_env, #delete_file, #directory_to_the_codon_tables?, #is_on_roebe?, #is_palindrome?, #main_encoding?, #mkdir, #move_file, #mv, #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 InternalHashModule
#internal_hash?, #reset_the_internal_hash
Methods included from InferTheNamespaceModule
#infer_the_namespace, #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.
#
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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/bioroebe/shell/help/class.rb', line 52 def initialize( use_colours = true, run_already = true ) reset set_use_colours(use_colours) # ======================================================================= # # === Handle blocks next # # 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 case run_already # ======================================================================= # # === :do_not_run_yet # ======================================================================= # when :do_not_run_yet run_already = false end run if run_already end |
Class Method Details
.[](i = ARGV) ⇒ Object
#
Bioroebe::Shell::Help[]
#
484 485 486 |
# File 'lib/bioroebe/shell/help/class.rb', line 484 def self.[](i = ARGV) new(i) end |
Instance Method Details
#add(i = '', append_this = nil) ⇒ Object
#
add (add tag)
#
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 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 |
# File 'lib/bioroebe/shell/help/class.rb', line 371 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.
#
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 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 |
# File 'lib/bioroebe/shell/help/class.rb', line 164 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.
#
141 142 143 |
# File 'lib/bioroebe/shell/help/class.rb', line 141 def ' ' * middle_padding? end |
#left_padding? ⇒ Boolean
#
left_padding?
#
148 149 150 |
# File 'lib/bioroebe/shell/help/class.rb', line 148 def left_padding? @left_padding end |
#middle_padding? ⇒ Boolean
#
middle_padding?
How much to pad in the middle.
#
124 125 126 |
# File 'lib/bioroebe/shell/help/class.rb', line 124 def middle_padding? @middle_padding end |
#reset ⇒ Object
#
reset
#
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/bioroebe/shell/help/class.rb', line 99 def reset super() # ======================================================================= # # === @_ # ======================================================================= # @_ = ''.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 |
#result? ⇒ Boolean
#
result?
#
453 454 455 |
# File 'lib/bioroebe/shell/help/class.rb', line 453 def result? @_ end |
#run ⇒ Object
#
run
#
476 477 478 479 |
# File 'lib/bioroebe/shell/help/class.rb', line 476 def run build_help_string show_help end |
#set_use_colours(i = true) ⇒ Object
#
set_use_colours
#
460 461 462 463 464 465 466 467 468 469 470 471 |
# File 'lib/bioroebe/shell/help/class.rb', line 460 def set_use_colours( i = true ) case i # ======================================================================= # # === :do_not_use_colours # ======================================================================= # when :do_not_use_colours i = false end set_will_we_use_colours(i) end |
#show_help(display_this = @_) ⇒ Object Also known as: display_result
#
show_help
This method will show the help subsection for the BioShell.
#
362 363 364 365 366 |
# File 'lib/bioroebe/shell/help/class.rb', line 362 def show_help( display_this = @_ ) e "#{display_this}#{N}" end |
#title? ⇒ Boolean
#
title?
#
131 132 133 |
# File 'lib/bioroebe/shell/help/class.rb', line 131 def title? RAW_TITLE end |
#use_konsole? ⇒ Boolean
#
use_konsole?
#
155 156 157 |
# File 'lib/bioroebe/shell/help/class.rb', line 155 def use_konsole? true end |