Class: Bio::Util::MrnaModel
- Inherits:
-
GFF::GFF3::Record
- Object
- GFF::GFF3::Record
- Bio::Util::MrnaModel
- Defined in:
- lib/bio/utils/bio-synreport.rb
Instance Attribute Summary collapse
-
#cds ⇒ Object
Returns the value of attribute cds.
-
#seq ⇒ Object
Returns the value of attribute seq.
Instance Method Summary collapse
- #cds_end ⇒ Object
- #cds_start ⇒ Object
-
#codon_and_index(point) ⇒ Object
returns codon and position of nucleotide.
- #codon_array ⇒ Object
- #codon_index(dist) ⇒ Object
- #codon_position(dist) ⇒ Object
- #get_nt_number_in_cds(point) ⇒ Object
- #includes?(seq, point) ⇒ Boolean
-
#initialize(gff_line) ⇒ MrnaModel
constructor
A new instance of MrnaModel.
- #nt ⇒ Object
- #substitution_info(point, alt) ⇒ Object
Constructor Details
#initialize(gff_line) ⇒ MrnaModel
Returns a new instance of MrnaModel.
10 11 12 13 |
# File 'lib/bio/utils/bio-synreport.rb', line 10 def initialize(gff_line) super gff_line @cds = [] end |
Instance Attribute Details
#cds ⇒ Object
Returns the value of attribute cds.
9 10 11 |
# File 'lib/bio/utils/bio-synreport.rb', line 9 def cds @cds end |
#seq ⇒ Object
Returns the value of attribute seq.
9 10 11 |
# File 'lib/bio/utils/bio-synreport.rb', line 9 def seq @seq end |
Instance Method Details
#cds_end ⇒ Object
24 25 26 |
# File 'lib/bio/utils/bio-synreport.rb', line 24 def cds_end @cds.flatten.max end |
#cds_start ⇒ Object
20 21 22 |
# File 'lib/bio/utils/bio-synreport.rb', line 20 def cds_start @cds.flatten.min end |
#codon_and_index(point) ⇒ Object
returns codon and position of nucleotide
60 61 62 63 64 65 66 67 |
# 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 ⇒ Object
51 52 53 54 |
# 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) ⇒ Object
43 44 45 |
# File 'lib/bio/utils/bio-synreport.rb', line 43 def codon_index(dist) (dist - 1) / 3 end |
#codon_position(dist) ⇒ Object
47 48 49 |
# File 'lib/bio/utils/bio-synreport.rb', line 47 def codon_position(dist) (dist - 1) % 3 end |
#get_nt_number_in_cds(point) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# 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) ⇒ Boolean
15 16 17 18 |
# 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 ⇒ Object
56 57 |
# File 'lib/bio/utils/bio-synreport.rb', line 56 def nt end |
#substitution_info(point, alt) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# 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 |