Class: ViennaRna::Package::Xbor

Inherits:
Base
  • Object
show all
Defined in:
lib/vienna_rna/package/xbor.rb

Direct Known Subclasses

Fftbor, Rnabor

Instance Attribute Summary

Attributes inherited from Base

#data, #response, #runtime

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

bootstrap, #debugger, #initialize, #serialize

Methods included from Global::ChainExtensions

included

Methods included from Global::RunExtensions

included

Constructor Details

This class inherits a constructor from ViennaRna::Package::Base

Class Method Details

.bootstrap_from_file(path, klass = self) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/vienna_rna/package/xbor.rb', line 25

def self.bootstrap_from_file(path, klass = self)
  log       = File.read(path)
  sequence  = log.split(/\n/).first.split(/\s+/)[1]
  structure = log.split(/\n/).first.split(/\s+/)[2]

  klass.bootstrap(RNA.from_string(sequence, structure), log)
end

.parse(response) ⇒ Object



33
34
35
# File 'lib/vienna_rna/package/xbor.rb', line 33

def self.parse(response)
  response.split(/\n/).select { |line| line =~ /^\d+\t-?\d+/ }.map { |line| line.split(/\t/) }
end

Instance Method Details

#expected_kObject



46
47
48
# File 'lib/vienna_rna/package/xbor.rb', line 46

def expected_k
  k_p_points.map { |array| array.inject(&:*) }.inject(&:+)
end

#full_distributionObject



37
38
39
40
# File 'lib/vienna_rna/package/xbor.rb', line 37

def full_distribution
  distribution      = run.distribution
  full_distribution = distribution + ([0.0] * ((differnece = data.seq.length - distribution.length + 1) < 0 ? 0 : differnece))
end

#inspectObject



58
59
60
# File 'lib/vienna_rna/package/xbor.rb', line 58

def inspect
  "#<#{self.class.name} #{data.inspect}>"
end

#k_p_pointsObject



42
43
44
# File 'lib/vienna_rna/package/xbor.rb', line 42

def k_p_points
  full_distribution.each_with_index.to_a.map(&:reverse)[0..data.seq.length]
end

#quick_plot(options = {}) ⇒ Object



50
51
52
53
54
55
56
# File 'lib/vienna_rna/package/xbor.rb', line 50

def quick_plot(options = {})
  ViennaRna::Graphing::Gnuplot.quick_plot(
    k_p_points,
    options[:title] || "%s\\n%s\\n%s" % [self.class.name, data.seq, data.safe_structure],
    options
  )
end

#run_command(flags) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/vienna_rna/package/xbor.rb', line 10

def run_command(flags)
  file = Tempfile.new("rna")
  file.write("%s\n" % data.seq)
  file.write("%s\n" % data.str)
  file.close

  ViennaRna.debugger { "Running FFTbor on #{data.inspect}" }

  "%s %s %s" % [
    exec_name, 
    stringify_flags(flags), 
    file.path
  ]
end