Class: Bio::NucleicAcid

Inherits:
Object
  • Object
show all
Defined in:
lib/bio/BIOExtensions.rb

Constant Summary collapse

IUPAC_CODES =
{

  'y' => 'ct',
  'r' => 'ag',
  'w' => 'at',
  's' => 'cg',
  'k' => 'gt',
  'm' => 'ac',

  'b' => 'cgt',
  'd' => 'agt',
  'h' => 'act',
  'v' => 'acg',

  'n' => 'acgt',

  'a' => 'a',
  't' => 't',
  'g' => 'g',
  'c' => 'c',
  'u' => 'u',

  'ct' => 'y',
  'ag' => 'r',
  'at' => 'w',
  'cg' => 's',
  'gt' => 'k',
  'ac' => 'm',

  'cgt' => 'b',
  'agt' => 'd',
  'act' => 'h',
  'acg' => 'v',

  'acgt' => 'n'
}

Class Method Summary collapse

Class Method Details

.is_unambiguous(base) ⇒ Object



105
106
107
# File 'lib/bio/BIOExtensions.rb', line 105

def self.is_unambiguous(base)
  "acgtACGT".match(base)
end

.is_valid(code, base) ⇒ Object



118
119
120
# File 'lib/bio/BIOExtensions.rb', line 118

def self.is_valid(code, base)
  IUPAC_CODES[code.downcase].chars.include? base.downcase
end

.to_IUAPC(bases) ⇒ Object



109
110
111
112
113
114
115
116
# File 'lib/bio/BIOExtensions.rb', line 109

def self.to_IUAPC(bases)    
  base = IUPAC_CODES[bases.to_s.downcase.chars.sort.uniq.join]
  if base == nil
    p "Invalid base! #{base}"
    base = 'n' #This is a patch... as one of the scripts failed here. 
  end
  base.upcase
end