If the contig is circular, then we consider segment pairs where seg2.end < seg1.start (or seg1.end < seg2.start on the negative strand) to be normally oriented and calculate the distance between them relative to the origin.
I think I also fixed another bug (for the non-circular case), changing seg1.range.start < seg2.range.start to seg1.range.start < seg2.range.end for the negative strand comparison.
If the contig is circular, then we consider segment pairs where seg2.end < seg1.start (or seg1.end < seg2.start on the negative strand) to be normally oriented and calculate the distance between them relative to the origin.
I think I also fixed another bug (for the non-circular case), changing
seg1.range.start < seg2.range.start
toseg1.range.start < seg2.range.end
for the negative strand comparison.