class ORF

Attributes

aa[R]
descr[R]
frame[R]
id[R]
nt[R]

Public Class Methods

new(num, type, id, descr, nt, frame, start, aa) click to toggle source
# 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

Public Instance Methods

<=>(other) click to toggle source
# 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_fastarec() click to toggle source
# 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