bioroebe 0.10.80 → 0.11.32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bioroebe might be problematic. Click here for more details.

Files changed (210) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3209 -2618
  3. data/bin/bioroebe +7 -1
  4. data/bioroebe.gemspec +3 -3
  5. data/doc/README.gen +3208 -2617
  6. data/doc/quality_control/commandline_applications.md +3 -3
  7. data/doc/todo/bioroebe_todo.md +2040 -2615
  8. data/lib/bioroebe/aminoacids/aminoacid_substitution.rb +1 -9
  9. data/lib/bioroebe/aminoacids/codon_percentage.rb +1 -9
  10. data/lib/bioroebe/aminoacids/deduce_aminoacid_sequence.rb +1 -9
  11. data/lib/bioroebe/aminoacids/display_aminoacid_table.rb +1 -0
  12. data/lib/bioroebe/aminoacids/show_hydrophobicity.rb +1 -6
  13. data/lib/bioroebe/base/colours_for_base/colours_for_base.rb +18 -8
  14. data/lib/bioroebe/base/commandline_application/commandline_arguments.rb +13 -11
  15. data/lib/bioroebe/base/commandline_application/misc.rb +26 -9
  16. data/lib/bioroebe/base/commandline_application/opn.rb +8 -8
  17. data/lib/bioroebe/base/commandline_application/reset.rb +3 -2
  18. data/lib/bioroebe/base/misc.rb +35 -0
  19. data/lib/bioroebe/base/prototype/misc.rb +11 -1
  20. data/lib/bioroebe/codon_tables/frequencies/parse_frequency_table.rb +2 -10
  21. data/lib/bioroebe/codons/possible_codons_for_this_aminoacid.rb +1 -9
  22. data/lib/bioroebe/codons/show_codon_tables.rb +6 -2
  23. data/lib/bioroebe/codons/show_codon_usage.rb +2 -1
  24. data/lib/bioroebe/constants/aminoacids_and_proteins.rb +1 -0
  25. data/lib/bioroebe/constants/database_constants.rb +1 -1
  26. data/lib/bioroebe/constants/files_and_directories.rb +31 -4
  27. data/lib/bioroebe/constants/misc.rb +20 -0
  28. data/lib/bioroebe/count/count_amount_of_nucleotides.rb +3 -0
  29. data/lib/bioroebe/crystal/README.md +2 -0
  30. data/lib/bioroebe/crystal/to_rna.cr +19 -0
  31. data/lib/bioroebe/data/README.md +11 -8
  32. data/lib/bioroebe/data/electron_microscopy/pos_example.pos +396 -0
  33. data/lib/bioroebe/data/electron_microscopy/test_particles.star +36 -0
  34. data/lib/bioroebe/electron_microscopy/coordinate_analyzer.rb +15 -18
  35. data/lib/bioroebe/{fasta_and_fastq/parse_fasta/run.rb → electron_microscopy/electron_microscopy_module.rb} +16 -8
  36. data/lib/bioroebe/electron_microscopy/fix_pos_file.rb +1 -9
  37. data/lib/bioroebe/electron_microscopy/flipy.rb +83 -0
  38. data/lib/bioroebe/electron_microscopy/parse_coordinates.rb +2 -10
  39. data/lib/bioroebe/electron_microscopy/read_file_xmd.rb +1 -9
  40. data/lib/bioroebe/electron_microscopy/simple_star_file_generator.rb +4 -9
  41. data/lib/bioroebe/fasta_and_fastq/autocorrect_the_name_of_this_fasta_file.rb +1 -9
  42. data/lib/bioroebe/fasta_and_fastq/compact_fasta_file/compact_fasta_file.rb +7 -9
  43. data/lib/bioroebe/fasta_and_fastq/fasta_defline/fasta_defline.rb +1 -5
  44. data/lib/bioroebe/fasta_and_fastq/fasta_to_yaml/fasta_to_yaml.rb +81 -0
  45. data/lib/bioroebe/fasta_and_fastq/parse_fasta/parse_fasta.rb +1460 -7
  46. data/lib/bioroebe/fasta_and_fastq/return_fasta_subsection_of_this_file.rb +11 -2
  47. data/lib/bioroebe/fasta_and_fastq/show_fasta_headers.rb +27 -12
  48. data/lib/bioroebe/fasta_and_fastq/simplify_fasta_header/simplify_fasta_header.rb +1 -5
  49. data/lib/bioroebe/fasta_and_fastq/split_this_fasta_file_into_chromosomes/constants.rb +0 -5
  50. data/lib/bioroebe/genome/README.md +4 -0
  51. data/lib/bioroebe/genome/genome.rb +67 -0
  52. data/lib/bioroebe/genomes/genome_pattern.rb +3 -9
  53. data/lib/bioroebe/gui/gtk +1 -0
  54. data/lib/bioroebe/gui/gtk3/controller/controller.rb +45 -27
  55. data/lib/bioroebe/gui/gtk3/dna_to_aminoacid_widget/dna_to_aminoacid_widget.rb +76 -50
  56. data/lib/bioroebe/gui/gtk3/fasta_table_widget/fasta_table_widget.rb +99 -21
  57. data/lib/bioroebe/gui/gtk3/hamming_distance/hamming_distance.rb +42 -28
  58. data/lib/bioroebe/gui/gtk3/nucleotide_analyser/nucleotide_analyser.rb +119 -71
  59. data/lib/bioroebe/gui/gtk3/protein_to_DNA/protein_to_DNA.rb +18 -18
  60. data/lib/bioroebe/gui/gtk3/random_sequence/random_sequence.rb +19 -11
  61. data/lib/bioroebe/gui/libui/three_to_one/three_to_one.rb +8 -6
  62. data/lib/bioroebe/gui/shared_code/protein_to_DNA/protein_to_DNA_module.rb +14 -14
  63. data/lib/bioroebe/gui/swing/three_to_one/ThreeToOne$1.class +0 -0
  64. data/lib/bioroebe/gui/swing/three_to_one/ThreeToOne$CloseListener.class +0 -0
  65. data/lib/bioroebe/gui/swing/three_to_one/ThreeToOne.class +0 -0
  66. data/lib/bioroebe/gui/swing/three_to_one/ThreeToOne.java +141 -0
  67. data/lib/bioroebe/java/README.md +4 -0
  68. data/lib/bioroebe/java/bioroebe/Sequence.java +25 -1
  69. data/lib/bioroebe/java/bioroebe/src/main/java/bioroebe/Base.class +0 -0
  70. data/lib/bioroebe/java/bioroebe/{Base.java → src/main/java/bioroebe/Base.java} +15 -2
  71. data/lib/bioroebe/java/bioroebe/{BisulfiteTreatment.class → src/main/java/bioroebe/BisulfiteTreatment.class} +0 -0
  72. data/lib/bioroebe/java/bioroebe/{BisulfiteTreatment.java → src/main/java/bioroebe/BisulfiteTreatment.java} +0 -0
  73. data/lib/bioroebe/java/bioroebe/{Codons.class → src/main/java/bioroebe/Codons.class} +0 -0
  74. data/lib/bioroebe/java/bioroebe/src/main/java/bioroebe/Codons.java +34 -0
  75. data/lib/bioroebe/java/bioroebe/src/main/java/bioroebe/Commandline.class +0 -0
  76. data/lib/bioroebe/java/bioroebe/src/main/java/bioroebe/Commandline.java +95 -0
  77. data/lib/bioroebe/java/bioroebe/{Esystem.class → src/main/java/bioroebe/Esystem.class} +0 -0
  78. data/lib/bioroebe/java/bioroebe/{Esystem.java → src/main/java/bioroebe/Esystem.java} +0 -0
  79. data/lib/bioroebe/java/bioroebe/{GenerateRandomDnaSequence.class → src/main/java/bioroebe/GenerateRandomDnaSequence.class} +0 -0
  80. data/lib/bioroebe/java/bioroebe/{GenerateRandomDnaSequence.java → src/main/java/bioroebe/GenerateRandomDnaSequence.java} +8 -2
  81. data/lib/bioroebe/java/bioroebe/{IsPalindrome.class → src/main/java/bioroebe/IsPalindrome.class} +0 -0
  82. data/lib/bioroebe/java/bioroebe/{IsPalindrome.java → src/main/java/bioroebe/IsPalindrome.java} +5 -1
  83. data/lib/bioroebe/java/bioroebe/src/main/java/bioroebe/PartnerNucleotide.class +0 -0
  84. data/lib/bioroebe/java/bioroebe/src/main/java/bioroebe/PartnerNucleotide.java +56 -0
  85. data/lib/bioroebe/java/bioroebe/{RemoveFile.class → src/main/java/bioroebe/RemoveFile.class} +0 -0
  86. data/lib/bioroebe/java/bioroebe/{RemoveFile.java → src/main/java/bioroebe/RemoveFile.java} +10 -4
  87. data/lib/bioroebe/java/bioroebe/{RemoveNumbers.class → src/main/java/bioroebe/RemoveNumbers.class} +0 -0
  88. data/lib/bioroebe/java/bioroebe/{RemoveNumbers.java → src/main/java/bioroebe/RemoveNumbers.java} +1 -0
  89. data/lib/bioroebe/java/bioroebe/{ToCamelcase.class → src/main/java/bioroebe/ToCamelcase.class} +0 -0
  90. data/lib/bioroebe/java/bioroebe/{ToCamelcase.java → src/main/java/bioroebe/ToCamelcase.java} +3 -3
  91. data/lib/bioroebe/java/bioroebe/src/main/java/bioroebe/ToRNA.class +0 -0
  92. data/lib/bioroebe/java/bioroebe/src/main/java/bioroebe/ToRNA.java +42 -0
  93. data/lib/bioroebe/java/bioroebe/toplevel_methods/BaseComposition.class +0 -0
  94. data/lib/bioroebe/java/bioroebe/toplevel_methods/BaseComposition.java +73 -0
  95. data/lib/bioroebe/misc/ruler.rb +1 -0
  96. data/lib/bioroebe/nucleotides/most_likely_nucleotide_sequence_for_this_aminoacid_sequence.rb +1 -9
  97. data/lib/bioroebe/nucleotides/show_nucleotide_sequence.rb +7 -7
  98. data/lib/bioroebe/parsers/genbank_parser.rb +347 -26
  99. data/lib/bioroebe/parsers/gff.rb +1 -9
  100. data/lib/bioroebe/patterns/scan_for_repeat.rb +1 -5
  101. data/lib/bioroebe/pdb/fetch_fasta_sequence_from_pdb.rb +1 -9
  102. data/lib/bioroebe/pdb/parse_mmCIF_file.rb +1 -9
  103. data/lib/bioroebe/pdb/parse_pdb_file.rb +1 -9
  104. data/lib/bioroebe/project/project.rb +1 -1
  105. data/lib/bioroebe/python/README.md +1 -0
  106. data/lib/bioroebe/python/__pycache__/mymodule.cpython-39.pyc +0 -0
  107. data/lib/bioroebe/python/gui/gtk3/all_in_one.css +4 -0
  108. data/lib/bioroebe/python/gui/gtk3/all_in_one.py +59 -0
  109. data/lib/bioroebe/python/gui/gtk3/widget1.py +20 -0
  110. data/lib/bioroebe/python/gui/tkinter/all_in_one.py +91 -0
  111. data/lib/bioroebe/python/mymodule.py +8 -0
  112. data/lib/bioroebe/python/protein_to_dna.py +33 -0
  113. data/lib/bioroebe/python/shell/shell.py +19 -0
  114. data/lib/bioroebe/python/to_rna.py +14 -0
  115. data/lib/bioroebe/python/toplevel_methods/esystem.py +12 -0
  116. data/lib/bioroebe/python/toplevel_methods/open_in_browser.py +20 -0
  117. data/lib/bioroebe/python/toplevel_methods/palindromes.py +42 -0
  118. data/lib/bioroebe/python/toplevel_methods/rds.py +13 -0
  119. data/lib/bioroebe/python/toplevel_methods/shuffleseq.py +23 -0
  120. data/lib/bioroebe/python/toplevel_methods/three_delimiter.py +37 -0
  121. data/lib/bioroebe/python/toplevel_methods/time_and_date.py +43 -0
  122. data/lib/bioroebe/python/toplevel_methods/to_camelcase.py +21 -0
  123. data/lib/bioroebe/requires/require_the_bioroebe_project.rb +3 -1
  124. data/lib/bioroebe/sequence/nucleotide_module/nucleotide_module.rb +28 -25
  125. data/lib/bioroebe/sequence/protein.rb +105 -3
  126. data/lib/bioroebe/sequence/sequence.rb +61 -2
  127. data/lib/bioroebe/shell/menu.rb +3819 -3713
  128. data/lib/bioroebe/shell/misc.rb +51 -4311
  129. data/lib/bioroebe/shell/readline/readline.rb +1 -1
  130. data/lib/bioroebe/shell/shell.rb +11250 -28
  131. data/lib/bioroebe/siRNA/siRNA.rb +81 -1
  132. data/lib/bioroebe/string_matching/find_longest_substring.rb +3 -2
  133. data/lib/bioroebe/string_matching/hamming_distance.rb +1 -9
  134. data/lib/bioroebe/taxonomy/class_methods.rb +3 -8
  135. data/lib/bioroebe/taxonomy/constants.rb +4 -3
  136. data/lib/bioroebe/taxonomy/edit.rb +2 -1
  137. data/lib/bioroebe/taxonomy/help/help.rb +10 -10
  138. data/lib/bioroebe/taxonomy/info/check_available.rb +15 -9
  139. data/lib/bioroebe/taxonomy/info/info.rb +18 -11
  140. data/lib/bioroebe/taxonomy/info/is_dna.rb +46 -36
  141. data/lib/bioroebe/taxonomy/interactive.rb +140 -104
  142. data/lib/bioroebe/taxonomy/menu.rb +27 -18
  143. data/lib/bioroebe/taxonomy/parse_fasta.rb +3 -1
  144. data/lib/bioroebe/taxonomy/shared.rb +1 -0
  145. data/lib/bioroebe/taxonomy/taxonomy.rb +1 -0
  146. data/lib/bioroebe/toplevel_methods/aminoacids_and_proteins.rb +31 -24
  147. data/lib/bioroebe/toplevel_methods/colourize_related_methods.rb +164 -0
  148. data/lib/bioroebe/toplevel_methods/databases.rb +1 -1
  149. data/lib/bioroebe/toplevel_methods/fasta_and_fastq.rb +107 -63
  150. data/lib/bioroebe/toplevel_methods/file_and_directory_related_actions.rb +14 -2
  151. data/lib/bioroebe/toplevel_methods/misc.rb +118 -11
  152. data/lib/bioroebe/toplevel_methods/nucleotides.rb +22 -5
  153. data/lib/bioroebe/toplevel_methods/open_in_browser.rb +2 -0
  154. data/lib/bioroebe/toplevel_methods/palindromes.rb +1 -2
  155. data/lib/bioroebe/toplevel_methods/taxonomy.rb +2 -2
  156. data/lib/bioroebe/toplevel_methods/to_camelcase.rb +5 -0
  157. data/lib/bioroebe/utility_scripts/align_open_reading_frames.rb +1 -9
  158. data/lib/bioroebe/utility_scripts/check_for_mismatches/check_for_mismatches.rb +1 -9
  159. data/lib/bioroebe/utility_scripts/compacter.rb +1 -9
  160. data/lib/bioroebe/utility_scripts/compseq/compseq.rb +1 -9
  161. data/lib/bioroebe/utility_scripts/create_batch_entrez_file.rb +1 -9
  162. data/lib/bioroebe/utility_scripts/dot_alignment.rb +1 -9
  163. data/lib/bioroebe/utility_scripts/move_file_to_its_correct_location.rb +1 -4
  164. data/lib/bioroebe/utility_scripts/showorf/constants.rb +0 -5
  165. data/lib/bioroebe/utility_scripts/showorf/reset.rb +1 -4
  166. data/lib/bioroebe/version/version.rb +2 -2
  167. data/lib/bioroebe/www/embeddable_interface.rb +101 -52
  168. data/lib/bioroebe/www/sinatra/sinatra.rb +186 -70
  169. data/lib/bioroebe/yaml/aminoacids/amino_acids_long_name_to_one_letter.yml +2 -2
  170. data/lib/bioroebe/yaml/configuration/browser.yml +1 -1
  171. data/lib/bioroebe/yaml/genomes/README.md +3 -4
  172. data/lib/bioroebe/yaml/restriction_enzymes/restriction_enzymes.yml +3 -3
  173. metadata +69 -64
  174. data/doc/setup.rb +0 -1655
  175. data/lib/bioroebe/fasta_and_fastq/parse_fasta/constants.rb +0 -50
  176. data/lib/bioroebe/fasta_and_fastq/parse_fasta/initialize.rb +0 -86
  177. data/lib/bioroebe/fasta_and_fastq/parse_fasta/menu.rb +0 -117
  178. data/lib/bioroebe/fasta_and_fastq/parse_fasta/misc.rb +0 -981
  179. data/lib/bioroebe/fasta_and_fastq/parse_fasta/report.rb +0 -156
  180. data/lib/bioroebe/fasta_and_fastq/parse_fasta/reset.rb +0 -128
  181. data/lib/bioroebe/genbank/genbank_parser.rb +0 -291
  182. data/lib/bioroebe/java/bioroebe/Base.class +0 -0
  183. data/lib/bioroebe/java/bioroebe/Codons.java +0 -22
  184. data/lib/bioroebe/java/bioroebe/PartnerNucleotide.class +0 -0
  185. data/lib/bioroebe/java/bioroebe/PartnerNucleotide.java +0 -19
  186. data/lib/bioroebe/java/bioroebe.jar +0 -0
  187. data/lib/bioroebe/shell/add.rb +0 -108
  188. data/lib/bioroebe/shell/assign.rb +0 -360
  189. data/lib/bioroebe/shell/chop_and_cut.rb +0 -281
  190. data/lib/bioroebe/shell/constants.rb +0 -166
  191. data/lib/bioroebe/shell/download.rb +0 -335
  192. data/lib/bioroebe/shell/enable_and_disable.rb +0 -158
  193. data/lib/bioroebe/shell/enzymes.rb +0 -310
  194. data/lib/bioroebe/shell/fasta.rb +0 -345
  195. data/lib/bioroebe/shell/gtk.rb +0 -76
  196. data/lib/bioroebe/shell/history.rb +0 -132
  197. data/lib/bioroebe/shell/initialize.rb +0 -217
  198. data/lib/bioroebe/shell/loop.rb +0 -74
  199. data/lib/bioroebe/shell/prompt.rb +0 -107
  200. data/lib/bioroebe/shell/random.rb +0 -289
  201. data/lib/bioroebe/shell/reset.rb +0 -335
  202. data/lib/bioroebe/shell/scan_and_parse.rb +0 -135
  203. data/lib/bioroebe/shell/search.rb +0 -337
  204. data/lib/bioroebe/shell/sequences.rb +0 -200
  205. data/lib/bioroebe/shell/show_report_and_display.rb +0 -2901
  206. data/lib/bioroebe/shell/startup.rb +0 -127
  207. data/lib/bioroebe/shell/taxonomy.rb +0 -14
  208. data/lib/bioroebe/shell/tk.rb +0 -23
  209. data/lib/bioroebe/shell/user_input.rb +0 -88
  210. data/lib/bioroebe/shell/xorg.rb +0 -45
