Sha256: 776aee94a5e4a3a571933261288f14b8a49f60b4ffc1e09f12d60c04a8d85081

Contents?: true

Size: 980 Bytes

Versions: 7

Compression:

Stored size: 980 Bytes

Contents

require 'slim'

# Top level module / namespace.
module NpSearch
  # Class that generates the output
  class Output
    class << self
      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

      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
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
npsearch-2.1.8 lib/npsearch/output.rb
npsearch-2.1.7 lib/npsearch/output.rb
npsearch-2.1.6 lib/npsearch/output.rb
npsearch-2.1.4 lib/npsearch/output.rb
npsearch-2.1.3 lib/npsearch/output.rb
npsearch-2.1.2 lib/npsearch/output.rb
npsearch-2.1.1 lib/npsearch/output.rb