Class: Bioroebe::FastaParser
- Inherits:
-
Base
- Object
- Base
- Bioroebe::FastaParser
show all
- Defined in:
- lib/bioroebe/fasta_and_fastq/fasta_parser.rb
Overview
Constant Summary
collapse
- MAIN_URL =
'https://www.ncbi.nlm.nih.gov/'
- BASE_URL =
MAIN_URL+'protein/'
- APPEND_THIS =
'?report=fasta'
- DEFAULT_URL =
340622821
- DISPLAY_HTML_RESULT =
true
- SAVE_HTML_FILE_HERE =
::Bioroebe.log_dir?+
'SavedFasta.html'
Constants inherited
from Base
Base::NAMESPACE
ColoursForBase::ARRAY_HTML_COLOURS_IN_USE
Instance Method Summary
collapse
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
#colourize_this_aminoacid_sequence_for_the_commandline, #colourize_this_nucleotide_sequence, #disable_colours, #ecomment, #efancy, #egold, #enable_colours, #eorange, #eparse, #erev, #red, #remove_trailing_escape_part, #return_colour_for_nucleotides, #rev, #sdir, #set_use_colours, #sfancy, #sfile, #simp, #swarn, #use_colours?, #use_colours_within_the_bioroebe_namespace?
Constructor Details
#initialize(url = DEFAULT_URL, run_already = true) ⇒ FastaParser
58
59
60
61
62
63
64
65
|
# File 'lib/bioroebe/fasta_and_fastq/fasta_parser.rb', line 58
def initialize(
url = DEFAULT_URL,
run_already = true
)
reset
set_full_url(url)
run if run_already
end
|
Instance Method Details
#feedback_help_then_exit ⇒ Object
#
feedback_help_then_exit
#
107
108
109
110
111
112
113
|
# File 'lib/bioroebe/fasta_and_fastq/fasta_parser.rb', line 107
def feedback_help_then_exit
e 'The URL is:'
e
e " #{simp(MAIN_URL)}"
e
exit(0)
end
|
#read_remote_url ⇒ Object
118
119
120
121
122
|
# File 'lib/bioroebe/fasta_and_fastq/fasta_parser.rb', line 118
def read_remote_url
@result = open(@url).read
sanitize_result
e @result if DISPLAY_HTML_RESULT
end
|
#report_url_used ⇒ Object
134
135
136
137
|
# File 'lib/bioroebe/fasta_and_fastq/fasta_parser.rb', line 134
def report_url_used
e 'We used this URL:'
e " #{simp(@url)}"
end
|
#reset ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/bioroebe/fasta_and_fastq/fasta_parser.rb', line 70
def reset
super()
@result = nil
@url = nil
@save_html_file_here = SAVE_HTML_FILE_HERE
end
|
#run ⇒ Object
157
158
159
160
161
|
# File 'lib/bioroebe/fasta_and_fastq/fasta_parser.rb', line 157
def run
read_remote_url
report_url_used
save_html_file
end
|
#sanitize_result ⇒ Object
127
128
129
|
# File 'lib/bioroebe/fasta_and_fastq/fasta_parser.rb', line 127
def sanitize_result @result.squeeze!(' ')
end
|
#save_html_file ⇒ Object
142
143
144
145
146
147
148
149
150
151
152
|
# File 'lib/bioroebe/fasta_and_fastq/fasta_parser.rb', line 142
def save_html_file
if @result unless Dir.exist?(File.basename(@save_html_file_here))
@save_html_file_here = File.expand_path('~')+'/'+
File.basename(SAVE_HTML_FILE_HERE)
end
e 'We will save the HTML file here:'
e " #{simp(@save_html_file_here)}"
save_file(@result, @save_html_file_here,'w+')
end
end
|
#set_full_url(i = DEFAULT_URL, be_verbose = true) ⇒ Object
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/bioroebe/fasta_and_fastq/fasta_parser.rb', line 89
def set_full_url(
i = DEFAULT_URL,
be_verbose = true
)
case i when nil
i = DEFAULT_URL
when 'help','help?'
feedback_help_then_exit
end
i = BASE_URL+i.to_s+APPEND_THIS
@url = i
e 'Setting to use this URL: '+sfancy(@url) if be_verbose
end
|