Commit 91221674 authored by Sebastien Moretti's avatar Sebastien Moretti
Browse files

Use more references to deal with hash going from fct to fct

parent ca37db96
......@@ -1052,8 +1052,8 @@ sub runExonerate{
close $FASTA;
my %best_pos;
my %best_boj;
my $best_pos;
my $best_boj;
my @bestAln;
RUN_EXONERATE:
for(my $b=0; $b<=$#gis; $b++){
......@@ -1088,25 +1088,23 @@ sub runExonerate{
my ($posiTions, $posBOJ) = Exonerate::parser("$cache/$date.$order.exon", $debug);
%best_pos = testPositions($posiTions, $gis[$b], %best_pos);
%best_boj = testBOJ($posBOJ, $gis[$b], %best_boj);
$best_pos = testPositions($posiTions, $gis[$b], $best_pos);
$best_boj = testBOJ($posBOJ, $gis[$b], $best_boj);
my $whichGI = $gis[$b];
$whichGI = 'gi|'.$whichGI.'|' if ( $whichGI =~ /^\d+$/ );
print {*STDERR} "\tNo exon-intron structure found for $whichGI with $fasta_header\n" if ( %$posBOJ eq 0 );
print "\tNo exon-intron structure found for $whichGI with $fasta_header\n" if ( %$posBOJ eq 0 );
}
#Remove temp files from exonerate and query sequence for exonerate
unlink("$cache/$date.$order.fas", "$cache/$date.$order.exon");# if ($tmp == 0);
my $refBestPOS = \%best_pos; #Use perl references to send two variables (mem address for the 2 hashes) instead of 2 hashes,
my $refBestBOJ = \%best_boj; #and easily, and properly, get them in the main script !
return($refBestPOS, $refBestBOJ);
return($best_pos, $best_boj);
}
sub testPositions{
my ($posiTions, $currentTarget, %best_pos) = @_;
my ($posiTions, $currentTarget, $best_pos) = @_;
my %positions = %$posiTions;
if ( %positions ne 0 ){
......@@ -1116,25 +1114,25 @@ sub testPositions{
print {*STDERR} "$_\t$positions{$_}\n" if ( $debug && $_>0 );
}
my @cles = sort({$a <=> $b} keys(%best_pos));
my @cles = sort({$a <=> $b} keys(%$best_pos));
if ( !exists($cles[0]) ){
return(%positions);
return(\%positions);
}
else{
return(%positions) if ( exists($cles[0]) && $#cles < $#clefs );
return(%best_pos) if ( exists($cles[0]) && $#cles >= $#clefs );
return(\%positions) if ( exists($cles[0]) && $#cles < $#clefs );
return($best_pos) if ( exists($cles[0]) && $#cles >= $#clefs );
}
}
elsif ( %best_pos ne 0 ){
return(%best_pos);
elsif ( %$best_pos ne 0 ){
return($best_pos);
}
else{
return(%positions);
return(\%positions);
}
}
sub testBOJ{
my ($posBOJ, $currentTarget, %bestBOJ) = @_;
my ($posBOJ, $currentTarget, $bestBOJ) = @_;
my %positBOJ = %$posBOJ;
if (%positBOJ ne 0){
......@@ -1144,20 +1142,20 @@ sub testBOJ{
print {*STDERR} "pos:$x -> $y\n" if ( $x>0 );
}
my @cles = sort({$a <=> $b} keys(%bestBOJ));
my @cles = sort({$a <=> $b} keys(%$bestBOJ));
if ( !exists($cles[0]) ){
return(%positBOJ);
return(\%positBOJ);
}
else{
return(%positBOJ) if ( exists($cles[0]) && $#cles < $#clefs );
return(%bestBOJ) if ( exists($cles[0]) && $#cles >= $#clefs );
return(\%positBOJ) if ( exists($cles[0]) && $#cles < $#clefs );
return($bestBOJ) if ( exists($cles[0]) && $#cles >= $#clefs );
}
}
elsif ( %bestBOJ ne 0 ){
return(%bestBOJ);
elsif ( %$bestBOJ ne 0 ){
return($bestBOJ);
}
else {
return(%positBOJ);
return(\%positBOJ);
}
}
########################################################
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment