Skip to content

Instantly share code, notes, and snippets.

@tomsing1
Forked from mikelove/accession2url.R
Created November 1, 2016 21:29
Show Gist options
  • Save tomsing1/5ab62fbf96164cab2248123ecd27c90f to your computer and use it in GitHub Desktop.
Save tomsing1/5ab62fbf96164cab2248123ecd27c90f to your computer and use it in GitHub Desktop.
ENA accession to URL
accession2url <- function(x) {
prefix <- "ftp://ftp.sra.ebi.ac.uk/vol1/fastq"
dir1 <- paste0("/",substr(x,1,6))
dir2 <- ifelse(nchar(x) == 9, "",
ifelse(nchar(x) == 10, paste0("/00",substr(x,10,10)),
ifelse(nchar(x) == 11, paste0("/0",substr(x,10,11)),
paste0("/",substr(x,10,12)))))
paste0(prefix,dir1,dir2,"/",x)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment