Commit 5886d653 authored by Aurelien Brionne's avatar Aurelien Brionne
Browse files

if not gff reader correction

parent 9dd07e57
......@@ -391,48 +391,55 @@ setMethod("build_genome_features",definition=function(txdb,features,parameters)
# read the gff
file=AnnotationDbi::metadata(txdb)$value[3]
###################
# download
if(base::length(grep("ftp.+\\.gz$",file))>0){
if(!base::is.na(file)){
###################
# import the GFF
utils::download.file(file,quiet=T,destfile = "gff.gz")
# download
if(base::length(grep("ftp.+\\.gz$",file))>0){
##################
# uncompress
R.utils::gunzip("gff.gz")
###################
# import the GFF
utils::download.file(file,quiet=T,destfile = "gff.gz")
##################
# file to download
file="gff"
}
##################
# uncompress
R.utils::gunzip("gff.gz")
###################
# read the gff
#gff<-data.table::fread(file,fill=T,drop=base::c(2,6,8),verbose=F,showProgress=F,col.names=base::c("chr",
#"type","start","end","strand","att"))[data.table::like(type,"RNA|transcript") & !data.table::like(chr,"^#")]
##################
# file to download
file="gff"
}
gff<-data.table::fread(file,sep="",verbose=F,showProgress=F,header=F)[data.table::like(base::gsub("ID=.+$","",V1),"[[:space:]].+(RNA|transcript)"),]
###################
# read the gff
#gff<-data.table::fread(file,fill=T,drop=base::c(2,6,8),verbose=F,showProgress=F,col.names=base::c("chr",
#"type","start","end","strand","att"))[data.table::like(type,"RNA|transcript") & !data.table::like(chr,"^#")]
###################
# parse it
gff<-gff[,{
tmp=data.table::data.table(base::t(base::strsplit(V1,"\t")[[1]]));
base::list(chr=tmp$V1,type=tmp$V3,start=tmp$V4,end=tmp$V5,strand=tmp$V7,att=tmp$V9)
},by=1:base::nrow(gff)][,base:=NULL]
gff<-data.table::fread(file,sep="",verbose=F,showProgress=F,header=F)[data.table::like(base::gsub("ID=.+$","",V1),"[[:space:]].+(RNA|transcript)"),]
###################
# remove files
if(file=="gff"){base::unlink("gff");base::unlink("gff.gz")}
###################
# parse it
gff<-gff[,{
tmp=data.table::data.table(base::t(base::strsplit(V1,"\t")[[1]]));
base::list(chr=tmp$V1,type=tmp$V3,start=tmp$V4,end=tmp$V5,strand=tmp$V7,att=tmp$V9)
},by=1:base::nrow(gff)][,base:=NULL]
###################
# extract all GeneID
gff<-GenomeFeatures::GFF_att(gff,att.list = c("Name","GeneID","gene"))
###################
# remove files
if(file=="gff"){base::unlink("gff");base::unlink("gff.gz")}
###################
# extract all GeneID
gff<-base::unique(gff[,.(type,Name,GeneID,gene)])
###################
# extract all GeneID
gff<-GenomeFeatures::GFF_att(gff,att.list = c("Name","GeneID","gene"))
###################
# extract all GeneID
gff<-base::unique(gff[,.(type,Name,GeneID,gene)])
}else{
###################
# else NA
gff=NA
}
###################
# create genome_features
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment