Class: Bioroebe::ElectronMicroscopy::ReadFileXMD
Overview
Bioroebe::ElectronMicroscopy::ReadFileXMD
Constant Summary
CommandlineApplication::OLD_VERBOSE_VALUE
ColoursForBase::ARRAY_HTML_COLOURS_IN_USE
Constants inherited
from Base
Base::NAMESPACE
Class Method Summary
collapse
Instance Method Summary
collapse
#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, #opne, #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, #set_be_verbose, #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
#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
#colourize_this_aminoacid_sequence_for_the_commandline, #colourize_this_nucleotide_sequence, #disable_colours, #ecomment, #efancy, #egold, #enable_colours, #eorange, #eparse, #erev, #red, #remove_trailing_escape_part, #return_colour_for_nucleotides, #rev, #sdir, #set_use_colours, #sfancy, #sfile, #simp, #swarn, #use_colours?, #use_colours_within_the_bioroebe_namespace?
Methods inherited from Base
#append_what_into, #can_base_pair?, #convert_global_env, #delete_file, #directory_to_the_codon_tables?, #file_readlines, #infer_the_namespace, #is_on_roebe?, #is_palindrome?, #main_encoding?, #mkdir, #move_file, #mv, #namespace?, #no_file_exists_at, #no_newlines, #project_yaml_directory?, #rds, #register_sigint, #return_pwd, #return_the_first_line_of_this_file, #word_wrap, #write_what_into
Constructor Details
#initialize(this_xmd_file = nil, run_already = true) ⇒ ReadFileXMD
#
initialize
The first argument passed to this class here should be the .xmd file in question.
#
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/bioroebe/electron_microscopy/read_file_xmd.rb', line 31
def initialize(
this_xmd_file = nil,
run_already = true
)
reset set_this_xmd_file(this_xmd_file)
case run_already
when :dont_run_yet
run_already = false
end
run if run_already
end
|
Class Method Details
#
Pass an array to us here.
#
262
263
264
265
266
|
# File 'lib/bioroebe/electron_microscopy/read_file_xmd.rb', line 262
def self.(i)
_ = new(nil, :dont_run_yet)
result = _.(i)
return result
end
|
Instance Method Details
#_ ⇒ Object
69
70
71
|
# File 'lib/bioroebe/electron_microscopy/read_file_xmd.rb', line 69
def _
@this_xmd_file
end
|
#body ⇒ Boolean
#
body?
The body of the .xmd file.
#
body
148
149
150
|
# File 'lib/bioroebe/electron_microscopy/read_file_xmd.rb', line 148
def body?
@body
end
|
#body? ⇒ Boolean
146
147
148
|
# File 'lib/bioroebe/electron_microscopy/read_file_xmd.rb', line 146
def body?
@body
end
|
#file? ⇒ Boolean
#
file?
This gives us colourized output.
#
128
129
130
|
# File 'lib/bioroebe/electron_microscopy/read_file_xmd.rb', line 128
def file?
sfile(_)
end
|
119
120
121
|
# File 'lib/bioroebe/electron_microscopy/read_file_xmd.rb', line 119
def
@header
end
|
#report ⇒ Object
236
237
238
239
240
241
242
243
244
245
|
# File 'lib/bioroebe/electron_microscopy/read_file_xmd.rb', line 236
def report
opnn; e 'The header subsection of this .xmd file is:'
pp @header
if @body
opnn; e 'The body subsection has '+@body.size.to_s+' entries.'
else
opnn; e 'No body has been found. Has a .xmd file been '\
'passed to this class?'
end
end
|
#report_what_we_will_do ⇒ Object
#
report_what_we_will_do
#
135
136
137
138
139
|
# File 'lib/bioroebe/electron_microscopy/read_file_xmd.rb', line 135
def report_what_we_will_do
if be_verbose?
opnn; e "We will next read in the data from the file #{file?}"
end
end
|
#reset ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/bioroebe/electron_microscopy/read_file_xmd.rb', line 47
def reset
super()
infer_the_namespace
@header = nil
@body = nil
set_be_verbose
@dataset = nil
set_prepend_this_to_the_mrc_file_path
end
|
#run ⇒ Object
250
251
252
253
254
255
|
# File 'lib/bioroebe/electron_microscopy/read_file_xmd.rb', line 250
def run
report_what_we_will_do
try_to_determine_the_body
sanitize_body
end
|
#sanitize_body ⇒ Object
#
sanitize_body
This method will do two things:
(1) It will chop off the trailing 1 (if it can be found)
(2) It will chop off the leading string that includes the
@ character.
(3) It will eliminate an existing trailing newlines, and
then .strip on the result.
(4) It will also replace the relative path to the .stk file
with an absolute path. (This is experimental for now)
#
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
|
# File 'lib/bioroebe/electron_microscopy/read_file_xmd.rb', line 164
def sanitize_body
@body.map! {|entry|
entry = entry.dup if entry.frozen?
entry.chomp!
entry = entry[(entry.index('@')+1)..-1] if entry.include? '@'
entry.strip!
entry.chop! if entry.end_with? '1'
if entry.include? '.mrc'
entry.sub!(/\.\/(.+\.mrc)/,
@prepend_this_to_the_mrc_file_path+'\\1')
end
entry.strip!
entry
} if @body
end
|
#
Next we will sanitize the @header variable.
#
212
213
214
215
216
217
218
219
220
221
222
223
224
|
# File 'lib/bioroebe/electron_microscopy/read_file_xmd.rb', line 212
def (i = @header)
if i.is_a? String
i = i.split(N)
end
i[3..-1] = '
_rlnImageName #1
_rlnMicrographName #2
_rlnCoordinateX #3
_rlnCoordinateY #4
'
@header = i
return i
end
|
#set_prepend_this_to_the_mrc_file_path(i = '') ⇒ Object
Also known as:
set_path_to_mrc_file
#
set_prepend_this_to_the_mrc_file_path
#
195
196
197
198
|
# File 'lib/bioroebe/electron_microscopy/read_file_xmd.rb', line 195
def set_prepend_this_to_the_mrc_file_path(i = '')
i = i.to_s.dup
@prepend_this_to_the_mrc_file_path = i
end
|
#set_this_xmd_file(i) ⇒ Object
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/bioroebe/electron_microscopy/read_file_xmd.rb', line 76
def set_this_xmd_file(i)
i = i.first if i.is_a? Array
i = i.to_s
@this_xmd_file = i
if File.exist? @this_xmd_file
@dataset = File.readlines(@this_xmd_file)
else
unless @this_xmd_file.empty?
opn; e 'The file at '+sfile(_)+' does not exist.'
end
end
end
|
#show_body ⇒ Object
229
230
231
|
# File 'lib/bioroebe/electron_microscopy/read_file_xmd.rb', line 229
def show_body
pp body?
end
|
#this_xmd_file? ⇒ Boolean
Also known as:
this_xmd_file
93
94
95
|
# File 'lib/bioroebe/electron_microscopy/read_file_xmd.rb', line 93
def this_xmd_file?
@this_xmd_file
end
|
#try_to_determine_the_body ⇒ Object
#
try_to_determine_the_body
#
110
111
112
113
114
|
# File 'lib/bioroebe/electron_microscopy/read_file_xmd.rb', line 110
def try_to_determine_the_body
if @dataset
@body = @dataset[9..-1] end
end
|
100
101
102
103
104
105
|
# File 'lib/bioroebe/electron_microscopy/read_file_xmd.rb', line 100
def
if @dataset
@header = @dataset[0,9]
end
end
|