darkreaper00
Technical User
I am pulling my hair out here, because @B should be static!
The problem is that I get the error 5, my values in @B are those that have been changed in @A, not the native values I wrote into @B specifically so I'd have a static copy to test against.
arg! Am I referencing something somewhere without realizing it?
Any help appreciated. Thanks.
Code:
foreach my $chr (keys %hits) {
foreach my $strand (keys %{$hits{$chr}}) {
my %ref;
## sort by location on subject then location on query.
[COLOR=red] my @A = sort {$a->[2]<=>$b->[2] || $a->[0]<=>$b->[0]} @{$hits{$chr}{$strand}} ;[/color]
# my @B = @A;
[COLOR=red] my @B = sort {$a->[2]<=>$b->[2] || $a->[0]<=>$b->[0]} @{$hits{$chr}{$strand}} ;[/color]
foreach $r (0..$#B){
$ref{$B[$r][5]} = $r if ($B[$r][5]);
}
print REPORT "$chr $strand has ",$#A+1," hits.\n";
print STDERR "$chr $strand \t";
LOCATION: foreach my $i (0..$#A) {
CONSIDER: foreach my $j ($i+1..$#A) {
print REPORT "\$i=$i, \$j=$j, $A[$i][3] <=> $A[$j][2], $A[$i][1] <=> $A[$j][0] ... ";
if ( $A[$j][2] > $A[$i][3] + $thresh ) {
print REPORT "0: fail: too far\n";
next LOCATION; }
elsif ( (abs($A[$j][2] - $A[$i][3]) < $thresh)
&& (abs($A[$j][0] - $A[$i][1]) < $thresh)
&& ( ( ($A[$j][0]>=$A[$i][1]-200) && ($strand eq "plus") )
or
( ($A[$j][0]<=$A[$i][1]+200) && ($strand eq "minus") ) )
#b/c sometimes a slight overhang breaks a module.
) {
# foreach my $h ($ref{$A[$i][5]}..$ref{$A[$j][5]}) {
foreach my $h (0..$ref{$A[$j][5]}) {
# can't settle on the first value. $ref-1 could be the same hit, ref{x-1} could be far, far away. *shrug*
if ( ( ($strand eq "plus") && ($B[$h][0] < $A[$j][0]-20) && ($B[$h][1] > $A[$i][1]+20) && ($A[$j][0]-$A[$i][1]>40) )
|| ( ($strand eq "minus") && ($B[$h][0] > $A[$j][0]+20) && ($B[$h][1] < $A[$i][1]-20) && ($A[$i][1]-$A[$j][0]>40) )
) {
[COLOR=red]print REPORT "5: fail: insertion $B[$h][0], $B[$h][1] between $A[$j][0] and $A[$i][1] \n";[/color]
next LOCATION;
}
}
[COLOR=red] ($A[$i][1],$A[$i][3]) = ($A[$j][1],$A[$j][3]);
splice (@A, $j, 1);[/color]
print REPORT "1: JOINED!\n";
last CONSIDER if ($#A < $j);
redo CONSIDER;
}
#....
}
The problem is that I get the error 5, my values in @B are those that have been changed in @A, not the native values I wrote into @B specifically so I'd have a static copy to test against.
arg! Am I referencing something somewhere without realizing it?
Any help appreciated. Thanks.