Class: Bio::Util::MrnaModel
- Inherits:
-
Object
- Object
- Bio::Util::MrnaModel
- Defined in:
- lib/bio/utils/bio-synreport.rb
Instance Attribute Summary collapse
-
#cds ⇒ Object
Returns the value of attribute cds.
-
#gff_id ⇒ Object
Returns the value of attribute gff_id.
-
#seqname ⇒ Object
Returns the value of attribute seqname.
-
#sequences ⇒ Object
Returns the value of attribute sequences.
-
#strand ⇒ Object
Returns the value of attribute strand.
Instance Method Summary collapse
- #includes?(seq, point) ⇒ Boolean
-
#initialize(chr, id, strand, cds_arr, seq_arr) ⇒ MrnaModel
constructor
A new instance of MrnaModel.
- #seq ⇒ Object
- #substitution_info(chr, point, alt) ⇒ Object
Constructor Details
#initialize(chr, id, strand, cds_arr, seq_arr) ⇒ MrnaModel
Returns a new instance of MrnaModel.
11 12 13 |
# File 'lib/bio/utils/bio-synreport.rb', line 11 def initialize(chr, id, strand, cds_arr, seq_arr) @seqname, @gff_id, @strand, @cds, @sequences = chr, id, strand, cds_arr, seq_arr 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 |
#gff_id ⇒ Object
Returns the value of attribute gff_id.
9 10 11 |
# File 'lib/bio/utils/bio-synreport.rb', line 9 def gff_id @gff_id end |
#seqname ⇒ Object
Returns the value of attribute seqname.
9 10 11 |
# File 'lib/bio/utils/bio-synreport.rb', line 9 def seqname @seqname end |
#sequences ⇒ Object
Returns the value of attribute sequences.
9 10 11 |
# File 'lib/bio/utils/bio-synreport.rb', line 9 def sequences @sequences end |
#strand ⇒ Object
Returns the value of attribute strand.
9 10 11 |
# File 'lib/bio/utils/bio-synreport.rb', line 9 def strand @strand end |
Instance Method Details
#includes?(seq, point) ⇒ Boolean
15 16 17 18 |
# File 'lib/bio/utils/bio-synreport.rb', line 15 def includes?(seq, point) @cds.each {|start, stop| return true if @seqname == seq and point.to_i >= start and point.to_i <= stop} false end |
#seq ⇒ Object
20 21 22 |
# File 'lib/bio/utils/bio-synreport.rb', line 20 def seq @sequences.join end |
#substitution_info(chr, point, alt) ⇒ Object
24 25 26 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 60 61 62 63 |
# File 'lib/bio/utils/bio-synreport.rb', line 24 def substitution_info(chr,point,alt) cds_start = @cds.first.first running_total = 0 @cds.each do |start,stop| if point.to_i >= start and point.to_i <= stop offset = case @strand when "+" #offset = (point.to_i - start) + running_total when "-" (stop - point.to_i) + running_total end #offset = how far into cds SNP is codon_number = offset / 3 position_in_codon = offset % 3 #pp [offset, codon_number, position_in_codon] codon_array = []; Bio::Sequence::NA.new(self.seq).window_search(3,3) {|b| codon_array << b} codon = codon_array[codon_number] nt = codon[position_in_codon] new_codon = codon.dup new_codon[position_in_codon] = alt.downcase #pp [codon, position_in_codon, nt, new_codon] 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 => @gff_id, :chr => @seqname, :strand => @strand, :position => point, :original_codon => codon, :original_residue => a || 'stop', :mutant_codon => new_codon, :mutant_residue =>b || 'stop', :position_in_codon => position_in_codon + 1, :substitution_type => sub_type } end running_total += (stop - start) running_total += 1 if @strand == '-' #how far we are into the cds end end |