Skip to content

Instantly share code, notes, and snippets.

@YulongNiu
Last active October 5, 2017 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YulongNiu/3e51804cb170b603b9633bd1fc0c611c to your computer and use it in GitHub Desktop.
Save YulongNiu/3e51804cb170b603b9633bd1fc0c611c to your computer and use it in GitHub Desktop.
Download gff/fna/ptt/rnt annotation files of a prokaryotic genome
###Download gff/fna/ptt/rnt annotation files of a prokaryotic genome ####
## Escherichia coli str. K-12 substr. MG1655 (E. coli)
## KEGG ID is 'eco' (http://www.genome.jp/kegg-bin/show_organism?org=eco)
## NCBI assembly ID is 'GCF_000005845.2' (https://www.ncbi.nlm.nih.gov/assembly/GCF_000005845.2)
library('ProGenome') ## version >= 0.06
library('magrittr')
## temporary folder for saving files
saveFolder <- 'ecoTemp'
## check folder
if (!dir.exists(saveFolder)) {
dir.create(saveFolder)
} else {}
## download gff, feature_table, and fna files
download.SpeAnno('eco', 'gff', saveFolder)
download.SpeAnno('eco', 'feature_table', saveFolder)
download.SpeAnno('eco', '[^from]_genomic.fna', saveFolder)
files <- dir(saveFolder, full.names = TRUE)
## extract the fna file as 'eco.fna'
files %>%
grepl('[^from]_genomic.fna', .) %>%
`[`(files, .) %>%
paste0('zcat ', ., ' > ', file.path(saveFolder, 'eco.fna')) %>%
system
## extract the gff file as 'eco.gff'
files %>%
grepl('gff', .) %>%
`[`(files, .) %>%
paste0('zcat ', ., ' > ', file.path(saveFolder, 'eco.gff')) %>%
system
## extract ptt files as 'eco.ptt'
## check ptt at http://cs.wellesley.edu/~btjaden/genomes/Escherichia_coli_K_12_substr__MG1655_uid57779/NC_000913.ptt
## extract rnt files as 'eco.rnt'
## check rnt at http://cs.wellesley.edu/~btjaden/genomes/Escherichia_coli_K_12_substr__MG1655_uid57779/NC_000913.rnt
ft <- files %>%
grepl('feature_table', .) %>%
`[`(files, .) %>%
read.gff
ft %>%
ExtractPtt %>%
write.ptt(file.path(saveFolder, 'eco.ptt'))
ft %>%
ExtractRnt %>%
write.rnt(file.path(saveFolder, 'eco.rnt'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment