Skip to contents

Converts amino acid one-letter abbreviations to three-letter codes, e.g., L to Leu. The accepted codes in the input include the 20 standard amino acids and also B (Asparagine or Aspartic acid), converted to Asx, and Z (Glutamine or Glutamic acid) converted to Glx.

Usage

as_three_letter(x)

Arguments

x

A character vector of one-letter amino acid codes, e.g. "S", "R", "L", or "P".

Value

A character vector of three-letter amino acid codes, e.g. "Ser", "Arg", "Leu", or "Pro".

Examples

# Convert S to Ser, R to Arg and P to Pro.
as_three_letter(c("S", "R", "P"))
#> [1] "Ser" "Arg" "Pro"

# The function `as_three_letter()` is case insensitive on the input but will
# always return the three-letter codes with the first letter in uppercase.
as_three_letter(c("S", "s", "p", "P"))
#> [1] "Ser" "Ser" "Pro" "Pro"

# Convert also special case codes B (Asparagine or Aspartic acid) and Z
# (Glutamine or Glutamic acid)
as_three_letter(c("B", "Z"))
#> [1] "Asx" "Glx"

# Invalid codes in the input are converted to NA.
# "S" is correctly mapped to "Ser" but "Ser" and "Serine" are not
# one-letter amino acid codes and are therefore converted to NA.
as_three_letter(c("S", "s", "Ser", "Serine"))
#> [1] "Ser" "Ser" NA    NA