knitr::opts_chunk$set(tidy = FALSE, message = FALSE)
library(magrittr) library(Biostrings) library("seqmagick")
tmpgb <- tempfile(fileext = '.gb') tmpfa <- tempfile(fileext = '.fa') download_genbank(acc='AB115403', format='genbank', outfile=tmpgb) download_genbank(acc='AB115403', format='fasta', outfile=tmpfa) ## readLines(tmpgb)[1:10] ## readLines(tmpfa)
fa_file <- system.file("extdata/HA.fas", package="seqmagick") ## use the small subset to save compilation time of the vignette fa2 <- tempfile(fileext = '.fa') fa_read(fa_file) %>% bs_filter('ATGAAAGTAAAA', by='sequence') %>% fa_write(fa2, type='interleaved') alnfas <- tempfile(fileext = ".fas") fa_read(fa2) %>% bs_aln(quiet=TRUE) %>% fa_write(alnfas) ## phylip format is only for aligned sequences tmpphy <- tempfile(fileext = ".phy") fas2phy(alnfas, tmpphy, type = 'sequential')
seqmagick
supports both sequential
and interleaved
formats, users can specify the format by type
parameter.
phy2fas(tmpphy, alnfas, type = 'interleaved')
tmpfas <- tempfile(fileext='.fa') fa_read(fa2) %>% fa_write(tmpfas, type="sequential")
tmpphy2 <- tempfile(fileext = '.phy') phy_read(tmpphy) %>% phy_write(tmpphy2, type="interleaved")
bs <- fa_read(fa_file) bs_filter(bs, 'ATGAAAGTAAAA', by='sequence') aln <- bs_filter(bs, 'ATGAAAGTAAAA', by='sequence') %>% bs_aln(quiet=TRUE) bs_consensus(aln)
If you have any, let me know. Thx!
Here is the output of sessionInfo()
on the system on which this document was compiled:
sessionInfo()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.