class Bio::Util::MrnaModel

Attributes

cds[RW]
seq[RW]

Public Class Methods

new(gff_line) click to toggle source
Calls superclass method
# File lib/bio/utils/bio-synreport.rb, line 10
def initialize(gff_line)
  super gff_line
  @cds = []
end

Public Instance Methods

cds_end() click to toggle source
# File lib/bio/utils/bio-synreport.rb, line 24
def cds_end
  @cds.flatten.max
end
cds_start() click to toggle source
# File lib/bio/utils/bio-synreport.rb, line 20
def cds_start
  @cds.flatten.min
end
codon_and_index(point) click to toggle source

returns codon and position of nucleotide

# File lib/bio/utils/bio-synreport.rb, line 60
def codon_and_index(point)
   distance_into_cds = get_nt_number_in_cds point
   codon_idx = codon_index distance_into_cds
   codon_list = codon_array
   codon = codon_list[codon_idx]
   pos = codon_position(distance_into_cds)
   [codon,pos]
end
codon_array() click to toggle source
# File lib/bio/utils/bio-synreport.rb, line 51
def codon_array
  codon_array = []; Bio::Sequence::NA.new(self.seq).window_search(3,3) {|b| codon_array << b}
  codon_array
end
codon_index(dist) click to toggle source
# File lib/bio/utils/bio-synreport.rb, line 43
def codon_index(dist)
  (dist - 1) / 3
end
codon_position(dist) click to toggle source
# File lib/bio/utils/bio-synreport.rb, line 47
def codon_position(dist)
  (dist - 1) % 3
end
get_nt_number_in_cds(point) click to toggle source
# File lib/bio/utils/bio-synreport.rb, line 28
def get_nt_number_in_cds(point)
  to_count = @cds.sort.select {|a| a.first <= point}
  in_block = to_count.pop
  distance_in = to_count.inject(1) {|tot, b| tot + ( b.last - b.first) + 1 }
  overhang =  point - in_block.first 
  left_section = distance_in + overhang
  
  if self.strand == '-'
      length = @cds.sort.inject(0) {|tot, b| tot + ( b.last - b.first) + 1 }
      return length - left_section + 1
  end
  
  return left_section
end
includes?(seq, point) click to toggle source
# File lib/bio/utils/bio-synreport.rb, line 15
def includes?(seq, point)
  return true if self.seqname == seq and point.to_i >= self.cds_start and point.to_i <= self.cds_end
  false
end
nt() click to toggle source
# File lib/bio/utils/bio-synreport.rb, line 56
def nt
end
substitution_info(point,alt) click to toggle source
# File lib/bio/utils/bio-synreport.rb, line 69
def substitution_info(point,alt)
      codon, position = codon_and_index(point)
      new_codon = codon.dup
      new_codon[position] = alt.downcase
      
      a = Bio::Sequence::NA.new(codon).translate.codes.first
      b =  Bio::Sequence::NA.new(new_codon).translate.codes.first
      sub_type = a == b ? "SYN" : "NON_SYN"
      return {#:id => self.gffid,
              :chr => self.seqname, 
              :strand => self.strand, 
              :position => point,
              :original_codon => codon, 
              :original_residue => a || 'stop', 
              :mutant_codon => new_codon, 
              :mutant_residue =>b || 'stop', 
              :position_in_codon => position + 1, 
              :substitution_type => sub_type
              }

end