write.fasta {seqinr} | R Documentation |
Writes sequences to a file in FASTA format.
write.fasta(sequences, names, nbchar = 60, file.out, open = "w")
sequences |
A DNA or protein sequence (i.e. a character vector) or a list of sequences (i.e. a list of character vectors). |
names |
The name(s) of the sequences. |
nbchar |
The number of characters per line (default: 60) |
file.out |
The name of the output file. |
open |
Mode to open the output file, use "w" to write into a new file, use "a" to append at the end of an already existing file. |
NULL
Anamaria Necsulea
citation("seqinr")
## Read sequences from a FASTA file: ortho <- read.fasta(file = system.file("sequences/ortho.fasta", package = "seqinr")) ## Select only third codon positions: ortho3 <- lapply(ortho, function(x) x[seq(from = 3, to = length(x), by = 3)]) ## Write the modified sequences to a file: write.fasta(sequences = ortho3, names = names(ortho3), nbchar = 80, file.out = "ortho3.fasta") ## Read it again from the same file and check that sequences are preserved: ortho3bis <- read.fasta("ortho3.fasta", set.attributes = FALSE) stopifnot(identical(ortho3bis, ortho3))