Class: ORF

Inherits:
Object
  • Object
show all
Defined in:
lib/bigbio/sequence/predictorf.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(num, type, id, descr, nt, frame, start, aa) ⇒ ORF

Returns a new instance of ORF.



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/bigbio/sequence/predictorf.rb', line 42

def initialize num, type, id, descr, nt, frame, start, aa
  @id = id.to_s + '_' + (num + 1).to_s
  # ---- adjust start to match frame
  start += frame.abs-1
  # ---- stop should not go beyond sequence
  stop = start + aa.size * 3
  if stop > nt.size
    stop = nt.size
  end
  # ---- if frame < 0 it should reverse complement
  if frame < 0
    nt = Bio::Sequence::NA.new(nt).reverse_complement.to_s.upcase
  end
  # p [start, stop, stop-start]
  # p nt
  fr = frame.to_s
  fr = '+'+fr if frame > 0
  @descr = "[#{type} #{fr} #{start} - #{stop}; #{stop-start}/#{nt.size}] " + descr
  @nt = ORFnucleotides.new(nt, start, stop)
  @frame = frame
  @aa = ORFaminoacids.new(aa)
end

Instance Attribute Details

#aaObject (readonly)

Returns the value of attribute aa.



41
42
43
# File 'lib/bigbio/sequence/predictorf.rb', line 41

def aa
  @aa
end

#descrObject (readonly)

Returns the value of attribute descr.



41
42
43
# File 'lib/bigbio/sequence/predictorf.rb', line 41

def descr
  @descr
end

#frameObject (readonly)

Returns the value of attribute frame.



41
42
43
# File 'lib/bigbio/sequence/predictorf.rb', line 41

def frame
  @frame
end

#idObject (readonly)

Returns the value of attribute id.



41
42
43
# File 'lib/bigbio/sequence/predictorf.rb', line 41

def id
  @id
end

#ntObject (readonly)

Returns the value of attribute nt.



41
42
43
# File 'lib/bigbio/sequence/predictorf.rb', line 41

def nt
  @nt
end

Instance Method Details

#<=>(other) ⇒ Object



65
66
67
68
69
70
71
# File 'lib/bigbio/sequence/predictorf.rb', line 65

def <=> other
  if frame == other.frame
    nt.seq <=> other.nt.seq
  else
    frame <=> other.frame
  end
end

#to_fastarecObject



73
74
75
76
77
# File 'lib/bigbio/sequence/predictorf.rb', line 73

def to_fastarec
  aa = FastaRecord.new(@id,@descr,@aa.seq)
  nt = FastaRecord.new(@id,@descr,@nt.seq)
  FastaPairedRecord.new(nt,aa)
end