I am looking for a tool that can randomly shuffle gff features into intergenic regions, but leaving the gene-models 'intact', so that at least all features of a gene (transcript, exon, CDS, etc.) are placed on the same contig and related features are placed *fully inside the interval* of their parent region. Bedtools shuffle doesn't seem to do that, I am trying:

    shuffleBed -i genes.gff3 -excl genes.gff3 -g chromsizes.txt -f 0

This command distributes sub-features to different contigs and leads to invalid gene-models, if I add `-chrom`, features are placed on the same contig, but not all features can be placed at all and the resulting gene-models are still not valid. Does anyone maybe have some R-code for this use-case?
<p>Here&#39;s my second attempt, this time in Perl. It does more or less what I want with good speed, maybe I will add a few more options and documentation in the future. This solution is really fast enough, I tried to shuffle 100,000 features thereof 30,000 top-level genes over 30,000 contigs in a few seconds, more or less the time it takes to do the parsing and IO. Feel free to comment on possible improvements bugs, horrific code...</p>

<p><a href="http://mdondrup.github.io/shuffleGff/">http://mdondrup.github.io/shuffleGff/</a></p>

<p>Hint, to place genes only in intergenic regions use the same gff file as exclude and input.</p>
