Module: EcfClassify::Runner

Defined in:
lib/ecf_classify/runner.rb

Class Method Summary collapse

Class Method Details

.general(seqs, file) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# 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.hmmscan(seqs,general.path,:general) 
    raise out[0] if out[1] != 0
    out = HMMER.hmmscan(seqs,sigma3.path,:sigma3)
    raise out[0] if out[1] != 0
    out = HMMER.hmmscan(seqs,pfam.path,:pfam) 
    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) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# 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 = Utils.path("data/statistics/groups.txt")
    ungrouped = "Ungrouped"
  when :subgroups
    th = 0.0041
    stats = Utils.path("data/statistics/subgroups.txt")
    ungrouped = "Unsubgrouped"
  else
    raise "type #{type} unknown"
  end
  specific = Tempfile.new("#{type}")
  begin
    out = HMMER.hmmscan(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