Class: Bio::PAML::Codeml::PositiveSites

Inherits:
Array
  • Object
show all
Defined in:
lib/bio/appl/paml/codeml/report.rb

Overview

List for the positive selection sites. PAML returns:

Naive Empirical Bayes (NEB) analysis Positively selected sites (*: P>95%; **: P>99%) (amino acids refer to 1st sequence: PITG_23265T0)

        Pr(w>1)     post mean +- SE for w

17 I      0.988*        3.293
18 H      1.000**       17.975
23 F      0.991**       6.283

(…)

131 V      1.000**       22.797
132 R      1.000**       10.800

(newline)

these can be accessed using normal iterators. Also special methods are available for presenting this data

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(search, buf, num_codons) ⇒ PositiveSites

Returns a new instance of PositiveSites.

Raises:



537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
# File 'lib/bio/appl/paml/codeml/report.rb', line 537

def initialize search, buf, num_codons
  @num_codons = num_codons
  if buf.index(search)==nil
    raise ReportError,"No NB sites found for #{search}" 
  end
  # Set description of this class
  @descr = search
  lines = buf.split("\n")
  # find location of 'search'
  start = 0
  lines.each_with_index do | line, i |
    if line.index(search) != nil
      start = i
      break
    end
  end
  raise ReportError,"Out of bound error for <#{buf}>" if lines[start+6]==nil
  lines[start+6..-1].each do | line |
    break if line.strip == ""
    fields = line.split
    push PositiveSite.new(fields)
  end
  num = size()
  @buf = lines[start..start+num+7].join("\n")
end

Instance Attribute Details

#descrObject (readonly)

Returns the value of attribute descr.



535
536
537
# File 'lib/bio/appl/paml/codeml/report.rb', line 535

def descr
  @descr
end

Instance Method Details

#graphObject

Generate a graph - which is a simple string pointing out the positions showing evidence of positive selection pressure.

>> c.sites.graph[0..32]
=> "                **    *       * *"


569
570
571
# File 'lib/bio/appl/paml/codeml/report.rb', line 569

def graph
  graph_to_s(lambda { |site| "*" })
end

#graph_omegaObject

Generate a graph - which is a simple string pointing out the positions showing evidence of positive selection pressure, with dN/dS values (high values are an asterisk *)

>> c.sites.graph_omega[0..32]
=> "                24    3       3 2"


580
581
582
583
584
585
586
# File 'lib/bio/appl/paml/codeml/report.rb', line 580

def graph_omega
  graph_to_s(lambda { |site| 
      symbol = "*"
      symbol = site.omega.to_i.to_s if site.omega.abs <= 10.0
      symbol
  })
end

#graph_seqObject

Graph of amino acids of first sequence at locations



589
590
591
592
593
# File 'lib/bio/appl/paml/codeml/report.rb', line 589

def graph_seq
  graph_to_s(lambda { |site |
    symbol = site.aaref
  })
end

#graph_to_s(func, fill = ' ') ⇒ Object

:nodoc: Creates a graph of sites, adjusting for gaps. This generator is also called from HtmlPositiveSites. The fill is used to fill out the gaps



604
605
606
607
608
609
610
611
612
613
614
615
616
# File 'lib/bio/appl/paml/codeml/report.rb', line 604

def graph_to_s func, fill=' '
  ret = ""
  pos = 0
  each do | site |
    symbol = func.call(site)
    gapsize = site.position-pos-1
    ret += fill*gapsize + symbol
    pos = site.position
  end
  gapsize = @num_codons - pos - 1
  ret += fill*gapsize if gapsize > 0
  ret
end

#to_sObject

Return the positive selection information as a String



596
597
598
# File 'lib/bio/appl/paml/codeml/report.rb', line 596

def to_s
  @buf
end