Skip to content

Commit

Permalink
update to BOLD v5
Browse files Browse the repository at this point in the history
initial update, should work again
  • Loading branch information
VascoElbrecht committed Oct 30, 2024
1 parent ec1ac1a commit d55b338
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
*.history
*.history
.DS_Store
PrimerMiner/.DS_Store
Binary file modified PrimerMiner/.DS_Store
Binary file not shown.
26 changes: 19 additions & 7 deletions PrimerMiner/R/Download_bold.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,32 @@ bold.apikey(apikey_bold)

for (k in 1:length(taxon)){
time <- Sys.time() # get time
data <- bold.public.search(taxonomy = taxon[k]) # fetch process IDs for specific taxons
bold.data <- bold.public.search(taxonomy = taxon[k]) # fetch process IDs for specific taxons

data <- bold.fetch(get_by = "processid", identifiers = bold.data$processid)

# save tsv (without any processing)
if(save_bold_tsv){
write.table(data, file=paste(folder_path, taxon[k], "_BOLD.tsv"), quote=F, sep='\t', row.names=F)
}

# filter for only needed marker codes
data <- data[data$marker_code == marker_bold,]

# remove gabs from sequences
data$nuc <- gsub("-", "", data$nuc)
data <- data[nchar(data$nuc)>1,]


if(length(data)!=0){
cat(file=paste(folder_path, taxon[k], "_BOLD.fasta", sep="")) # delet old file
for (i in 1:length(data)){
exp <- paste(">", data[i][[1]][1], "_", data[i][[1]][2], "\n", gsub("-", "", data[i][[1]][4]), "\n", sep="")
cat(exp, file=paste(folder_path, taxon[k], "_BOLD.fasta", sep=""), append=T)
}
exp <- paste(">", data$processid, "___", data$order, "_", data$species, "\n", data$nuc, "\n", sep="")

cat(exp, file=paste(folder_path, taxon[k], "_BOLD.fasta", sep=""), append=T, sep="")
}
time <- Sys.time() - time
message(paste("Downloaded ", length(data)," sequences for ", taxon[k], " in ", format(time, digits=2), " from BOLD.", sep=""))
cat(paste(taxon[k],"\t", length(data), "\t", format(time, digits=2), "\n", sep=""), file= logfile, sep="", append=T)
message(paste("Downloaded ", nrow(data)," sequences for ", taxon[k], " in ", format(time, digits=2), " from BOLD.", sep=""))
cat(paste(taxon[k],"\t", nrow(data), "\t", format(time, digits=2), "\n", sep=""), file= logfile, sep="", append=T)
}
cat("#Bold_data_end\n\n", file= logfile, sep="", append=T)
}
Expand Down
1 change: 1 addition & 0 deletions PrimerMiner/R/batch_down.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ if(download_and_cluster){
# download data!

if (Download){
message("Starting to downloand data for ", subFolder, ": \"", paste(taxa, collapse="\", \""), "\"")
if (download_bold){Download_BOLD(taxa, folder= subFolderPath, setwd=subFolder)}
if (download_GB){Download_GB(taxa, folder= subFolderPath, marker=Marker, maxlength= maxlength_GB, custom_query= custom_query_GB, setwd=subFolder, GB_subset=GB_Subset)}
if (download_mt){Download_mito(taxa, folder= subFolderPath, minlength= minlength_mt, maxlength= maxlength_mt, custom_query = custom_query_mt, setwd=subFolder, MT_Subset= mt_subset)
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ Please take a look at the PrimerMiner wiki for detailed package documentation an

1) Installation
You can install PrimerMiner directly from GitHub. You will also need to install [BOLDconnectR](https://github.com/boldsystems-central/BOLDconnectR).
`install.packages("devtools")`
`library("devtools")`
`install_github("boldsystems-central/BOLDconnectR")`
`install_github("VascoElbrecht/PrimerMiner", subdir="PrimerMiner")`
```
install.packages("devtools")
library("devtools")
install_github("boldsystems-central/BOLDconnectR")
install_github("VascoElbrecht/PrimerMiner", subdir="PrimerMiner")
```

Alternatively, you can download a specific PrimerMiner version manually and install it with:
`install.packages("path_to_package_file", repos = NULL, type="source", dependencies=T)`

Load the package with `library("PrimerMiner")`. You find all the commands and an executable example in the Sample_Data!

Important: you will need the apikey from you BOLD login to download bold data (currently November 2024 its not checked, any key works, but this might change in the future).
Important: you will need the apikey from you BOLD login to download bold data. You can find it under user settings in your BOLD login.

2) Batch downloading sequences
Generate the configuration file by runing `batch_config("config.txt")`in R. Edit this file to review and change the default settings.
Expand Down

0 comments on commit d55b338

Please sign in to comment.