Several (hundreds, even) sequences may be read, and it's apparently necessary to define a new object relating @nreg to the name of each sequence, as I find that the values for all sequences are pushed into the same array. Can anyone suggest a suitable way to set up a "new" method to relate a different @nreg to a particular sequence name, please? I've tried various permutations, which either use the same array every time or refuse to bless it (e.g. "Attempt to bless into a reference at..." messages appear). Thanks for any suggestions!sub addregion { my ($start,$end) = @_; if ($start > $end) { ($start,$end) = ($end,$start); } my $done = 0; my $k; my $tempcoding = 0; for ($k=0;$k<@nreg;$k++) { # calculate sum of bases $tempcoding += $nreg[$k][1] - $nreg[$k][0] + 1; # new region starts after old region ends next if ($nreg[$k][1] < $start); # new region ends before old region starts if ($end < $nreg[$k][0]) { splice(@nreg,$k,0,[$start,$end]); $done = 1; last; } # regions overlap $nreg[$k][0] = $start < $nreg[$k][0] ? $start : $nreg[$k][0]; $nreg[$k][1] = $end > $nreg[$k][1] ? $end : $nreg[$k][1]; $done = 1; # Combine two regions if the new section has brough about an o +verlap while ($k < $#nreg and $nreg[$k][1] > $nreg[$k+1][0]) { $nreg[$k][1] = $nreg[$k+1][1]; splice(@nreg,$k+1,1); } last; } unless ($done) { push @nreg,[$start,$end]; } }
In reply to Array of arrays used within object by knirirr
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |