Module: Bio::Big::TranslationAdapter
- Included in:
- Nucleotide::Translate
- Defined in:
- lib/bigbio/adapters/translate.rb
Constant Summary collapse
- VALID_FRAME_VALUES =
[ 0, -1, -2, -3, 1, 2, 3 ]
Class Method Summary collapse
-
.pre_translate(seq, label) ⇒ Object
Precompile sequence for EMBOSS.
-
.translate(trn_table, frame, seq, pre_seq = nil) ⇒ Object
Translate using frame (pre_seq is only used for EMBOSS).
- .translation_table(num) ⇒ Object
Class Method Details
.pre_translate(seq, label) ⇒ Object
Precompile sequence for EMBOSS
17 18 19 20 21 22 23 |
# 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) ⇒ Object
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.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# 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) ⇒ Object
10 11 12 13 14 |
# File 'lib/bigbio/adapters/translate.rb', line 10 def self.translation_table num if Environment.instance.biolib Biolib::Emboss.ajTrnNewI(num) end end |