Class: Sequence
- Inherits:
-
Object
- Object
- Sequence
- Defined in:
- lib/full_lengther_next/classes/sequence.rb
Instance Attribute Summary collapse
-
#fasta_length ⇒ Object
Returns the value of attribute fasta_length.
-
#orfs ⇒ Object
Returns the value of attribute orfs.
-
#sec_desc ⇒ Object
Returns the value of attribute sec_desc.
-
#seq_fasta ⇒ Object
Returns the value of attribute seq_fasta.
-
#seq_name ⇒ Object
Returns the value of attribute seq_name.
-
#seq_qual ⇒ Object
Returns the value of attribute seq_qual.
Instance Method Summary collapse
- #add_orf(orf_seq, orf_t_start, orf_t_end, orf_frame, orf_stop_codon, orf_type) ⇒ Object
- #annotate(annotation_type, message = '', replace_existing = false) ⇒ Object
- #change_degenerated_nt! ⇒ Object
- #fix_degenerated_fasta!(tranlaste_hash) ⇒ Object
-
#get_annotations(annotation_type) ⇒ Object
:complete, :tmp_annotation, :error, :protein, :nucleotide, :alignment, :tcode.
-
#initialize(seq_name, seq_fasta, seq_qual = '') ⇒ Sequence
constructor
A new instance of Sequence.
- #reject!(message = '') ⇒ Object
- #rejected? ⇒ Boolean
Constructor Details
#initialize(seq_name, seq_fasta, seq_qual = '') ⇒ Sequence
Returns a new instance of Sequence.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/full_lengther_next/classes/sequence.rb', line 8 def initialize(seq_name,seq_fasta,seq_qual='') fasta_ori = seq_fasta.dup @seq_name=seq_name @seq_fasta = seq_fasta @fasta_length = fasta_ori.length change_degenerated_nt! @seq_qual = '' @sec_desc = '' @annotations=[] @orfs=[] @rejected=false @rejected_message='' end |
Instance Attribute Details
#fasta_length ⇒ Object
Returns the value of attribute fasta_length.
6 7 8 |
# File 'lib/full_lengther_next/classes/sequence.rb', line 6 def fasta_length @fasta_length end |
#orfs ⇒ Object
Returns the value of attribute orfs.
6 7 8 |
# File 'lib/full_lengther_next/classes/sequence.rb', line 6 def orfs @orfs end |
#sec_desc ⇒ Object
Returns the value of attribute sec_desc.
6 7 8 |
# File 'lib/full_lengther_next/classes/sequence.rb', line 6 def sec_desc @sec_desc end |
#seq_fasta ⇒ Object
Returns the value of attribute seq_fasta.
6 7 8 |
# File 'lib/full_lengther_next/classes/sequence.rb', line 6 def seq_fasta @seq_fasta end |
#seq_name ⇒ Object
Returns the value of attribute seq_name.
6 7 8 |
# File 'lib/full_lengther_next/classes/sequence.rb', line 6 def seq_name @seq_name end |
#seq_qual ⇒ Object
Returns the value of attribute seq_qual.
6 7 8 |
# File 'lib/full_lengther_next/classes/sequence.rb', line 6 def seq_qual @seq_qual end |
Instance Method Details
#add_orf(orf_seq, orf_t_start, orf_t_end, orf_frame, orf_stop_codon, orf_type) ⇒ Object
24 25 26 27 28 |
# File 'lib/full_lengther_next/classes/sequence.rb', line 24 def add_orf(orf_seq, orf_t_start, orf_t_end, orf_frame, orf_stop_codon, orf_type) orf = Orf.new(orf_seq, orf_t_start, orf_t_end, orf_frame, orf_stop_codon, orf_type) @orfs.push orf end |
#annotate(annotation_type, message = '', replace_existing = false) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/full_lengther_next/classes/sequence.rb', line 44 def annotate(annotation_type, ='', replace_existing = false) if replace_existing @annotations.reverse_each do |annotation| if annotation[:annotation_type]==annotation_type @annotations.delete(annotation) end end end @annotations.push({:annotation_type=>annotation_type,:message=>}) end |
#change_degenerated_nt! ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/full_lengther_next/classes/sequence.rb', line 58 def change_degenerated_nt! ######################################## tranlaste_hash = {} tranlaste_hash['R']= [['a','g'],0] tranlaste_hash['W']= [['a','t'],0] tranlaste_hash['M']= [['a','c'],0] tranlaste_hash['K']= [['g','t'],0] tranlaste_hash['S']= [['g','c'],0] tranlaste_hash['Y']= [['c','t'],0] tranlaste_hash['H']= [['a','t','c'],0] tranlaste_hash['B']= [['g','t','c'],0] tranlaste_hash['D']= [['g','a','t'],0] tranlaste_hash['V']= [['g','a','c'],0] tranlaste_hash['N']= [['g','a','c','t'],0] ######################################## fix_degenerated_fasta!(tranlaste_hash) end |
#fix_degenerated_fasta!(tranlaste_hash) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/full_lengther_next/classes/sequence.rb', line 83 def fix_degenerated_fasta!(tranlaste_hash) s = @seq_fasta res = [] nts_of_a_line = s.split('') nts_of_a_line.map{ |e| # puts "#{e} " if (e =~ /[RWMKSYHBDVN]/) # puts "#{e} " tranlaste_hash[e][1] += 1 # puts "#{e} #{tranlaste_hash[e][1]}" e = tranlaste_hash[e][0][tranlaste_hash[e][1]%tranlaste_hash[e][0].length] # puts "#{e}" end res.push e } @seq_fasta=res.compact.join # @seq_fasta='dario' end |
#get_annotations(annotation_type) ⇒ Object
:complete, :tmp_annotation, :error, :protein, :nucleotide, :alignment, :tcode
40 41 42 |
# File 'lib/full_lengther_next/classes/sequence.rb', line 40 def get_annotations(annotation_type) return @annotations.select{|a| a[:annotation_type]==annotation_type} end |
#reject!(message = '') ⇒ Object
34 35 36 37 |
# File 'lib/full_lengther_next/classes/sequence.rb', line 34 def reject!(='') @rejected=true @rejected_message= end |
#rejected? ⇒ Boolean
30 31 32 |
# File 'lib/full_lengther_next/classes/sequence.rb', line 30 def rejected? return @rejected end |