This function takes an alignment and exports it to a FASTA file.
Arguments
- alignment
An alignment. It may be a simple matrix or an object obtained with
read_alignment()
.- file
A file path.
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())
# }
alignment <- matrix(
c('P', 'M', 'I',
'P', 'I', 'I',
'P', 'L', 'I'),
nrow = 3,
byrow = TRUE
)
# Export an alignment based on a matrix
write_alignment(alignment, "my_alignment.fasta")
#> [1] "my_alignment.fasta"
cat(readLines("my_alignment.fasta"), sep = "\n")
#> >seq_01
#> PMI
#> >seq_02
#> PII
#> >seq_03
#> PLI
# Export one of the bundled alignments
write_alignment(read_alignment(gene = 'BRCA1'), "BRCA1.fasta")
#> [1] "BRCA1.fasta"
cat(readLines("BRCA1.fasta")[1:10], sep = "\n")
#> >B1_Hsap_NP_009225
#> MDLSALRVEEVQNVINAMQKILECPICLELIKEPVSTKCDHIFCKFCMLK
#> LLN-QKKGPSQCPLCKNDITKRSLQESTRFSQLVEELLKIICAFQLDTGL
#> EYANSYNFAKKENN--SPEHL--KDEVSIIQSMGYRNRAKRLLQSEP--E
#> NPSLQETSLSVQLSNLGTV-RTLRTKQRIQPQKTS--VYIELGSDSSE-D
#> TVNKATYCSVGDQELLQITPQGTRDEISLDS------AKKAACEFSETDV
#> TNTEHHQPSNNDLNTTEKRAAERHPEKYQGSSVSNLHVEP--CGTNT---
#> HASSLQHENSSLLLTKDRMNVEKAEFCNKSKQPGLARSQHNRWAGSKETC
#> NDRRTPSTE--KKVDLNADPLCERKEWNKQKL-PCSENPRDTEDVPWIT-
#> -LNSSIQKVNEWFSRSDELLGSDDSHDGESESNAKVADVLDVLNEVDEYS
# \dontshow{
setwd(.old_wd)
# }