R/unzipData.R

Defines functions unzipData

Documented in unzipData

#' Unzip the downloaded Data
#'
#' use the unzipData() fuction to unzip the downloaded Data,
#' get the reads counts of samples.
#' @import R.utils
#' @param dataPath the direction of download Data
#' @export
unzipData<-function(dataPath){
setwd(dataPath)
if (!file.exists('all')) {
  dir.create('all')
}
if (!file.exists('output')) {
  dir.create('output')
}

file_lists=list.files(pattern = '.*\\-.*\\-.*\\-.*\\-.*')

for (n in file_lists) {
  x.path = paste(n, list.files(n), sep = '/')
  if(!file.exists(paste("./all",n,sep='/'))){
    file.copy(x.path, './all')
  }
}

wdir = paste(dataPath, "all", sep = "/")
setwd(wdir)
i = 1
for (file in list.files(pattern = "*.gz")) {
  print(paste0(file, "正在解压文件..."))
  R.utils::gunzip(file, remove = T,overwrite=T)
  print(paste0("已经解压完成 ", paste0(i, " 个!")))
  i = i + 1
}
#删除annotation文件
file.remove("annotations.txt")
setwd(dataPath)
message("Completed!")

}
dming1024/TCGApackages0226 documentation built on April 9, 2021, 7:48 a.m.