Class: PeptideToGeneAlignment
- Inherits:
-
Object
- Object
- PeptideToGeneAlignment
- Defined in:
- lib/protk/gapped_aligner.rb
Instance Attribute Summary collapse
-
#gene_seq ⇒ Object
Returns the value of attribute gene_seq.
-
#pep_seq ⇒ Object
Returns the value of attribute pep_seq.
-
#trace ⇒ Object
Returns the value of attribute trace.
Instance Method Summary collapse
- #fragments ⇒ Object
- #gaps ⇒ Object
-
#initialize(gene, peptide, trace) ⇒ PeptideToGeneAlignment
constructor
A new instance of PeptideToGeneAlignment.
- #inspect ⇒ Object
Constructor Details
#initialize(gene, peptide, trace) ⇒ PeptideToGeneAlignment
Returns a new instance of PeptideToGeneAlignment.
15 16 17 18 19 |
# File 'lib/protk/gapped_aligner.rb', line 15 def initialize(gene,peptide,trace) @gene_seq = gene @pep_seq = peptide @trace = trace end |
Instance Attribute Details
#gene_seq ⇒ Object
Returns the value of attribute gene_seq.
11 12 13 |
# File 'lib/protk/gapped_aligner.rb', line 11 def gene_seq @gene_seq end |
#pep_seq ⇒ Object
Returns the value of attribute pep_seq.
12 13 14 |
# File 'lib/protk/gapped_aligner.rb', line 12 def pep_seq @pep_seq end |
#trace ⇒ Object
Returns the value of attribute trace.
13 14 15 |
# File 'lib/protk/gapped_aligner.rb', line 13 def trace @trace end |
Instance Method Details
#fragments ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/protk/gapped_aligner.rb', line 47 def fragments frags=[] in_fragment=false @trace.each_with_index do |move,i| if move==0 frags << [i,0] unless in_fragment #Start a fragment in_fragment=true else frags.last[1]=i-1 if in_fragment #End a fragment in_fragment=false end end if frags.last[1]==0 frags.last[1]=@trace.length-1 end frags end |
#gaps ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/protk/gapped_aligner.rb', line 65 def gaps gps=[] in_start_end=true in_gap=false @trace.each_with_index do |move, i| if move==0 in_start_end=false if in_gap #Ending a gap gps.last[1]=i end in_gap=false else if !in_start_end && !in_gap #Starting a gap in_gap=true gps<<[i,0] end end end #Remove gaps that have zero length (Trailing) gps=gps.collect do |gp| rv=gp if gp[1]==0 rv=nil end rv end gps.compact! gps end |
#inspect ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/protk/gapped_aligner.rb', line 21 def inspect descr = "#{@gene_seq}\n" pep_triples="" @pep_seq.each_char { |c| pep_triples<<c;pep_triples<<c;pep_triples<<c } # gene_seq_triples="" # Bio::Sequence::NA.new(@gene_seq).translate.each_char do |c| # gene_seq_triples<<c;gene_seq_triples<<c;gene_seq_triples<<c # end # descr << "#{gene_seq_triples}\n" pepi=0 @trace.each_with_index do |move, i| if move==1 descr<<"-" elsif move==0 descr<<"#{pep_triples[pepi]}" pepi+=1 end end descr<<"\n" puts descr end |