view gff2tabular.R @ 2:90c46e40d222 draft

planemo upload for repository https://github.com/kavonrtep/galaxy_packages commit 248ffeb6792d5807820b664eae3e88306f3f395e-dirty
author petr-novak
date Mon, 26 Feb 2024 13:11:53 +0000
parents 639c0edb7e64
children
line wrap: on
line source

#!/usr/bin/env Rscript
library(rtracklayer)
gff <- import(commandArgs(T)[1], format='GFF')
tabular <- as.data.frame(gff)
head(tabular)
# some columns are lists, we need to convert them to vectors  before writing to file
for (i in 1:ncol(tabular)){
  if (is.list(tabular[[i]])){
    tabular[[i]] <- sapply(tabular[[i]], function(x) paste(x, collapse = ";"))
  }
}
write.table(tabular, file = commandArgs(T)[2], quote=FALSE, sep="\t", row.names=FALSE)