if (FALSE) {
# Download the records
data_for_export_ids <- bold.public.search(taxonomy = list("Poecilia reticulata"))
# Fetch the data using the ids.
#1. api_key must be obtained from BOLD support before using `bold.fetch()` function.
#2. Use the `bold.apikey()` function to set the apikey in the global env.
bold.apikey('apikey')
# Fetching the data using the ids
data_for_export <- bold.fetch(get_by = "processid",
identifiers = data_for_export_ids$processid)
#1. Export the BCDM data using 'presets' as a csv file
bold.export(bold_df=data_for_export,
export_type = "preset_df",
presets = 'taxonomy',
export = file.path(tempdir(), "file_path_with_intended_name.csv"))
#2. Export the fasta file (unaligned)
# Note that input data here is the original BCDM data (data_for_export)
bold.export(bold_df = data_for_export,
export_type = "fas",
cols_for_fas_names = c("bin_uri","genus","species"),
export = file.path(tempdir(),"file_path_with_intended_name.fas"))
#3. Export multiple sequence alignment
#a. Align the data
# (using processid and bin_uri as fields for sequence names)
# Users need to install and load packages `msa` and `Biostrings` before using bold.analyze.align.
seq_align<-bold.analyze.align(data_for_export,
cols_for_seq_names = c("processid","bin_uri"),
align_method = "ClustalOmega")
#b. Export the multiple sequence alignment
# Note the input data here is the modified BCDM data (seq_align)
bold.export(bold_df=seq_align,
export_type = "msa",
export = "file_path_with_intended_name.fas")#'
}
Run the code above in your browser using DataLab