read_sequences: Read sequences from a file

View source: R/read_sequences.r

read_sequencesR Documentation

Read sequences from a file

Description

These functions read a sequence alignment file and return a named list of sequences. Currently supported formats are 'fasta' and 'nexus'. Interleaved formats, where sequences are defined in a repeating blocks, are not supported.

Usage

read_sequences(file, format = NULL)

read_fasta(file)

read_nexus(file)

Arguments

file

with alignment

format

requested format

Details

The function '[read_sequences]' tries to guess the correct format from the file extension. Alternatively, the correct format can be specified. Currently supported formats are fasta and nexus.

Functions '[read_fasta]' and '[read_nexus]' are then used to read the sequence alignment file.

Value

named list of sequences

Examples

seq1 = c("A" = "AAA", "B" = "BBB", "C" = "CCC")
fasta = tempfile(fileext = ".fasta")
writeLines(paste0(">", names(seq1), "\n", seq1), fasta)

seq2 = read_sequences(fasta)
seq3 = read_fasta(fasta)
identical(seq1, seq2)
identical(seq1, seq3)

bioDS/beter documentation built on June 15, 2022, 7:58 a.m.