Find fasta files present in a folder

find_fasta(dir, pattern = "\\.fa$|\\.fas$|\\.fasta$", exclude)

Arguments

dir

Path to the directory which should be examined. If not provided, the current working directory (as returned by getwd) is used.

pattern

Regular expression used by list.files to detect the fasta files. The default is to list all files ending in ".fa", ".fas", and ".fasta".

exclude

Optional regular expression used to exclude some filenames from the list of detected files.

Value

A vector with the full paths to the found files.

Examples

# Get the directory containing the package example files
dir <- system.file("extdata", package = "concatipede")
# List the fasta files containing in that directory
find_fasta(dir)
#> [1] "/tmp/RtmphZaYwy/temp_libpath1b91336049f/concatipede/extdata/COI_Macrobiotidae.fas" 
#> [2] "/tmp/RtmphZaYwy/temp_libpath1b91336049f/concatipede/extdata/ITS2_Macrobiotidae.fas"
#> [3] "/tmp/RtmphZaYwy/temp_libpath1b91336049f/concatipede/extdata/LSU_Macrobiotidae.fas" 
#> [4] "/tmp/RtmphZaYwy/temp_libpath1b91336049f/concatipede/extdata/SSU_Macrobiotidae.fas" 
# Exclude some files
find_fasta(dir, exclude = "COI")
#> [1] "/tmp/RtmphZaYwy/temp_libpath1b91336049f/concatipede/extdata/ITS2_Macrobiotidae.fas"
#> [2] "/tmp/RtmphZaYwy/temp_libpath1b91336049f/concatipede/extdata/LSU_Macrobiotidae.fas" 
#> [3] "/tmp/RtmphZaYwy/temp_libpath1b91336049f/concatipede/extdata/SSU_Macrobiotidae.fas"