Here's one way you might debug and fix this issue.
The first step is to make an unsorted BED file, by using the `--do-not-sort` option:
$ gff2bed --do-not-sort < HzOGS2-15205-fixed_note-added.gff3 > HzOGS2-15205-fixed_note-added.gff3.unsorted.bed
The next step is to fix coordinates where the start coordinate is larger than or equal to the stop coordinate (which the BED format does not usually allow):
$ awk -v FS="\t" -v OFS="\t" '{ if ($2 > $3) { t = $2; $2 = $3; $3 = t; } else if ($2 == $3) { $3 = $3 + 1; } print $0; }' HzOGS2-15205-fixed_note-added.gff3.unsorted.bed > HzOGS2-15205-fixed_note-added.gff3.unsorted.fixed.bed
The final step is to sort the unsorted output:
$ sort-bed HzOGS2-15205-fixed_note-added.gff3.unsorted.fixed.bed > HzOGS2-15205-fixed_note-added.gff3.bed
Sorted output is easier to use with set operation tools.
I am posting these steps to show how to debug data. To streamline things, these steps can be done in one coordinated step, without creating any wasteful intermediate files:
$ gff2bed --do-not-sort < HzOGS2-15205-fixed_note-added.gff3 | awk -v FS="\t" -v OFS="\t" '{ if ($2 > $3) { t = $2; $2 = $3; $3 = t; } else if ($2 == $3) { $3 = $3 + 1; } print $0; }' | sort-bed - > HzOGS2-15205-fixed_note-added.gff3.bed
Please let me know if you run into any other issues.
Regards,
Alex