Module: RGFA::Sequence
- Included in:
- String
- Defined in:
- lib/rgfa/sequence.rb
Overview
Extensions of the String class to handle nucleotidic sequences
Constant Summary collapse
- WCC =
Watson-Crick Complements
{"a"=>"t","t"=>"a","A"=>"T","T"=>"A", "c"=>"g","g"=>"c","C"=>"G","G"=>"C", "b"=>"v","B"=>"V","v"=>"b","V"=>"B", "h"=>"d","H"=>"D","d"=>"h","D"=>"H", "R"=>"Y","Y"=>"R","r"=>"y","y"=>"r", "K"=>"M","M"=>"K","k"=>"m","m"=>"k", "S"=>"S","s"=>"s","w"=>"w","W"=>"W", "n"=>"n","N"=>"N","u"=>"a","U"=>"A", "-"=>"-","."=>".","="=>"=", " "=>"","\n"=>""}
Instance Method Summary collapse
-
#rc(tolerant: false, rnasequence: false) ⇒ String
Computes the reverse complement of a nucleotidic sequence.
Instance Method Details
#rc(tolerant: false, rnasequence: false) ⇒ String
Computes the reverse complement of a nucleotidic sequence
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rgfa/sequence.rb', line 32 def rc(tolerant: false, rnasequence: false) return "*" if self == "*" retval = each_char.map do |c| if c == "U" or c == "u" rnasequence = true elsif rnasequence and (c == "T" or c == "t") raise "String contains both U/u and T/t" end wcc = WCC.fetch(c, tolerant ? c : nil) raise "#{self}: no Watson-Crick complement for #{c}" if wcc.nil? wcc end.reverse.join if rnasequence retval.tr!("tT","uU") end retval end |