module EcfClassify::Runner

Public Class Methods

general(seqs,file) click to toggle source
# File lib/ecf_classify/runner.rb, line 6
def self.general(seqs,file)
  general = Tempfile.new("general")
  sigma3 = Tempfile.new("sigma3")
  pfam = Tempfile.new("pfam")
  begin
    out = HMMER.hmmsearch(seqs,general.path,:general) 
    raise out[0] if out[1] != 0
    out = HMMER.hmmsearch(seqs,sigma3.path,:sigma3)
    raise out[0] if out[1] != 0
    out = HMMER.hmmsearch(seqs,pfam.path,:sigma2_4) 
    raise out[0] if out[1] != 0
    script = Utils.path("lib/scripts/extract_ECF.py")
    out = `python3 #{script} --general #{general.path} --pfam #{pfam.path} --sigma3 #{sigma3.path} --infile #{seqs} --conserved #{file}`
    raise unless $?.success?
  ensure
    [general,sigma3,pfam].map(&:close)
    [general,sigma3,pfam].map(&:unlink)
  end
  return out
end
specific(seqs, type, probabilities = nil) click to toggle source
# File lib/ecf_classify/runner.rb, line 27
def self.specific(seqs, type, probabilities = nil)
  ungrouped = nil
  stats = nil
  th = nil
  case type
  when :groups
    th = 0.0016
    stats = EcfClassify::Zenodo.path(:groups_statistics)
    ungrouped = "Ungrouped"
  when :subgroups
    th = 0.0041
    stats = EcfClassify::Zenodo.path(:subgroups_statistics)
    ungrouped = "Unsubgrouped"
  else
    raise "type #{type} unknown"
  end
  specific = Tempfile.new("#{type}")
  begin
    out = HMMER.hmmsearch(seqs,specific.path,type) 
    raise out[0] if out[1] != 0
    script = Utils.path("lib/scripts/classify.py")
    cmd = "python3 #{script} --hmm-result #{specific.path} --th #{th} --stats-file #{stats} --ungrouped #{ungrouped}"
    if probabilities
      cmd += " --probabilities #{probabilities}"
    end
    out = `#{cmd}`
    raise unless $?.success?
  ensure
    specific.close
    specific.unlink
  end
  return out
end