lib/neurohmmer/output.rb in neurohmmer-0.1.1 vs lib/neurohmmer/output.rb in neurohmmer-0.1.2
- old
+ new
@@ -9,10 +9,24 @@
class Output
class <<self
extend Forwardable
def_delegators Neurohmmer, :opt, :conf
+ def to_fasta(hmm_results)
+ File.open(conf[:fasta_output], 'w') do |file|
+ hmm_results.each do |query, hits|
+ next if hits.length == 0
+ file.puts # a blank line
+ file.puts '# ' + query
+ hits.each do |hit|
+ file.puts '>' + hit[:id]
+ file.puts hit[:seq]
+ end
+ end
+ end
+ end
+
def to_html(hmm_results)
@html_results = format_seqs_for_html(hmm_results)
template_path = File.expand_path('../../../template/contents.slim',
__FILE__)
contents_temp = File.read(template_path)
@@ -62,15 +76,15 @@
return s.insert(sp_cut_off + 19, '</span><span class=hsp>')
elsif s1 =~ /<span class=hsp>/
s = s1.gsub(/<span class=hsp>/, '</span><span class=sp_hsp>') +
seq[sp_cut_off..-1]
return s.insert(0, '<span class=sp>')
- .insert(sp_cut_off + 41, '</span><span class=hsp>')
+ .insert(sp_cut_off + 41, '</span><span class=hsp>')
elsif s1 =~ /</
- s = s1.gsub(/<.+$/, '</span><span class=sp_hsp>') +
- seq[sp_cut_off..-1].gsub(/^\w+?>/,'')
+ s = s1.gsub(/<.*?$/, '</span><span class=sp_hsp>') +
+ seq[sp_cut_off..-1].gsub(/^.*?>/, '')
return s.insert(0, '<span class=sp>')
- .insert(sp_cut_off + 41, '</span><span class=hsp>')
+ .insert(sp_cut_off + 41, '</span><span class=hsp>')
else
return seq.insert(0, '<span class=sp>').insert(sp_cut_off + 15,
'</span>')
end
end