class Neurohmmer::Hmmer
A class that holds methods related to Hmmer
Public Class Methods
analyse_output()
click to toggle source
# File lib/neurohmmer/hmmer.rb, line 21 def analyse_output hmm_results = {} hmm_search_output = File.open(conf[:hmm_output]) hmm_reports = Bio::HMMER::HMMER3.reports(hmm_search_output) hmm_reports.each_with_index do |report, idx| next if idx + 1 == hmm_reports.length hmm_results[report.query] = analyse_hmm_search_report(report) end hmm_results end
generate_hmm_models()
click to toggle source
# File lib/neurohmmer/hmmer.rb, line 32 def generate_hmm_models Dir.foreach(conf[:raw_data]) do |file| next if file !~ /fa(sta)?$/ np_fasta_file = File.join(conf[:raw_data], file) aligned_file = File.join(conf[:raw_alignments], "#{file.gsub(/fa(sta)?$/, '')}.aligned") hmm_model_file = File.join(conf[:hmm_dir], "#{file.gsub(/fa(sta)?$/, '')}.hmm") mafft(np_fasta_file, aligned_file, opt[:num_threads]) hmm_build(aligned_file, hmm_model_file) end end
search()
click to toggle source
# File lib/neurohmmer/hmmer.rb, line 12 def search Dir.foreach(conf[:hmm_dir]) do |h| hmm_file = File.join(conf[:hmm_dir], h) next if hmm_file !~ /hmm$/ hmm_search(opt[:input_file], hmm_file, conf[:hmm_output], opt[:num_threads]) end end
Private Class Methods
analyse_hmm_search_report(report)
click to toggle source
# File lib/neurohmmer/hmmer.rb, line 47 def analyse_hmm_search_report(report) report_result = [] report.hits.each do |hit| seq = Neurohmmer.extract_sequence(hit.sequence_name.strip) hsps = [] hit.hsps.each { |hsp| hsps << hsp.flatseq } report_result << { id: seq[0], seq: seq[1], flatseq: hsps } end report_result end
hmm_build(aligned_file, hmm_model_file)
click to toggle source
# File lib/neurohmmer/hmmer.rb, line 63 def hmm_build(aligned_file, hmm_model_file) `hmmbuild '#{hmm_model_file}' '#{aligned_file}'` end
hmm_search(input_file, hmm_file, hmm_output, num_threads)
click to toggle source
# File lib/neurohmmer/hmmer.rb, line 67 def hmm_search(input_file, hmm_file, hmm_output, num_threads) `hmmsearch --cpu #{num_threads} '#{hmm_file}' '#{input_file}' >> \ '#{hmm_output}'` end
mafft(input, aligned_file, num_threads)
click to toggle source
# File lib/neurohmmer/hmmer.rb, line 58 def mafft(input, aligned_file, num_threads) `mafft --maxiterate 1000 --thread #{num_threads} '#{input}' > \ '#{aligned_file}'` end