Skip to content

Instantly share code, notes, and snippets.

@mikelove
Created June 16, 2016 18:33
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mikelove/f539631f9e187a8931d34779436a1c01 to your computer and use it in GitHub Desktop.
Save mikelove/f539631f9e187a8931d34779436a1c01 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)
}
@Benjamin-Lee
Copy link

Thanks for this! It was super useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment