bioroebe 0.10.80 → 0.11.12

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 (67) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +507 -310
  3. data/bioroebe.gemspec +3 -3
  4. data/doc/README.gen +506 -309
  5. data/doc/todo/bioroebe_todo.md +29 -40
  6. data/lib/bioroebe/aminoacids/display_aminoacid_table.rb +1 -0
  7. data/lib/bioroebe/base/colours_for_base/colours_for_base.rb +18 -8
  8. data/lib/bioroebe/base/commandline_application/commandline_arguments.rb +13 -11
  9. data/lib/bioroebe/base/commandline_application/misc.rb +18 -8
  10. data/lib/bioroebe/base/prototype/misc.rb +1 -1
  11. data/lib/bioroebe/codons/show_codon_tables.rb +6 -2
  12. data/lib/bioroebe/constants/aminoacids_and_proteins.rb +1 -0
  13. data/lib/bioroebe/constants/files_and_directories.rb +8 -1
  14. data/lib/bioroebe/count/count_amount_of_nucleotides.rb +3 -0
  15. data/lib/bioroebe/gui/gtk3/protein_to_DNA/protein_to_DNA.rb +18 -18
  16. data/lib/bioroebe/gui/shared_code/protein_to_DNA/protein_to_DNA_module.rb +14 -14
  17. data/lib/bioroebe/parsers/genbank_parser.rb +353 -24
  18. data/lib/bioroebe/python/README.md +1 -0
  19. data/lib/bioroebe/python/__pycache__/mymodule.cpython-39.pyc +0 -0
  20. data/lib/bioroebe/python/gui/gtk3/widget1.py +22 -0
  21. data/lib/bioroebe/python/mymodule.py +8 -0
  22. data/lib/bioroebe/python/protein_to_dna.py +30 -0
  23. data/lib/bioroebe/python/shell/shell.py +19 -0
  24. data/lib/bioroebe/python/to_rna.py +14 -0
  25. data/lib/bioroebe/python/toplevel_methods/to_camelcase.py +11 -0
  26. data/lib/bioroebe/sequence/nucleotide_module/nucleotide_module.rb +28 -25
  27. data/lib/bioroebe/sequence/sequence.rb +54 -2
  28. data/lib/bioroebe/shell/menu.rb +3336 -3304
  29. data/lib/bioroebe/shell/readline/readline.rb +1 -1
  30. data/lib/bioroebe/shell/shell.rb +11233 -28
  31. data/lib/bioroebe/siRNA/siRNA.rb +81 -1
  32. data/lib/bioroebe/string_matching/find_longest_substring.rb +3 -2
  33. data/lib/bioroebe/toplevel_methods/aminoacids_and_proteins.rb +31 -24
  34. data/lib/bioroebe/toplevel_methods/nucleotides.rb +22 -5
  35. data/lib/bioroebe/toplevel_methods/open_in_browser.rb +2 -0
  36. data/lib/bioroebe/toplevel_methods/to_camelcase.rb +5 -0
  37. data/lib/bioroebe/version/version.rb +2 -2
  38. data/lib/bioroebe/yaml/configuration/browser.yml +1 -1
  39. data/lib/bioroebe/yaml/restriction_enzymes/restriction_enzymes.yml +3 -3
  40. metadata +17 -36
  41. data/doc/setup.rb +0 -1655
  42. data/lib/bioroebe/genbank/genbank_parser.rb +0 -291
  43. data/lib/bioroebe/shell/add.rb +0 -108
  44. data/lib/bioroebe/shell/assign.rb +0 -360
  45. data/lib/bioroebe/shell/chop_and_cut.rb +0 -281
  46. data/lib/bioroebe/shell/constants.rb +0 -166
  47. data/lib/bioroebe/shell/download.rb +0 -335
  48. data/lib/bioroebe/shell/enable_and_disable.rb +0 -158
  49. data/lib/bioroebe/shell/enzymes.rb +0 -310
  50. data/lib/bioroebe/shell/fasta.rb +0 -345
  51. data/lib/bioroebe/shell/gtk.rb +0 -76
  52. data/lib/bioroebe/shell/history.rb +0 -132
  53. data/lib/bioroebe/shell/initialize.rb +0 -217
  54. data/lib/bioroebe/shell/loop.rb +0 -74
  55. data/lib/bioroebe/shell/misc.rb +0 -4341
  56. data/lib/bioroebe/shell/prompt.rb +0 -107
  57. data/lib/bioroebe/shell/random.rb +0 -289
  58. data/lib/bioroebe/shell/reset.rb +0 -335
  59. data/lib/bioroebe/shell/scan_and_parse.rb +0 -135
  60. data/lib/bioroebe/shell/search.rb +0 -337
  61. data/lib/bioroebe/shell/sequences.rb +0 -200
  62. data/lib/bioroebe/shell/show_report_and_display.rb +0 -2901
  63. data/lib/bioroebe/shell/startup.rb +0 -127
  64. data/lib/bioroebe/shell/taxonomy.rb +0 -14
  65. data/lib/bioroebe/shell/tk.rb +0 -23
  66. data/lib/bioroebe/shell/user_input.rb +0 -88
  67. data/lib/bioroebe/shell/xorg.rb +0 -45
@@ -1,360 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # Encoding: UTF-8
3
- # frozen_string_literal: true
4
- # =========================================================================== #
5
- # require 'bioroebe/shell/assign.rb'
6
- # =========================================================================== #
7
- module Bioroebe
8
-
9
- class Shell < ::Bioroebe::CommandlineApplication
10
-
11
- # ========================================================================= #
12
- # === set_dna_sequence (assign tag, assigning tag)
13
- #
14
- # This method can be used to set/assign the main DNA string.
15
- #
16
- # It is a fairly long method, mostly because it will do lots of
17
- # additional tasks, way aside from setting/assigning to a DNA
18
- # sequence only.
19
- #
20
- # As of June 2016, the method will also keep a backup of the
21
- # generated sequence in a local file as well. This will allow
22
- # us to "replay" the given sequence on startup of the shell.
23
- #
24
- # Note that as of Jun 2016, we will chop off any '"' found in
25
- # the input String.
26
- # ========================================================================= #
27
- def set_dna_sequence(
28
- i = nil,
29
- be_verbose = true,
30
- do_upcase = :check_for_config_value_here
31
- )
32
- if is_the_main_sequence_frozen?
33
- report_that_the_main_sequence_is_frozen
34
- return
35
- end
36
- case do_upcase
37
- # ======================================================================= #
38
- # === :check_for_config_value_here
39
- # ======================================================================= #
40
- when :check_for_config_value_here,
41
- :default
42
- if @config and @config.respond_to?(:upcase_nucleotides)
43
- do_upcase = @config.upcase_nucleotides
44
- else
45
- do_upcase = false
46
- end
47
- # ======================================================================= #
48
- # === :do_not_upcase
49
- # ======================================================================= #
50
- when :do_not_upcase
51
- do_upcase = false
52
- end
53
- if do_upcase
54
- shall_we_upcase = do_upcase if @config
55
- end
56
- # ======================================================================= #
57
- # === Sanitize the second variable next
58
- # ======================================================================= #
59
- case be_verbose
60
- # ======================================================================= #
61
- # === :be_verbose
62
- # ======================================================================= #
63
- when :be_verbose
64
- be_verbose = true
65
- # ======================================================================= #
66
- # === :do_not_upcase
67
- # ======================================================================= #
68
- when :do_not_upcase,
69
- :no_upcase,
70
- :no_upcasing,
71
- shall_we_upcase = false
72
- be_verbose = true # Sync this.
73
- # ======================================================================= #
74
- # === :be_silent
75
- # ======================================================================= #
76
- when :be_silent,
77
- :be_quiet
78
- be_verbose = false
79
- end
80
- if i.nil?
81
- # ===================================================================== #
82
- # === Hande nil value for the variable i next:
83
- #
84
- # Here in this entry point, we will handle if the first input
85
- # argument is nil.
86
- #
87
- # If @internal_hash[:misc_sequence] is NOT nil, then it will be used
88
- # once, then cleared. Otherwise, we will use dna_sequence?.
89
- # ===================================================================== #
90
- if @internal_hash[:misc_sequence]
91
- i = @internal_hash[:misc_sequence]
92
- @internal_hash[:misc_sequence] = nil # Set it to nil again.
93
- else
94
- i = dna_sequence?
95
- end
96
- end
97
- # ======================================================================= #
98
- # === Convert Array into String next
99
- # ======================================================================= #
100
- i = i.join if i.is_a? Array
101
- i = i.to_s # Work on a String past this point here.
102
- if i.include? ' ' # Sanitize the input a little bit.
103
- i = i.strip.delete(' ')
104
- end
105
- if i.include? '|' # I think we will not need '|' in our main string.
106
- i.delete!('|')
107
- end
108
- # ======================================================================= #
109
- # === If the input has only numbers
110
- # ======================================================================= #
111
- if i =~ /^\d+$/
112
- i = random_dna_sequence(i)
113
- end
114
- # ======================================================================= #
115
- # === Handle Fasta format next
116
- # ======================================================================= #
117
- if i.start_with?('>') and i.include?(N)
118
- erev 'It seems as if you have a FASTA sequence there, as it starts with '\
119
- 'a > character.'
120
- erev 'We will omit this first section (the header) though.'
121
- i[0 .. i.index(N)] = '' # This does the chop-off action.
122
- end
123
- i.delete!('-') if i.include? '-'
124
- i.delete!('_') if i.include? '_' # Don't want '_' characters.
125
- i.delete!('?') if i.include? '?'
126
- i.delete!('#') if i.include? '#' # This was added at 08.05.2016.
127
- i.delete!('"') if i.include? '"' # This was added at 02.06.2016.
128
- i.gsub!(/\^C/,'') if i.include? '^C'
129
- i = i.to_s.dup
130
- case i
131
- # ======================================================================= #
132
- # === :GFP
133
- # ======================================================================= #
134
- when ':GFP' # ← This means the default GFP sequence.
135
- i = return_default_GFP_sequence
136
- # ======================================================================= #
137
- # === random
138
- # ======================================================================= #
139
- when /^random$/i,
140
- '' # As of 04.01.2015, we will try '' too here.
141
- i = random :do_not_show_the_string
142
- # ======================================================================= #
143
- # === multiline
144
- # ======================================================================= #
145
- when 'multiline' # Handle multiline input.
146
- erev 'Multiline input detected.'
147
- erev 'Finish by issuing __ on an empty line. (These are 2 "_" tokens.)'
148
- i = $stdin.gets('__')
149
- # ===================================================================== #
150
- # Next, sanitize it a bit if it starts with a '>' identifier.
151
- # ===================================================================== #
152
- if i.strip.start_with? '>'
153
- i = i[(i.index(N)+1)..-1]
154
- end
155
- else
156
- if i
157
- # =================================================================== #
158
- # === Next upcase the input if the flag was set
159
- # =================================================================== #
160
- i.upcase! if shall_we_upcase
161
- case mode?
162
- # =================================================================== #
163
- # === :dna
164
- # =================================================================== #
165
- when :dna,
166
- :rna
167
- dna_sequence_object?.set_mode(mode?)
168
- # =================================================================== #
169
- # === :aminoacids
170
- # =================================================================== #
171
- when :aminoacids
172
- set_aminoacids(i)
173
- end
174
- else # else input is nil.
175
- erev 'Missing Input to assign_sequence(). Please input '\
176
- 'your DNA string now (Hitting the enter key will '\
177
- 'finish this):'
178
- i = $stdin.gets.chomp
179
- i = i.upcase if shall_we_upcase
180
- end
181
- end
182
- i = '' unless i
183
- # ======================================================================= #
184
- # === Remove possible newlines in the given input
185
- # ======================================================================= #
186
- i.delete!(N) if i.include? N
187
- i.delete!('_') if i.include? '_'
188
- # ======================================================================= #
189
- # Is faster than .gsub()# if i
190
- # i.upcase! # Since as of Feb 2016. Nope, disabled again as of May 2016.
191
- # end
192
- # ======================================================================= #
193
- if File.exist?(i) # Assume a file was given. Read its content then.
194
- if i.end_with? '.yml'
195
- i = YAML.load_file(i)
196
- else
197
- i = File.readlines(i).reject {|line|
198
- line.start_with? '>'
199
- }.join
200
- end
201
- end
202
- # ======================================================================= #
203
- # Also get rid of numbers.
204
- # ======================================================================= #
205
- i = i.dup if i.frozen?
206
- i.gsub!(/\d/,'')
207
- # ======================================================================= #
208
- # The DNA Sequence will be stored in the Sequence object directly.
209
- # The nil is required for now, because otherwise set_input() will
210
- # upcase the input by default.
211
- # ======================================================================= #
212
- if dna_sequence_object?.nil?
213
- _ = Bioroebe::Sequence.new(i.dup) { :is_DNA }
214
- @internal_hash[:array_dna_sequence] << _
215
- else
216
- # ===================================================================== #
217
- # Assign it here.
218
- # ===================================================================== #
219
- dna_sequence_object?.set_input(i.dup, nil) # We can re-use the old @sequence object.
220
- end
221
- # ======================================================================= #
222
- # === :coding_area
223
- #
224
- # Whenever the DNA sequence is modified like that, we will also reset
225
- # the "coding_area" entry in the internal Hash to the initial nil state.
226
- # ======================================================================= #
227
- @internal_hash[:coding_area] = nil
228
- # ======================================================================= #
229
- # === Report that we will perform an assignment next
230
- # ======================================================================= #
231
- if be_verbose # Check for verbosity
232
- case mode?
233
- when :dna
234
- if i.empty?
235
- erev 'Nothing was assigned yet.'
236
- else
237
- erev 'Setting DNA sequence to ('+
238
- sfancy(i.size.to_s)+
239
- rev+' nucleotides):'
240
- show_string
241
- end
242
- end
243
- end
244
- # ======================================================================= #
245
- # === Set the Xorg Buffer next
246
- # ======================================================================= #
247
- if @config and @config.respond_to?(:additionally_set_xorg_buffer) and
248
- @config.additionally_set_xorg_buffer
249
- begin
250
- set_xorg_buffer(i)
251
- rescue NoMethodError; end
252
- end
253
- unless i.empty? # We do not save empty nucleotide Strings.
254
- result = i.to_s.dup
255
- # ===================================================================== #
256
- # We will save into a file next.
257
- # ===================================================================== #
258
- this_file = "#{log_dir?}dna_string.yml"
259
- dna_sequence_object?.save_sequence_to_this_file(this_file) # Save it here.
260
- # ===================================================================== #
261
- # Since as of Jun 2016, we will also create a new RNA string.
262
- #
263
- # This has been disabled as of December 2021. It was too strange
264
- # to automatically create a RNA string.
265
- # ===================================================================== #
266
- # if @internal_hash[:array_rna_sequence]
267
- # @internal_hash[:array_rna_sequence].last.set_sequence(result)
268
- # end
269
- # ===================================================================== #
270
- # === Automatically assign the aminoacid sequence as well
271
- # ===================================================================== #
272
- _ = translate_dna_into_aminoacid(result)
273
- set_aminoacids(_, nil, :be_quiet)
274
- return result
275
- end
276
- end; alias set_dna_string set_dna_sequence # === set_dna_string
277
- alias set_string set_dna_sequence # === set_dna_sequence
278
- alias set_main_sequence set_dna_sequence # === set_main_sequence (set_main_sequence tag)
279
- alias set_sequence set_dna_sequence # === set_sequence (set_sequence tag)
280
- alias set_dna set_dna_sequence # === set_dna
281
- alias set_assign set_dna_sequence # === set_dna
282
- alias assign_sequence set_dna_sequence # === assign_sequence
283
- alias assign_dna_sequence set_dna_sequence # === assign_dna_sequence
284
- alias assign_this_dna_sequence set_dna_sequence # === assign_this_dna_sequence
285
- alias assign set_dna_sequence # === assign
286
-
287
- require 'bioroebe/aminoacids/create_random_aminoacids.rb'
288
- # ========================================================================= #
289
- # === set_aminoacids (assign protein tag, set aminoacids tag)
290
- #
291
- # Assign a protein sequence here. The first argument shall be the
292
- # aminoacid sequence in question.
293
- #
294
- # Usage example:
295
- #
296
- # assign_protein FLIMVSPTAYHQNKDECWRGX*
297
- #
298
- # ========================================================================= #
299
- def set_aminoacids(
300
- i = :random,
301
- how_many_to_generate = 1000, # Will only be applied if the input is :random or :generate
302
- be_verbose = true
303
- )
304
- # ======================================================================= #
305
- # === Sanitize the third argument next
306
- # ======================================================================= #
307
- case be_verbose
308
- when :be_silent,
309
- :be_quiet
310
- be_verbose = false
311
- end
312
- i = :random unless i
313
- case i
314
- # ======================================================================= #
315
- # === :random
316
- # ======================================================================= #
317
- when :random,
318
- :generate
319
- i = Bioroebe.create_random_aminoacids(how_many_to_generate) # Generate them here.
320
- end
321
- i = i.join if i.is_a? Array
322
- if i =~ /^\d+$/ # only numbers
323
- i = Bioroebe.create_random_aminoacids(i)
324
- end
325
- if be_verbose
326
- erev "Now assigning aminoacid sequence to: #{sfancy(i.to_s)}"
327
- end
328
- if i.is_a? String # Convert it into a Sequence object here.
329
- i = ::Bioroebe.sequence(i) { :aminoacid }
330
- end
331
- # ======================================================================= #
332
- # Do the assignment next.
333
- # ======================================================================= #
334
- if @internal_hash[:array_aminoacid_sequence].empty?
335
- @internal_hash[:array_aminoacid_sequence] << i
336
- else
337
- @internal_hash[:array_aminoacid_sequence].pop
338
- @internal_hash[:array_aminoacid_sequence] << i
339
- end
340
- end; alias assign_aminoacid_sequence set_aminoacids # === assign_aminoacid_sequence
341
- alias assign_protein_sequence set_aminoacids # === assign_protein_sequence
342
- alias set_aminoacid_sequence set_aminoacids # === set_aminoacid_sequence
343
-
344
- # ========================================================================= #
345
- # === report_that_a_string_must_be_assigned_first
346
- # ========================================================================= #
347
- def report_that_a_string_must_be_assigned_first
348
- erev 'No sequence has been assigned yet. Please first "'+
349
- sfancy('assign')+rev+'" a string.'
350
- end
351
-
352
- # ========================================================================= #
353
- # === assign_sequence2
354
- # ========================================================================= #
355
- def assign_sequence2(i)
356
- i = i.join(' ') if i.is_a? Array
357
- @internal_hash[:sequence2] = Bioroebe::Sequence.new(i)
358
- end
359
-
360
- end; end
@@ -1,281 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # Encoding: UTF-8
3
- # frozen_string_literal: true
4
- # =========================================================================== #
5
- # require 'bioroebe/shell/chop_and_cut.rb'
6
- # =========================================================================== #
7
- module Bioroebe
8
-
9
- class Shell < ::Bioroebe::CommandlineApplication
10
-
11
- # ========================================================================= #
12
- # === chop (chop tag)
13
- #
14
- # We use this method to get rid of some nucleotides, from the 3'
15
- # end of a nucleotide sequence (aka the "right hand side" of it) by
16
- # default.
17
- #
18
- # The first argument to this method tells us how many nucleotides are
19
- # to be removed.
20
- #
21
- # The second argument determines whether to chop from the right side
22
- # (the 3' side) or from the left side (the 5' side).
23
- # ========================================================================= #
24
- def chop(
25
- i = 1,
26
- chop_from_left_or_right_hand_side = :default # The default is the 3' end.
27
- ) # Default will be to chop off one nucleotide.
28
- if is_the_main_sequence_frozen?
29
- report_that_the_main_sequence_is_frozen
30
- return
31
- end
32
- i = i.first if i.is_a? Array
33
- if i == '?'
34
- e 'chop allows us to remove nucleotides from the main sequence.'
35
- return
36
- end
37
- i = 1 if i.nil? # Assign to the default then.
38
- i = i.to_i # Need a number past this point.
39
- if i == 0
40
- erev 'Please add a number, such as 1, or any other value.'
41
- else
42
- case chop_from_left_or_right_hand_side
43
- # ===================================================================== #
44
- # === :right
45
- # ===================================================================== #
46
- when :right,
47
- :default
48
- which_end = "3'"
49
- # ===================================================================== #
50
- # === :left
51
- # ===================================================================== #
52
- when :left
53
- which_end = "5'"
54
- end
55
- if dna_sequence_object?.size > 0
56
- erev "We will now remove some characters (#{simp(i.to_s)}#{rev}"\
57
- ") from the #{which_end} end of our main string."
58
- end
59
- if dna_sequence_object?.size == 0
60
- erev 'Can not remove anything as the sequence is empty.'
61
- elsif i > dna_sequence_object?.size
62
- erev 'We can not remove that many characters, thus we will'
63
- erev 'simply remove all characters now.'
64
- reset_string
65
- else
66
- # =================================================================== #
67
- # Finally do the manipulation. We need to honour from which
68
- # side we will be operating on.
69
- # =================================================================== #
70
- case chop_from_left_or_right_hand_side
71
- # =================================================================== #
72
- # === :default
73
- # =================================================================== #
74
- when :default,
75
- :right
76
- # ================================================================= #
77
- # We also store the chopped-away sequence, but we have to be
78
- # mindful here since the sequence-object counts the nucleotides
79
- # differently than ruby counts Arrays.
80
- # ================================================================= #
81
- @internal_hash[:array_these_sequences_were_chopped_away] << seq_object?[(-i)+1, i-1].dup
82
- seq_object?[-i, i] = ''
83
- # =================================================================== #
84
- # === :left
85
- # =================================================================== #
86
- when :left
87
- @internal_hash[:array_these_sequences_were_chopped_away] << seq_object?[0, i].dup
88
- seq_object?[0, i+1] = ''
89
- end
90
- end
91
- unless dna_sequence_object?.size == 0
92
- erev "#{rev}The new length of the main string is now: "\
93
- "#{simp(dna_sequence_object?.size.to_s)}#{rev}."
94
- end
95
- show_dna_sequence
96
- end
97
- end; alias remove_n_nucleotides chop # === remove_n_nucleotides
98
-
99
- # ========================================================================= #
100
- # === cut_sequence_in_slices_of
101
- #
102
- # This method cuts the sequence into slices of n, where n is the
103
- # argument to this method.
104
- #
105
- # So if you input 10 as argument, then we will put the nucleotides
106
- # into chunks of 10 nucleotides per row.
107
- #
108
- # Usage examples:
109
- #
110
- # cut_sequence_in_slices_of 5
111
- # cut_sequence_in_slices_of 6
112
- # cut_sequence_in_slices_of 7
113
- #
114
- # ========================================================================= #
115
- def cut_sequence_in_slices_of(threshold = '9')
116
- _ = dna_sequence_object?
117
- matches = _.scan(/.{#{threshold}}/)
118
- matches.each {|entry|
119
- erev ' '+entry
120
- }
121
- end
122
-
123
- # ========================================================================= #
124
- # === left_chop
125
- # ========================================================================= #
126
- def left_chop(i)
127
- chop(i, :left)
128
- end
129
-
130
- # ========================================================================= #
131
- # === cut_at
132
- #
133
- # Use this method to chop off or rather cut at a DNA sequence.
134
- # ========================================================================= #
135
- def cut_at(
136
- this_sequence = 'GAATTC',
137
- be_verbose = true
138
- )
139
- main_sequence = dna_sequence_object?
140
- this_sequence = this_sequence.join.strip if this_sequence.is_a? Array
141
- if be_verbose
142
- erev "We will chop away (at) the sequence #{simp(this_sequence)}#{rev}."
143
- erev 'Note that the sequences all originated from the larger '\
144
- 'parent sequence.'
145
- end
146
- results = main_sequence.split(/#{this_sequence}/)
147
- results.each {|sequence|
148
- _ = properly_spaced_dna(sequence)
149
- _ << (' ('+sequence.size.to_s+' nucleotides)').rjust(110 - sequence.size)
150
- erev _
151
- }
152
- end
153
-
154
- # ========================================================================= #
155
- # === restore_the_last_chop_operation
156
- #
157
- # This method will "restore" the last chop operation.
158
- #
159
- # Presently it will only append onto the 3' area but in the future
160
- # this may change, depending on whether we will store the position
161
- # as well.
162
- # ========================================================================= #
163
- def restore_the_last_chop_operation
164
- if @internal_hash[:array_these_sequences_were_chopped_away].empty?
165
- erev 'Can not restore the last chop-operation as we have not yet'
166
- erev 'chopped away any nucleotide from the main sequence.'
167
- else
168
- this_sequence = @internal_hash[:array_these_sequences_were_chopped_away].pop
169
- erev 'Now adding the sequence '+
170
- format_this_nucleotide_sequence(
171
- this_sequence
172
- )
173
- erev 'to our main sequence.'
174
- main_sequence?.append(this_sequence)
175
- end
176
- end
177
-
178
- # ========================================================================= #
179
- # === chop_to
180
- #
181
- # This method will chop up to the first occurence of the given input
182
- # sequence.
183
- #
184
- # If the given input sequence can not be found, no change is made.
185
- # ========================================================================= #
186
- def chop_to(i)
187
- if i.is_a? Array
188
- i = i.first
189
- end
190
- case i
191
- when 'start'
192
- i = 'ATG'
193
- end
194
- _ = nucleotide_sequence?
195
- if i.include? 'U'
196
- # ===================================================================== #
197
- # Convert Uracil to Thymine next.
198
- # ===================================================================== #
199
- erev "The given input sequence includes at the least one "\
200
- "#{sfancy('U')}#{rev}, which we will convert to #{sfancy('T')}#{rev}."
201
- i.tr!('U','T')
202
- end
203
- if _.include? i
204
- # ===================================================================== #
205
- # Ok, we found the search sequence, so now we can chop off the
206
- # unnecessary sequences.
207
- # ===================================================================== #
208
- position = _.index(i)
209
- erev "Chopping away #{sfancy(position.to_s)}#{rev} nucleotides from "\
210
- "the left-hand side (5' end) next."
211
- @internal_hash[:array_these_sequences_were_chopped_away] << seq_object?[0, position+1]
212
- seq_object?[0, position+1] = ''
213
- show_dna_sequence
214
- else
215
- erev 'No modification can be made as our target nucleotide sequence'
216
- erev "does not include the given search string #{sfancy(i)}."
217
- end
218
- end
219
-
220
- # ========================================================================= #
221
- # === cut (cut tag)
222
- #
223
- # This method will cut away some part from the DNA string.
224
- # ========================================================================= #
225
- def cut(i)
226
- i = i.to_i
227
- @sequence[-i,i] = ''
228
- show_dna_sequence
229
- end
230
-
231
- # ========================================================================= #
232
- # === cutseq
233
- #
234
- # This can be used to modify the sequence object. It will cut some
235
- # segment out from the nucleotide.
236
- #
237
- # Usage examples:
238
- #
239
- # random 30; cutseq 5 8
240
- # random 30; cutseq 5-8
241
- #
242
- # ========================================================================= #
243
- def cutseq(i = [1,3])
244
- if i.is_a? Array
245
- if i.size == 1 and i.first.is_a? String and i.first.include?('-')
246
- i = [i.first.split('-')].flatten
247
- end
248
- if i.empty? # In this case we will ask the user for input.
249
- erev 'No argument was provided. Please input the start nucleotide position next:'
250
- start_position = $stdin.gets.chomp.to_i
251
- erev 'Next, input the end nucleotide position:'
252
- end_position = $stdin.gets.chomp
253
- elsif i.size > 1
254
- start_position = i.first
255
- end_position = i.last
256
- end
257
- end
258
- # ======================================================================= #
259
- # === Handle +3 relational position given
260
- # ======================================================================= #
261
- if end_position.is_a? String and end_position.include?('+')
262
- end_position = start_position + end_position.delete('+').to_i
263
- end
264
- n_nucleotides_will_be_deleted = (end_position.to_i - start_position.to_i)+1
265
- # ======================================================================= #
266
- # Notify the user what we will do next.
267
- # ======================================================================= #
268
- erev 'Next cutting away '+simp(n_nucleotides_will_be_deleted.to_s)+
269
- rev+' nucleotides.'
270
- sequence_object?[start_position, end_position] = ''
271
- end
272
-
273
- # ========================================================================= #
274
- # === cut_with_enzyme
275
- # ========================================================================= #
276
- def cut_with_enzyme(i)
277
- i = i.join(' ').strip if i.is_a? Array
278
- pp sequence_object?.cut_with_enzyme(i)
279
- end
280
-
281
- end; end