Hi, I have three ints describing locations which I read to a hash data structure:
$VAR1 = { '27069_1' => { 'stop' => 214601666, 'start' => 214600991 }, '14644_1' => { 'stop' => 166950686, 'start' => 166950125 }, }
I'd need to remove the elements that have equal start/stop locations the ones that have lt start comparing to other but the stop will be between second elements start and stop. And if the second elements start is between the first elements start and stop and the stop is gt than the first elements stop. I know this is really hard to explain. I try to achieve this by creating the not that complex data structure with:
$tss{$ch[0]}{$id}={ start=>$start, stop=>$stop };
For some reason it manages to remove 'some' elements that have overlapping region in somehow but not all. The removing is done in:
for(keys(%the_hash)){ my $ch=$_; my @a=keys(%{$tss{$ch}}); my $tid=pop(@a); my $s=$tss{$ch}{$tid}{'start'}; my $st=$tss{$ch}{$tid}{'stop'}; foreach(keys(%{$tss{$ch}})){my $k=$_; if($tss{$ch}{$k}{'start'} eq $s and $tss{$ch}{$k}{'sto +p'} eq $st #and $_ ne $tid ){ delete($tss{$ch}{$k}); } ..... and so on
The loop is quite long having just more elif-statements to see if the regions overlap. I think the problem lies somewhere in the looping technique I'm using. I tried others but with no succes. Also I could change the data structure. Now it is having a hash, which has like 20 numeric keys, and each of those having multiple different id's (unique keys) and each id has the start and stop property. I try to access first for each of the 20 first elements as the id's can be groupd due that to smaller groups.
In reply to deleting elements in nested hash structure by lshadow
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |