module Neurohmmer
Top level module / namespace.
Top level module / namespace.
Top level module / namespace.
Top level module / namespace.
Top level module / namespace.
Top level module / namespace.
Constants
- VERSION
Attributes
conf[RW]
opt[RW]
Public Class Methods
extract_sequence(id)
click to toggle source
# File lib/neurohmmer.rb, line 36 def extract_sequence(id) id = id.gsub(/\s+/, '') idx = @input_index[id] seq = IO.binread(@opt[:input_file], idx[1] - idx[0], idx[0]) seq.scan(/>([^\n]*)\n([A-Za-z\n\*]*)/)[0] end
init(opt)
click to toggle source
# File lib/neurohmmer.rb, line 14 def init(opt) @opt = ArgumentsValidators.run(opt) @conf = { hmm_dir: File.expand_path('../../data/hmm', __FILE__), raw_data: File.expand_path('../../data/raw_data', __FILE__), raw_alignments: File.expand_path('../../data/raw_data/alignments', __FILE__), hmm_output: File.join(@opt[:temp_dir], 'input.hmm_search.out'), html_output: "#{@opt[:input_file]}.neurohmmer.html", fasta_output: "#{@opt[:input_file]}.neurohmmer.fa" } init_input end
run()
click to toggle source
# File lib/neurohmmer.rb, line 28 def run Hmmer.search hmm_analysis = Hmmer.analyse_output Output.to_fasta(hmm_analysis) Output.to_html(hmm_analysis) remove_temp_dir end
Private Class Methods
index(content, keys, values)
click to toggle source
A method run from index_input_file
that creates a simple hash with the {seq id: [start byte in file, end byte in file] }
# File lib/neurohmmer.rb, line 76 def index(content, keys, values) fasta_index = {} keys.each_with_index do |k, i| id = k[0..115].gsub(/\s+/, '') endf = (i == values.length - 1) ? content.length - 1 : values[i + 1] fasta_index[id] = [values[i], endf] end fasta_index end
index_input_file()
click to toggle source
Indexes the input file - returns a hash in the following format: {seq id: [start byte in file, end byte in file] }
# File lib/neurohmmer.rb, line 67 def index_input_file c = IO.binread(@opt[:input_file]) keys = c.scan(/>(.*)\n/).flatten values = c.enum_for(:scan, /(>[^>]+)/).map { Regexp.last_match.begin(0) } index(c, keys, values) end
init_input()
click to toggle source
# File lib/neurohmmer.rb, line 45 def init_input FileUtils.mkdir_p(@opt[:temp_dir]) @opt[:input_file] = translate_input if @opt[:type] == :genetic @input_index = index_input_file end
remove_temp_dir()
click to toggle source
# File lib/neurohmmer.rb, line 86 def remove_temp_dir return unless File.directory?(@opt[:temp_dir]) FileUtils.rm_rf(@opt[:temp_dir]) end
translate_input(input = @opt[:input_file])
click to toggle source
Translates the input data in all 6 frames
# File lib/neurohmmer.rb, line 52 def translate_input(input = @opt[:input_file]) translated_file = File.join(@opt[:temp_dir], 'input.translated.fa') File.open(translated_file, 'w') do |file| Bio::FlatFile.open(Bio::FastaFormat, input).each_entry do |entry| (1..6).each do |f| file.puts ">#{entry.definition}-frame:#{f}" file.puts entry.naseq.translate(f) end end end translated_file end