knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "README-"
)

Run mafft through outsider in R

Build Status

MAFFT (Multiple Alignment through Fast Fourier Transformation): Multiple alignment program for amino acid or nucleotide sequences offering range of methods: L-INS-i (accurate; for alignment of <∼200 sequences), FFT-NS-2 (fast; for alignment of <∼30,000 sequences), etc.

Install and look up help

library(outsider)
module_install(repo = 'dombennett/om..mafft')
# module_help(repo = 'dombennett/om..mafft')

Aligning DNA sequences

Small alignment example using the --auto argument.

library(outsider)
mafft <- module_import(fname = 'mafft', repo = "dombennett/om..mafft")

# get help
mafft('--help')

# download
wd <- file.path(tempdir(), 'mafft_example')
if (!dir.exists(wd)) {
  dir.create(wd)
}
# example DNA
seq_file <- file.path(wd, 'example_seq.fasta')
url <- 'https://raw.githubusercontent.com/DomBennett/om..pasta/master/example_seq.fasta'
download.file(url = url, destfile = seq_file)

# align
al_file <- file.path(wd, 'alignment.fasta')
mafft(arglist = c('--auto', '--quiet', seq_file, '>', al_file))

# verify
cat(paste0(readLines(al_file, n = 10), collapse = '\n'))

# add new sequences using the --add argument
al_file2 <- file.path(wd, 'alignment2.fasta')
url <- 'https://raw.githubusercontent.com/DomBennett/om..mafft/master/test_data/extra_seqs.fasta'
extra_file <- file.path(wd, 'extra_seqs.fasta')
download.file(url = url, destfile = extra_file)
# (no "--quiet" this time)
mafft(arglist = c('--add', extra_file, '--reorder', al_file, '>', al_file2))
if ('wd' %in% ls() && dir.exists(wd)) {
  unlink(x = wd, recursive = TRUE, force = TRUE)
}
module_uninstall(repo = 'dombennett/om..mafft')

Key arguments

mafft has the following signature:

mafft "--option" "input_file" > "output_file"

These arguments can be passed through R via the arglist as a character vector as demonstrated in the example above. Note, option arguments (--op, --ep, --maxiterate, etc.) must always precede the "input > output" statement. Also note, --man does not via R.

Links

Find out more by visiting the MAFFT homepage.

Please cite/read


An outsider module

Learn more at outsider website. Want to build your own module? Check out outsider.devtools website.



DomBennett/om..mafft documentation built on Jan. 21, 2020, 8:38 p.m.