Skip to contents

This function exports to a file a list of residue substitutions. The format used will be the same one as requested by the web version of Align-GVGD.

Usage

write_substitutions(
  file,
  alignment,
  poi,
  sub,
  mode = c("recycle", "expand_grid")
)

Arguments

file

A file path.

alignment

A character matrix or an alignment object obtained with read_alignment(). Rows are expected to be sequences of single characters (protein residues), and columns the alignment positions. The first row must be the reference sequence, i.e. the sequence whose substitutions will be evaluated against.

poi

A whole number indicating the position of interest (POI).

sub

A character vector of protein residue substitutions to be classified. The amino acids must be provided as one-letter symbols.

mode

If both poi and sub contain more than one element, mode specifies how these two inputs are combined. If mode = 'recycle' the shortest vector is recycled to match the length of the longest. If mode = 'expand_grid', all combinations between elements of poi and sub are combined.

Value

This function is run for its side effect of writing a file. But it returns the file path passed in file.

Examples

# \dontshow{
.old_wd <- setwd(tempdir())
# }
write_substitutions(file = "ex01.csv",
                    alignment = read_alignment("ATM"),
                    poi = 20:25,
                    sub = amino_acids())
#> [1] "ex01.csv"
cat(readLines("ex01.csv"), sep = "\n")
#> R19S
#> A20R
#> T21L
#> E22P
#> R23T
#> K24A
#> R19V
#> A20G
#> T21I
#> E22F
#> R23Y
#> K24C
#> R19H
#> A20Q
#> T21N
#> E22K
#> R23D
#> K24E
#> R19M
#> A20W

write_substitutions(file = "ex02.csv",
                    alignment = read_alignment("ATM"),
                    poi = 20:21,
                    sub = amino_acids(),
                    mode = 'expand_grid')
#> [1] "ex02.csv"
cat(readLines("ex02.csv"), sep = "\n")
#> R19S
#> R19R
#> R19L
#> R19P
#> R19T
#> R19A
#> R19V
#> R19G
#> R19I
#> R19F
#> R19Y
#> R19C
#> R19H
#> R19Q
#> R19N
#> R19K
#> R19D
#> R19E
#> R19M
#> R19W
#> A20S
#> A20R
#> A20L
#> A20P
#> A20T
#> A20A
#> A20V
#> A20G
#> A20I
#> A20F
#> A20Y
#> A20C
#> A20H
#> A20Q
#> A20N
#> A20K
#> A20D
#> A20E
#> A20M
#> A20W
# \dontshow{
setwd(.old_wd)
# }