view gff2tabular.R @ 1:639c0edb7e64 draft

planemo upload for repository https://github.com/kavonrtep/galaxy_packages commit 248ffeb6792d5807820b664eae3e88306f3f395e-dirty
author petr-novak
date Mon, 26 Feb 2024 12:59:20 +0000
parents 696e702ebf74
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)