Last active
March 22, 2017 10:53
-
-
Save qgeissmann/c977fdfe8528f1311e43ad505c3839eb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rethomics) | |
# we define three functions to help us to download the data | |
syncIndexFile <- function(local_data_dir, remote, index_file = "index.txt"){ | |
url = paste(remote, index_file,sep="/") | |
dst_name = paste(local_data_dir, index_file,sep="/") | |
dir.create(local_data_dir, recursive=T) | |
download.file(url, dst_name) | |
dst_name | |
} | |
downloadCreateDir <-function(src,dst){ | |
dir.create(dirname(dst), recursive=T) | |
download.file(src,dst, mode="wb", method="libcurl") | |
} | |
fetchDataForQuery <- function(query_file, | |
local_dir, | |
remote = "ftp://nas.lab.gilest.ro/auto_generated_data/ethoscope_results/") | |
{ | |
query <- fread(query_file) | |
index_file <- syncIndexFile(local_data_dir, remote) | |
q <- buildEthoscopeQuery(result_dir=local_data_dir, query, index_file=index_file) | |
to_dl <- q[,.(dst = unique(path))] | |
to_dl[,src := gsub(local_data_dir, remote,dst)] | |
to_dl[,id := 1:nrow(to_dl)] | |
to_dl[,downloadCreateDir(src, dst),by=id] | |
q | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment