Module: Bioinform::IUPAC

Defined in:
lib/bioinform/alphabet.rb

Constant Summary collapse

NucleotideIndicesByIUPACLetter =
{
  A: [0], C: [1], G: [2], T: [3],
  M: [0, 1], R: [0, 2], W: [0, 3], S: [1, 2], Y: [1, 3], K: [2, 3],
  V: [0, 1, 2], H: [0, 1, 3], D: [0, 2, 3], B: [1, 2, 3],
  N: [0, 1, 2, 3]
}
IUPACLettersByNucleotideIndices =
Bioinform::Support.with_key_permutations(NucleotideIndicesByIUPACLetter.invert)

Class Method Summary collapse

Class Method Details

.complement_iupac_letter(iupac_letter) ⇒ Object



72
73
74
75
76
# File 'lib/bioinform/alphabet.rb', line 72

def self.complement_iupac_letter(iupac_letter)
  nucleotide_indices = NucleotideIndicesByIUPACLetter[iupac_letter]
  complement_nucleotide_indices = nucleotide_indices.map{|nucleotide_index| 3 - nucleotide_index }
  IUPACLettersByNucleotideIndices[complement_nucleotide_indices]
end