http://www.perlmonks.org?node_id=1043671

oxydeepu has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

I have a small problem, I am not able to find a logic to do it.

Question is: I have a file of exons like this where col1 is chromosome name col2 is orientation and rest are start and stop.

Contig0 + 127874 130761
Contig0 + 129936 129984
Contig0 + 130572 133438
Contig0 + 130573 130607
Contig0 + 130630 130761
Contig0 + 130732 130767
Contig0 + 130784 130818
Contig0 + 130832 130866
Contig0 + 130832 130867
Contig0 + 130893 130928
Contig0 + 130970 131004
Contig0 + 130982 131017

As this coordinates have overlapping

Contig0 + 127874 130761
Contig0 + 129936 129984
Contig0 + 130572 133438
Contig0 + 130573 130607
Contig0 + 130630 130761
Contig0 + 130732 130767

It will be

Contig0 + 127874 130767

then

Contig0 + 130784 130818

doesn't have any over lap. Then,

Contig0 + 130832 130866
Contig0 + 130832 130867

will be

Contig0 + 130832 130867

After that no overlap for

Contig0 + 130893 130928

and for

Contig0 + 130970 131004
Contig0 + 130982 131017

it will be

Contig0 + 130970 131017

So at last the result for the example block will be

Contig0 + 127874 130767
Contig0 + 130893 130928
Contig0 + 130970 131017

I hope the question is clear.
Can anyone please help me with this.
Thank you in advance,
Deepak