@@ -1,289 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # Encoding: UTF-8
3
- # frozen_string_literal: true
4
- # =========================================================================== #
5
- # require 'bioroebe/shell/random.rb'
6
- # =========================================================================== #
7
- module Bioroebe
8
-
9
- class Shell < ::Bioroebe::CommandlineApplication
10
-
11
- require 'bioroebe/constants/files_and_directories.rb'
12
-
13
- # ========================================================================= #
14
- # === random (random tag, rand tag)
15
- #
16
- # This will generate a random DNA sequence or a random aminoacid
17
- # sequence.
18
- #
19
- # The first argument tells us how many nucleotides or amino acids
20
- # should be part of that sequence.
21
- #
22
- # If a second argument was given, we will generate AA. Otherwise we
23
- # will generate DNA (which is the default).
24
- #
25
- # Usage examples:
26
- #
27
- # random dna
28
- # random dna 20
29
- # random 2552
30
- # random 2552 aa
31
- #
32
- # ========================================================================= #
33
- def random(
34
- n_elements = default_length?,
35
- dna_or_amino_acid = :dna,
36
- do_report_the_sequence = false
37
- )
38
- # ====================================================================== #
39
- # === First handle Arrays
40
- # ====================================================================== #
41
- if dna_or_amino_acid.is_a? Array
42
- dna_or_amino_acid = dna_or_amino_acid.first
43
- end
44
- case n_elements.to_s
45
- # ====================================================================== #
46
- # === aminoacids
47
- # ====================================================================== #
48
- when 'aminoacids',
49
- /^aa$/i
50
- five_steps_array = [] # An array from 5 to 50, in 5 steps.
51
- 5.step(50, 5) { |entry| five_steps_array << entry }
52
- n_elements = 200+five_steps_array.sample
53
- dna_or_amino_acid = :aminoacids
54
- # ====================================================================== #
55
- # === do_not_show_the_string
56
- # ====================================================================== #
57
- when 'do_not_show_the_string'
58
- dna_or_amino_acid = :dna
59
- n_elements = default_length?
60
- do_report_the_sequence = false
61
- # ====================================================================== #
62
- # === dna
63
- # ====================================================================== #
64
- when 'dna','' # This also handles nil.
65
- n_elements = default_length?
66
- if only_numbers?(dna_or_amino_acid)
67
- n_elements = dna_or_amino_acid.to_i
68
- end
69
- dna_or_amino_acid = :dna
70
- # ====================================================================== #
71
- # === nil
72
- # ====================================================================== #
73
- when nil
74
- n_elements = default_length? # defaults to 1000.
75
- end
76
- # ====================================================================== #
77
- # If input has NOT only numbers alone:
78
- # ====================================================================== #
79
- if n_elements.to_s !~ /^\d+$/
80
- n_elements = default_length?
81
- end
82
- dna_or_amino_acid = dna_or_amino_acid.to_s
83
- # ====================================================================== #
84
- # === Handle DNA or amino acid as input next
85
- # ====================================================================== #
86
- case dna_or_amino_acid
87
- # ====================================================================== #
88
- # === dna
89
- # ====================================================================== #
90
- when 'dna',
91
- 'd',
92
- 'default',
93
- ''
94
- # '' is also the default for this.
95
- erev 'Generating some DNA of length '+
96
- simp(n_elements.to_s)+rev+'.'
97
- if seq_object?.type?.nil?
98
- seq_object?.is_DNA_now
99
- require 'bioroebe/sequence/nucleotide_module/nucleotide_module.rb'
100
- seq_object?.extend(Bioroebe::NucleotideModule)
101
- else
102
- unless seq_object?.respond_to? :n_random_dna
103
- require 'bioroebe/sequence/nucleotide_module/nucleotide_module.rb'
104
- seq_object?.extend(Bioroebe::NucleotideModule)
105
- end
106
- end
107
- sequence = seq_object?.n_random_dna(n_elements)
108
- set_dna_sequence(sequence)
109
- # ====================================================================== #
110
- # === aminoacids
111
- # ====================================================================== #
112
- when 'aminoacids',
113
- 'aminoacid',
114
- 'aa'
115
- e 'Generating some ('+sfancy(n_elements.to_s)+rev+') AminoAcids next.'
116
- _ = set_aminoacids(:generate, n_elements, :be_silent) # We are silent here because we report lateron anyway.
117
- output = _
118
- end
119
- # ======================================================================= #
120
- # Next, show this string if we also wish to report the sequence.
121
- # ======================================================================= #
122
- show_string(output) if do_report_the_sequence
123
- return _ # Last but not least, return it.
124
- end
125
-
126
- # ========================================================================= #
127
- # === generate_random_dna_sequence_with_variable_length_and_variable_composition
128
- #
129
- # This method will generate a random DNA sequence of variable
130
- # length and composition.
131
- # ========================================================================= #
132
- def generate_random_dna_sequence_with_variable_length_and_variable_composition
133
- e 'Input the desired length of your DNA string:'
134
- length = $stdin.gets.chomp.to_i
135
- e 'Input the percentage of Adenine, Thymin, Cytosine and Guanosine. You can'
136
- e 'omit this, in which case we will default to 25% each.'
137
- e 'Use a / as delimiter please, as in '+
138
- orange('30 / 30 / 20 / 20')+rev+'.'
139
- e
140
- print 'Adenine / Thymin / Cytosine / Guanosine: '
141
- composition = $stdin.gets.chomp
142
- if composition.include? '/'
143
- splitted = composition.split('/').
144
- map(&:strip).map(&:to_f)
145
- else
146
- splitted = [25,25,25,25]
147
- end
148
- # ======================================================================= #
149
- # Next, we fill in our pool of nucleotides.
150
- # ======================================================================= #
151
- pool_of_nucleotides = []
152
- # ======================================================================= #
153
- # Next, we must determine how many we will use. The percentage value
154
- # tells us this.
155
- # The entries are e. g. 35%. So we first must calculate how much is
156
- # 1%, then we multiply this.
157
- # ======================================================================= #
158
- n_A = (length.to_f / 100) * splitted[0].to_f
159
- n_T = (length.to_f / 100) * splitted[1].to_f
160
- n_C = (length.to_f / 100) * splitted[2].to_f
161
- n_G = (length.to_f / 100) * splitted[3].to_f
162
- pool_of_nucleotides << (['A'] * n_A)
163
- pool_of_nucleotides << (['T'] * n_T)
164
- pool_of_nucleotides << (['C'] * n_C)
165
- pool_of_nucleotides << (['G'] * n_G)
166
- pool_of_nucleotides.flatten!
167
- _ = ''.dup # This is the return string.
168
- _ << pool_of_nucleotides.shuffle.join
169
- return _
170
- end
171
-
172
- # ========================================================================= #
173
- # === return_random_nucleotide
174
- #
175
- # Here we return a random nucleotide.
176
- # ========================================================================= #
177
- def return_random_nucleotide
178
- Bioroebe.return_random_nucleotide
179
- end; alias add_nucleotide return_random_nucleotide # === add_nucleotide
180
-
181
- # ========================================================================= #
182
- # === random_dna_sequence
183
- #
184
- # Generate a random DNA sequence. Note that this will return a String -
185
- # if you wish to put this onto a Sequence object then you have to
186
- # handle this situation on your own.
187
- #
188
- # The argument shall be how many DNA nucleotides you want to have.
189
- # ========================================================================= #
190
- def random_dna_sequence(
191
- length = 250
192
- )
193
- ::Bioroebe.generate_random_dna_sequence(length)
194
- end
195
-
196
- # ========================================================================= #
197
- # === random_insert
198
- #
199
- # Use this method to do a random insert into your main DNA sequence.
200
- #
201
- # The input should be a nucleotide sequence such as ATGCCA, but it can
202
- # also be a number - see the examples below for that.
203
- #
204
- # Note that this method will insert the given input into ONE random
205
- # position of our main sequence.
206
- #
207
- # To use this, try:
208
- #
209
- # random 15; rinsert ATTGGGCCC
210
- # random 15; rinsert 5
211
- # random 15; rinsert 15
212
- #
213
- # ========================================================================= #
214
- def random_insert(i)
215
- i = i.join if i.is_a? Array
216
- i.delete!(' ')
217
- if i =~ /\d+$/ # If it has at the least one number.
218
- _ = ''
219
- i.to_i.times { _ << return_random_nucleotide }
220
- e "The #{simp(i.to_i.to_s)}#{rev} nucleotides to be added "\
221
- "will be `#{sfancy(_)}#{rev}`."
222
- i = _
223
- end
224
- # ======================================================================= #
225
- # We need to determine the insert position. The insert_position can
226
- # be 0 zoo.
227
- # ======================================================================= #
228
- insert_position = rand(sequence?.size)
229
- n_nucleotides = i.size.to_s
230
- e 'Inserting '+sfancy(n_nucleotides.to_s)+rev+' nucleotides at '\
231
- 'nucleotide position '+simp(insert_position.to_s)+rev+'.'
232
- old_size = @sequence.size
233
- @sequence[insert_position+1, 0] = i
234
- e 'The old size was '+sfancy(old_size.to_s)+rev+'. The new '\
235
- 'size is '+sfancy(@sequence.size.to_s)+rev+'.'
236
- end
237
-
238
- # ========================================================================= #
239
- # === create_n_random_amino_acids
240
- # ========================================================================= #
241
- def create_n_random_amino_acids(n = 1000)
242
- set_aminoacids :random, n, :be_verbose
243
- end
244
-
245
- # ========================================================================= #
246
- # === set_aminoacids
247
- #
248
- # Simply delegate to set_aminoacids.
249
- # ========================================================================= #
250
- def set_random_aminoacids
251
- set_aminoacids :random
252
- end
253
-
254
- # ========================================================================= #
255
- # === generate_random_protein_sequence_with_variable_length_and_variable_composition
256
- #
257
- # Use this method to generate a random protein sequence with variable
258
- # length and variable composition.
259
- # ========================================================================= #
260
- def generate_random_protein_sequence_with_variable_length_and_variable_composition
261
- _ = {} # This is our hash.
262
- e 'You can generate a random protein sequence next. First, input the'
263
- print 'target length of the protein in question: '
264
- length = $stdin.gets.chomp.to_i
265
- e
266
- e 'Next, you have to input the percentage for the respective amino '\
267
- 'acids, separated via the token '+orange('/')+rev+'.'
268
- e
269
- e 'This can be quite tedious though. Unfortunately, there is not a'
270
- e 'much simpler way possible on the commandline, so here we go:'
271
- e
272
- print 'Glycine Alanine Valine: '
273
- glycine_alanine_valine = $stdin.gets.chomp
274
- glycine, alanine, valine = glycine_alanine_valine.split('/').map(&:strip)
275
- _['glycine'] = glycine
276
- _['alanine'] = alanine
277
- _['valine'] = valine
278
- e 'The length of the target protein is '+simp(length.to_s)+'.'
279
- e swarn('!!! THE ABOVE CODE ^^^ IS UNFINISHED !!!!!')+rev
280
- end
281
-
282
- # ========================================================================= #
283
- # === return_random_aminoacid
284
- # ========================================================================= #
285
- def return_random_aminoacid
286
- Bioroebe.return_random_aminoacid
287
- end
288
-
289
- end; end
@@ -1,335 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # Encoding: UTF-8
3
- # frozen_string_literal: true
4
- # =========================================================================== #
5
- # require 'bioroebe/shell/reset.rb'
6
- # =========================================================================== #
7
- module Bioroebe
8
-
9
- class Shell < ::Bioroebe::CommandlineApplication
10
-
11
- require 'bioroebe/raw_sequence/raw_sequence.rb'
12
- require 'bioroebe/nucleotides/show_nucleotide_sequence.rb'
13
-
14
- # ========================================================================= #
15
- # === reset (reset tag)
16
- # ========================================================================= #
17
- def reset(
18
- be_verbose = true
19
- )
20
- super()
21
- # ======================================================================= #
22
- # First we try to enable the configuration.
23
- # ======================================================================= #
24
- enable_configuration
25
- reset_to_initial_state(be_verbose)
26
- set_default_length # Set the default length of 1000 here.
27
- # ======================================================================= #
28
- # Make sure that the base directories exist.
29
- # ======================================================================= #
30
- ensure_that_the_base_directories_exist
31
- if defined? DEFAULT_DNA_INPUT_YAML_FILE # Main DNA string.
32
- set_string(DEFAULT_DNA_INPUT_YAML_FILE)
33
- end
34
- end
35
-
36
- require 'bioroebe/sequence/sequence.rb'
37
- # ========================================================================= #
38
- # === initialize_main_sequence
39
- #
40
- # Initialize a Sequence-object on startup. We use the length 150
41
- # for now.
42
- # ========================================================================= #
43
- def initialize_main_sequence
44
- @internal_hash[:array_dna_sequence] << Bioroebe::Sequence.new(250)
45
- end; alias reset_string initialize_main_sequence # === reset_string
46
-
47
- # ========================================================================= #
48
- # === reset_to_initial_state
49
- # ========================================================================= #
50
- def reset_to_initial_state(
51
- be_verbose = true
52
- )
53
- # ======================================================================= #
54
- # === @internal_hash
55
- #
56
- # The internal Hash can be used to store internal behaviour variables
57
- # rather than spawn so many different instance variables.
58
- #
59
- # It should be defined very early in this method.
60
- # ======================================================================= #
61
- @internal_hash = {}
62
- # ======================================================================= #
63
- # === :first_argument
64
- #
65
- # This variable refers to the first argument passed into a method,
66
- # from the menu.rb file.
67
- # ======================================================================= #
68
- @internal_hash[:first_argument] = nil
69
- # ======================================================================= #
70
- # === :show_nucleotide_sequence
71
- # ======================================================================= #
72
- @internal_hash[:show_nucleotide_sequence] = ::Bioroebe::ShowNucleotideSequence.new(
73
- '', :do_not_run_yet
74
- )
75
- # ======================================================================= #
76
- # === :array_aminoacid_sequence
77
- #
78
- # This variable should be an empty Array, aka [], initially, so that we
79
- # can distinguish the case when the user has added data onto that
80
- # Array.
81
- # ======================================================================= #
82
- @internal_hash[:array_aminoacid_sequence] = []
83
- # ======================================================================= #
84
- # === :array_rna_sequence
85
- #
86
- # This can be populated with sequence objects such as:
87
- #
88
- # Bioroebe::Sequence.new(''.dup, :rna)
89
- #
90
- # ======================================================================= #
91
- @internal_hash[:array_rna_sequence] = []
92
- # ======================================================================= #
93
- # === :array_dna_sequence
94
- # ======================================================================= #
95
- @internal_hash[:array_dna_sequence] = []
96
- # ======================================================================= #
97
- # === @use_working_directory_as_prompt
98
- # ======================================================================= #
99
- @internal_hash[:use_working_directory_as_prompt] = false
100
- # ======================================================================= #
101
- # === @debug
102
- #
103
- # Determine whether we will debug or whether we will not
104
- # ======================================================================= #
105
- @internal_hash[:debug] = SHALL_WE_DEBUG
106
- # ======================================================================= #
107
- # === @array_sequences
108
- # ======================================================================= #
109
- @internal_hash[:array_sequences] = []
110
- # ======================================================================= #
111
- # === @all_arguments
112
- # ======================================================================= #
113
- @internal_hash[:all_arguments] = []
114
- # ======================================================================= #
115
- # === :remaining_arguments
116
- # ======================================================================= #
117
- @internal_hash[:remaining_arguments] = []
118
- # ======================================================================= #
119
- # === :registered_actions
120
- # ======================================================================= #
121
- @internal_hash[:registered_actions] = ARRAY_REGISTERED_ACTIONS
122
- # ======================================================================= #
123
- # === :the_main_sequence_is_frozen
124
- # ======================================================================= #
125
- @internal_hash[:the_main_sequence_is_frozen] = false
126
- # ======================================================================= #
127
- # === :file_dna_string_saved
128
- #
129
- # Where to store our DNA string by default.
130
- # ======================================================================= #
131
- @internal_hash[:file_dna_string_saved] = "#{log_dir?}dna_string_saved.yml"
132
- # ======================================================================= #
133
- # === :array_jumper_directories
134
- # ======================================================================= #
135
- @internal_hash[:array_jumper_directories] = []
136
- # ======================================================================= #
137
- # === :array_fasta
138
- # ======================================================================= #
139
- @internal_hash[:array_fasta] = []
140
- # ======================================================================= #
141
- # === :raw_sequence
142
- # ======================================================================= #
143
- @internal_hash[:raw_sequence] = Bioroebe::RawSequence.new
144
- # ======================================================================= #
145
- # === :use_xsel
146
- #
147
- # This method will determine whether we will use the external
148
- # program "xsel". By default, at the least on my home system,
149
- # I prefer to make use of xsel.
150
- # ======================================================================= #
151
- @internal_hash[:use_xsel] = true
152
- # ======================================================================= #
153
- # === :silent_startup
154
- #
155
- # This variable keeps track as to whether we will display a welcome
156
- # message on startup or whether we will not.
157
- # ======================================================================= #
158
- @internal_hash[:silent_startup] = false
159
- # ======================================================================= #
160
- # === exit_the_shell_how
161
- #
162
- # The next variable has two valid modes:
163
- #
164
- # :instantly
165
- # :exit_gracefully
166
- #
167
- # The first is the default; the second can be used if the Bioshell
168
- # is embedded into another program.
169
- # ======================================================================= #
170
- @internal_hash[:exit_the_shell_how] = :instantly
171
- # ======================================================================= #
172
- # === search_for
173
- #
174
- # This is the sequence we wish to find, in a given nucleotide sequence.
175
- # By default this will be nil.
176
- # ======================================================================= #
177
- @internal_hash[:search_for] = nil
178
- # ======================================================================= #
179
- # === analyse_the_local_dataset_on_startup
180
- #
181
- # If this setting is set to true then, on startup, the bioshell
182
- # will report some information about the local dataset (FASTA
183
- # files and pdb files).
184
- # ======================================================================= #
185
- @internal_hash[:analyse_the_local_dataset_on_startup] = true
186
- # ======================================================================= #
187
- # === user_input
188
- # ======================================================================= #
189
- @internal_hash[:user_input] = nil
190
- # ======================================================================= #
191
- # === array_history
192
- #
193
- # This array will keep track of the input-history, aka the commands
194
- # that the user has used.
195
- # ======================================================================= #
196
- @internal_hash[:array_history] = []
197
- # ======================================================================= #
198
- # === remove_last_character_if_it_is_a_question_mark
199
- #
200
- # If this variable is set to true then we will remove the last
201
- # input character - at the least if it is a '?'.
202
- # ======================================================================= #
203
- @internal_hash[:remove_last_character_if_it_is_a_question_mark] = false
204
- # ======================================================================= #
205
- # === prompt_to_use
206
- #
207
- # This variable keeps track as to which prompt is to be used.
208
- # ======================================================================= #
209
- @internal_hash[:prompt_to_use] = :default
210
- # ======================================================================= #
211
- # === use_xsel
212
- # ======================================================================= #
213
- @internal_hash[:use_xsel] = false
214
- # ======================================================================= #
215
- # === search_for
216
- # ======================================================================= #
217
- @internal_hash[:search_for] = nil
218
- # ======================================================================= #
219
- # === coding_area
220
- # ======================================================================= #
221
- @internal_hash[:coding_area] = nil # This can keep track of the real coding area.
222
- # ======================================================================= #
223
- # === misc_sequence
224
- # ======================================================================= #
225
- @internal_hash[:misc_sequence] = nil # This can store a misc DNA or RNA sequence.
226
- # ======================================================================= #
227
- # === fasta_file
228
- #
229
- # This used to be a standalone @hash variable, but during the
230
- # rewrite in April 2020 this was integrated into @internal_hash.
231
- # ======================================================================= #
232
- @internal_hash[:fasta_file] = {}
233
- # ======================================================================= #
234
- # === @array_all_downloads
235
- # ======================================================================= #
236
- @internal_hash[:array_all_downloads] = [] # Must be an Array.
237
- # ======================================================================= #
238
- # === @use_working_directory_as_prompt
239
- # ======================================================================= #
240
- @internal_hash[:use_working_directory_as_prompt] = true
241
- # ======================================================================= #
242
- # === @mode
243
- #
244
- # @mode can be either :dna or :rna or :aminoacid
245
- # ======================================================================= #
246
- @internal_hash[:mode] = :dna
247
- # ======================================================================= #
248
- # === @array_these_sequences_were_chopped_away
249
- #
250
- # Keep an Array that can be used to keep track of which sequences
251
- # were chopped away. Whenever we perform a chop-related action we
252
- # will store that sequence in an Array.
253
- # ======================================================================= #
254
- @internal_hash[:array_these_sequences_were_chopped_away] = []
255
- # ======================================================================= #
256
- # === @save_file
257
- # ======================================================================= #
258
- @internal_hash[:save_file] = BIOSHELL_SAVE_FILE
259
- # ======================================================================= #
260
- # === create_directories_on_startup_of_the_shell
261
- #
262
- # If this variable is set to true then the bio-shell will create
263
- # some directories on startup. The user can modify this from
264
- # the commandline, though, and specifically disable it.
265
- # ======================================================================= #
266
- @internal_hash[:create_directories_on_startup_of_the_shell] = true
267
- # ======================================================================= #
268
- # === show_the_leader
269
- # ======================================================================= #
270
- @internal_hash[:show_the_leader] = true # Show the 5' leader.
271
- # ======================================================================= #
272
- # === show_the_trailer
273
- # ======================================================================= #
274
- @internal_hash[:show_the_trailer] = true # Show the 3' trailer.
275
- # ======================================================================= #
276
- # === array_timer_snapshots
277
- # ======================================================================= #
278
- @internal_hash[:array_timer_snapshots] = [] # This Array keeps track of the time.
279
- # ======================================================================= #
280
- # === may_we_show_the_startup_information
281
- #
282
- # This variable determines whether the startup-information may be
283
- # shown, on start-up of the bioshell. By default this will be true
284
- # typically, but a config-variable may overrule this.
285
- # ======================================================================= #
286
- @internal_hash[:may_we_show_the_startup_information] = true
287
- if @config and @config.respond_to? :may_we_show_the_startup_information
288
- @internal_hash[:may_we_show_the_startup_information] = @config.may_we_show_the_startup_information
289
- end
290
- # ======================================================================= #
291
- # === @use_colours
292
- #
293
- # Let's enable the colours.
294
- # ======================================================================= #
295
- enable_colours(:be_quiet)
296
- initialize_clipboard
297
- # ======================================================================= #
298
- # === @sequence
299
- #
300
- # We set @sequence to a new instance of Bioroebe::Sequence next.
301
- # ======================================================================= #
302
- initialize_main_sequence
303
- # ======================================================================= #
304
- # === Setting towards a default padding
305
- #
306
- # Next comes left-padding, defaulting to ' '. This should come after
307
- # the clipboard has been initialized, and after @internal_hash has
308
- # been populated.
309
- # ======================================================================= #
310
- set_padding :default
311
- set_sequence_2
312
- set_sequence_3
313
- set_sequence_4
314
- set_sequence_5
315
- set_sequence_6
316
- ::Bioroebe.clear_array_colourize_this_aminoacid
317
- # ======================================================================= #
318
- # === Determine whether silent startup is active
319
- #
320
- # Next, determine whether we will show a small startup-message or
321
- # whether we shall not show it. By default this should be false -
322
- # but if a file called 'use_silent_startup.yml' exists then we
323
- # will use that file.
324
- # ======================================================================= #
325
- if File.exist? FILE_USE_SILENT_STARTUP
326
- dataset = YAML.load_file(FILE_USE_SILENT_STARTUP)
327
- if dataset.is_a?(Hash) and dataset.has_key?('use_silent_startup')
328
- @internal_hash[:silent_startup] = dataset['use_silent_startup']
329
- end
330
- else # else it is
331
- @internal_hash[:silent_startup] = false
332
- end
333
- end
334
-
335
- end; end