Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: Finding Overlapping Regions on Genome

by oxydeepu (Novice)
on Jul 11, 2013 at 11:13 UTC ( #1043696=note: print w/replies, xml ) Need Help??

in reply to Finding Overlapping Regions on Genome

Hi all,

I am so sorry. I wont repeat the mistake. I do understand the policy.

The question is

how to get the overlapping coordinates pairs if there any? If yes take the smallest start position and largest stop position from overlapping coordinates and if no overlap for a pair, report as it is?

The example I gave was a small part of a huge file. I was manually doing it, that is why I missed some overlapping coordinates.

I did write a code for it.

here is the code which I wrote,

open $fh,"genome_pred_exons.bed"; use List::Util qw( min max ); while(<$fh>) { chomp; @lh = split /\t/,$_; $ph{$lh[0]."\t".$lh[1]."\t".$lh[2]} .= $lh[3]."\t".$lh[4]."NNN +NNN"; } close($fh); foreach $k(sort keys %ph) { @c = sort { $a <=> $b } split ("NNNNNN",$ph{$k}); @g = (); foreach $m(@c) { @r = split /\t/,$m; if (@g == 0) { push @g, [$r[0]+0, $r[1]+0]; next; } else { for ($i = 0;$i <= $#g;$i++) { if(($r[0] + 0) <= ($g[$i][1] + 1)) { $g[$i][0] = min($g[$i][0]+0, $r[0]+0); $g[$i][1] = max($g[$i][1]+0, $r[1]+0); last; } elsif ( $i == $#g ) { push @g, [$r[0]+0, $r[1]+0]; last; } } } } } print Dumper \@g;

This was an adapted script from internet. I changed it, but it did not give me any output.

I hope this is a better way to ask than the last one.

thank you, Deepak

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1043696]
[Corion]: Also, is it impossible in the general case, but doable in your specific case, maybe? I find that working through a counterexample usually makes people see the light
[Corion]: Uiiih! Let's Encrypt will start issuing wildcard certificates, that's cool!
[ambrus]: Corion: no, backwards. It's possible in the general case, but not in the specific case of bad data we have. Which is why it's harder to explain.
[marto]: that reminds me, to donate...
[ambrus]: If it was possible in this specific case, then the burden to argue for that would be his.

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (9)
As of 2017-12-12 13:10 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (332 votes). Check out past polls.