Learn R Programming

phylotools (version 0.1.2)

fasta.split: Split the fasta object to fasta objects

Description

Split the fasta object to fasta objects according to the groups given

Usage

fasta.split(fasta, ref, save2disk = FALSE)

Arguments

fasta
The fasta object
ref
Data frame with first column of the names of the sequences , the second column which group it belongs to.
save2disk
Whether to save the groups of fasta files to separate files

Value

Returns a list, indicate the groups for the sequences

Details

This function may be used to split the trnH-psbA sequences, given the order ( usually APGIII ) it belongs to.

References

Non.

See Also

rename.fasta

Examples

Run this code

library(seqRFLP)
## loading data
data(fil.fas)
## Get the names of the sequences
col1 <- gnames.fas(fil.fas)
## Generating new names
col2 <- paste("seq", 1:length(col1), sep = "")
reftable.rename <- data.frame(col1, col2)
renamed <- rename.fasta(fil.fas, reftable.rename)

##Generate split factor levels.
index <- rep(NA, length(col2))
level1 <- seq(1, length(col2), by = 2)
index[level1] <- 1
index[-level1] <- 2

## Reference table
reftable.split <- data.frame(col2, index)

## split the fasta object
fasta.split(renamed, reftable.split)

Run the code above in your browser using DataLab