Class: FastaPairedRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/bigbio/db/fasta/fastarecord.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nt, aa) ⇒ FastaPairedRecord

Returns a new instance of FastaPairedRecord.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/bigbio/db/fasta/fastarecord.rb', line 19

def initialize nt, aa
  @nt = nt
  @aa = aa
  raise "ID error NT #{nt.id} not matching AA #{aa.id}" if nt.id != aa.id
  if nt.seq.size == aa.seq.size*3-1
    # account for EMBOSS cleverness
    nt.seq.chop!
    nt.seq.chop!
    aa.seq.chop!
  end
  if nt.seq.size == aa.seq.size*3-2
    # account for EMBOSS cleverness
    nt.seq.chop!
    aa.seq.chop!
  end
  if nt.seq.size == aa.seq.size*3-3
    aa.seq.chop!
  end
  nt_size = nt.seq.size
  expected_size = aa.seq.size*3
  # raise "Sequence size mismatch for #{nt.id} <nt:#{nt.seq.size} != #{aa.seq.size*3} (aa:#{aa.seq.size}*3)>" if expected_size - 3 > nt_size and  nt_size > expected_size + 3
end

Instance Attribute Details

#aaObject (readonly)

Returns the value of attribute aa.



17
18
19
# File 'lib/bigbio/db/fasta/fastarecord.rb', line 17

def aa
  @aa
end

#ntObject (readonly)

Returns the value of attribute nt.



17
18
19
# File 'lib/bigbio/db/fasta/fastarecord.rb', line 17

def nt
  @nt
end

Instance Method Details

#idObject



42
43
44
# File 'lib/bigbio/db/fasta/fastarecord.rb', line 42

def id
  @aa.id
end