File: write.fasta.Rd

package info (click to toggle)
r-cran-seqinr 3.4-5-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 5,876 kB
  • sloc: ansic: 1,987; makefile: 14
file content (44 lines) | stat: -rw-r--r-- 1,570 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
\name{write.fasta}
\alias{write.fasta}
\title{ Write sequence(s) into a file in fasta format }
\description{
  Writes one or more sequences into a file in FASTA format.
}

\usage{write.fasta(sequences, names, file.out, open = "w", nbchar = 60, as.string = FALSE)}

\arguments{
  \item{sequences}{ A DNA or protein sequence (in the form of a
    vector of single characters by default) or a list of such sequences. }
  \item{as.string}{ FALSE. When set to TRUE sequences are in the
    form of strings instead of vectors of single characters. }
  \item{names}{ The name(s) of the sequences. }
  \item{nbchar}{ The number of characters per line (default: 60) }
  \item{file.out}{ The name of the output file. }
  \item{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.}
}
\value{
 none.
}
\references{
  \code{citation("seqinr")}
}
\author{A. Nec┼čulea}
\seealso{ \code{\link{read.fasta}} }
\examples{
## Read 3 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 3 modified sequences to a file:
write.fasta(sequences = ortho3, names = names(ortho3), nbchar = 80, file.out = "ortho3.fasta")

## Read them again from the same file and check that sequences are preserved:
ortho3bis <- read.fasta("ortho3.fasta", set.attributes = FALSE)
stopifnot(identical(ortho3bis, ortho3))
}
\keyword{ utilities }