Writes a data frame containing id, sequence, and comment columns,
write_fasta
will write the data frame out to a
standard FASTA-formatted file.
The header will have a tab character between the sequence id and any
comments. There won't be a tab if there's no comment for the sequence. All
sequence data will be on a single line
Arguments
- data_frame
A data frame object with three columns. The
id
column will contain the non-space characters following the>
in the header line of each sequence; thesequence
column will contain the sequence; and thecomment
column will contain any text found after the first whitespace character on the header line. Thecomment
column is optional.- file
Either a path to a file, a connection, or literal data (either a single string or a raw vector) to write to a standard FASTA formatted file. There are no checks to determine whether the data are DNA or amino acid sequences.
Files ending in .gz, .bz2, .xz, or .zip will be automatically compressed. Files starting with
http://
,https://
,ftp://
, orftps://
will be automatically downloaded. Remote gz files can also be autom downloaded and decompressed.If the value of
file
isNULL
(default), the string will be written out to the screen
Examples
df_d <- data.frame(
id = c("seqA", "seqB", "seqC"),
sequence = c("ATGCATGC", "ATGCATGA", "ATGCATGT"),
comment = c("comment 1", "", "comment 3")
)
string_d <- write_fasta(df_d)