Class: NpSearch::Output

Inherits:
Object
  • Object
show all
Defined in:
lib/npsearch/output.rb

Overview

Class that generates the output

Class Method Summary collapse

Class Method Details

.to_fasta(input_file, sorted_sequences, input_type) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/npsearch/output.rb', line 16

def to_fasta(input_file, sorted_sequences, input_type)
  File.open("#{input_file}.npsearch.fa", 'w') do |f|
    sorted_sequences.each do |s|
      if input_type == :protein
        f.puts ">#{s.defline}\n#{s.signalp}#{s.seq}"
      elsif input_type == :genetic
        f.puts ">#{s.defline}"
        f.puts "#{s.signalp}#{s.seq}"
      end
    end
  end
end

.to_html(input_file) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/npsearch/output.rb', line 8

def to_html(input_file)
  templates_path = File.expand_path(File.join(__FILE__, '../../../',
                                              'templates/contents.slim'))
  contents_temp = File.read(templates_path)
  h_content = Slim::Template.new { contents_temp }.render(NpSearch)
  File.open("#{input_file}.npsearch.html", 'w') { |f| f.puts h_content }
end