view split_and_filter_tracks.R @ 12:755a4d643184 draft default tip

planemo upload commit a61591d548f42ff417781e7fe7418dc2901ccc23
author petr-novak
date Tue, 26 Sep 2023 07:28:04 +0000
parents ea6a3059a6af
children
line wrap: on
line source

#!/usr/bin/env Rscript
suppressPackageStartupMessages(library(rtracklayer))
gff = import(commandArgs(T)[1])
BN = gsub("[.]gff(3){0,1}","",basename(commandArgs(T)[1]))
min_width = as.numeric(commandArgs(T)[2])
outdir = commandArgs(T)[3]



gff_min_width=gff[width(gff)>=min_width]



dir.create(outdir, recursive = TRUE, showWarnings = FALSE)

gff_min_width_parts = split(gff_min_width, f=gff_min_width$Name)

x = sapply(names(gff_min_width_parts),
       function(x) export(
                     gff_min_width_parts[[x]],
                     format="gff3",
                     con=paste0(
                       outdir,"/",
                       gsub("/","_",x),
                       "_", min_width ,"plus.gff3"
                     )
                   ))