module Bio::Big::TranslationAdapter

Constants

VALID_FRAME_VALUES

Public Class Methods

pre_translate(seq,label) click to toggle source

Precompile sequence for EMBOSS

# File lib/bigbio/adapters/translate.rb, line 17
def self.pre_translate seq,label
  if Environment.instance.biolib
    Biolib::Emboss.ajSeqNewNameC(seq,"Test sequence")
  else
    nil
  end
end
translate(trn_table, frame, seq, pre_seq = nil) click to toggle source

Translate using frame (pre_seq is only used for EMBOSS)

Valid frame values are 0,1,2,3 and -1,-2,-3, where 0 and 1 are the standard reading frame. The negative values translate the reverse complement of the strand.

# File lib/bigbio/adapters/translate.rb, line 30
def self.translate trn_table, frame, seq, pre_seq = nil
  raise "Illegal frame #{frame}" if VALID_FRAME_VALUES.index(frame) == nil
  frame = 1 if frame == 0
  if Environment.instance.biolib
    # Using EMBOSS for translation
    ajpseq = pre_seq
    if not pre_seq
      ajpseq = Biolib::Emboss.ajSeqNewNameC(seq,"Test sequence")
    end
    ajpseqt  = Biolib::Emboss.ajTrnSeqOrig(trn_table,ajpseq,frame)
    Biolib::Emboss.ajSeqGetSeqCopyC(ajpseqt)
  else
    # Using BioRuby for translation
    ntseq = if frame > 0 
      Bio::Sequence::NA.new(seq[frame-1..-1])
    else
      # This to match EMBOSS frames
      rframe =
        case frame
          when -2 
            -3 
          when -3
            -2
          else 
            -1
        end
      Bio::Sequence::NA.new(seq[0..rframe]).reverse_complement
    end
    # pp ntseq
    ntseq.translate.to_s
  end
end
translation_table(num) click to toggle source
# File lib/bigbio/adapters/translate.rb, line 10
def self.translation_table num
  if Environment.instance.biolib
    Biolib::Emboss.ajTrnNewI(num)
  end
end