usage:
shuf.sh "bedtools cmd" "metric" $genome
where metric must accept the output from bedtools cmd and return a single numeric value.
bash shuf.sh "bedtools intersect -a a.bed -b b.bed" "awk '{s+=\$3-\$2}END{print 1}'" hg19.genome
or
bash shuf.sh "bedtools intersect -a a.bed -b b.bed" "wc -l" contigs.genome
> observed cmd: bedtools intersect -a a.bed -b b.bed | awk '{s+=$3-$2}END{print s}'
> observed value: 425
> sim command: bedtools intersect -a a.bed -b <(bedtools shuffle -allowBeyondChromEnd -i b.bed -g contigs.genome) \
| awk '{s+=$3-$2}END{print s}'
> running 60 shufflings and comparing to observed
p-value: 0.131148