WEEDLOW: for my $low ( @{ $matchesfasta_id{ $site } } ) { #### last unless @{$matches{$fasta_id}{$site}}; #### WEEDLOW: for my $low ( @{ $matches{ $fasta_id }{ $site } }) { #### for my $site ( sort { $a <=> $b } keys %{ $matches{ $fasta_id } } ) { ## A last unless @{ $matches{ $fasta_id }{ $site } }; WEEDLOW: for my $low ( @{ $matches{ $fasta_id }{ $site } } ) { my $lowerlimit = $low + 0; my $upperlimit = $span + $lowerlimit; for my $sitekey ( sort { $a <=> $b } keys %{ $matches{ $fasta_id } } ) { ## B #### my @sortedKeys = sort { $a <=> $b } keys %{ $matches{ $fasta_id } }; for my $site ( @sortedKeys ) { last unless @{ $matches{ $fasta_id }{ $site } }; WEEDLOW: for my $low ( @{ $matchesfasta_id{ $site } } ) { my $lowerlimit = $low + 0; my $upperlimit = $span + $lowerlimit; for my $sitekey ( @sortedKeys ) { #### for my $hit ( @{ $matches{ $fasta_id }{ $sitekey } } ) { next unless $hit >= $lowerlimit; last unless $hit <= $upperlimit; push @arrayA, $hit + 0; } if( @arrayA ) { @{ $sets{ $fasta_id }[ $setscounter ]{ $sitekey } } = @arrayA; } else { %{ $sets{ $fasta_id }[ $setscounter ] } = (); } #### @{ $sets{ $fasta_id }[ $setscounter ]{ $sitekey } } = grep { $_ >= $lowerlimit and $_ <= $upperlimit } @{ $matches{ $fasta_id }{ $sitekey } } unless( @{ $sets{ $fasta_id }[ $setscounter ]{ $sitekey } } ) { undef $sets{ $fasta_id }[ $setscounter ] }; next WEEDLOW; } #### %{ $sets{ $fasta_id }[ $setscounter ] } = (); #### undef $sets{ $fasta_id }[ $setscounter ] }; #### # @fastarray = (); @fastarray = @newfast; #### push @newfast, $h; #### if( scalar keys %{ $sets{ $fasta_id }[ $setscounter ] } < $num ) { #### for my $checkhash ( keys %{ $sets{ $fasta_id }[ $setscounter ] } ) { unless( defined $sets{ $fasta_id }[ $setscounter ]{ $checkhash }[ 0 ] ) { undef $sets{ $fasta_id }[ $setscounter ] }; last; } } if( scalar keys %{ $sets{ $fasta_id }[ $setscounter ] } < $num ) { undef $sets{ $fasta_id }[ $setscounter ]; } $setscounter++ if scalar %{ $sets{ $fasta_id }[ $setscounter ] }; } } if( @{ $sets{ $fasta_id } } ) { pop @{ $sets{ $fasta_id } } unless scalar %{ $sets{ $fasta_id }[ $#{ $sets{ $fasta_id } } ] }; } #### sub WEED { my( $span, %matches) = @_; my( $site, $fasta, $sitekey) = ''; my( $setscounter, $lowerlimit, $upperlimit, $i, $set, $yes ) = 0; my %sets = (); my @newfast; for my $fasta_id ( @fastheaders ) { $setscounter = 0; next unless defined %{ $matches{ $fasta_id } }; print "Currently analysing results from sequence:\n $fasta_id\n"; for $site ( sort { $a <=> $b } keys %{ $matches{ $fasta_id } } ) { last unless @{ $matches{ $fasta_id }{ $site } }; $i = 0; WEEDLOW: for my $low ( @{ $matches{ $fasta_id }{ $site } } ) { $lowerlimit = $low + 0; $upperlimit = $span + $lowerlimit; for $sitekey ( sort { $a <=> $b } keys %{ $matches{ $fasta_id } } ) { next unless defined @{ $matches{ $fasta_id }{ $sitekey } }; my @arrayA = (); for my $hit ( @{ $matches{ $fasta_id }{ $sitekey } } ) { next unless $hit >= $lowerlimit; last unless $hit <= $upperlimit; my $ggg = $hit + 0; push( @arrayA, $ggg); $ggg = 0; next; } if( @arrayA ) { @{ $sets{ $fasta_id }[ $setscounter ]{ $sitekey } } = @arrayA; @arrayA = (); } else { %{ $sets{ $fasta_id }[ $setscounter ] } = (); next WEEDLOW; } } for my $checkhash ( keys %{ $sets{ $fasta_id }[ $setscounter ] } ) { unless( defined $sets{ $fasta_id }[ $setscounter ]{ $checkhash }[ 0 ] ) { %{ $sets{ $fasta_id }[ $setscounter ] } = (); last; } } if( scalar keys %{ $sets{ $fasta_id }[ $setscounter ] } < $num ) { %{ $sets{ $fasta_id }[ $setscounter ] } = (); } $setscounter++ if scalar %{ $sets{ $fasta_id }[ $setscounter ] }; } } if( @{ $sets{ $fasta_id } } ) { pop @{ $sets{ $fasta_id } } unless scalar %{ $sets{ $fasta_id }[ $#{ $sets{ $fasta_id } } ] }; } if( @{ $sets{ $fasta_id } } ) { push @newfast, $h; } else { delete $sets{ $fasta_id }; } } @fastarray = (); @fastarray = @newfast; return %sets; } #### sub WEED { my( $span, %matches) = @_; my %sets; my @newfast; for my $fasta_id ( @fastheaders ) { my $setscounter = 0; next unless defined %{ $matches{ $fasta_id } }; print "Currently analysing results from sequence:\n $fasta_id\n"; my @sortedKeys = sort { $a <=> $b } keys %{ $matches{ $fasta_id } }; for my $site ( @sortedKeys ) { last unless @{ $matches{ $fasta_id }{ $site } }; WEEDLOW: for my $low ( @{ $matches{ $fasta_id }{ $site } } ) { my $lowerlimit = $low + 0; my $upperlimit = $span + $lowerlimit; for my $sitekey ( @sortedKeys ) { next unless defined @{ $matches{ $fasta_id }{ $sitekey } }; @{ $sets{ $fasta_id }[ $setscounter ]{ $sitekey } } = grep { $_ >= $lowerlimit and $_ <= $upperlimit } @{ $matches{ $fasta_id }{ $sitekey } } unless( @{ $sets{ $fasta_id }[ $setscounter ]{ $sitekey } } ) { undef $sets{ $fasta_id }[ $setscounter ] }; next WEEDLOW; } } for my $checkhash ( keys %{ $sets{ $fasta_id }[ $setscounter ] } ) { unless( defined $sets{ $fasta_id }[ $setscounter ]{ $checkhash }[ 0 ] ) { undef $sets{ $fasta_id }[ $setscounter ] }; last; } } if( scalar keys %{ $sets{ $fasta_id }[ $setscounter ] } < $num ) { undef $sets{ $fasta_id }[ $setscounter ]; } $setscounter++ if scalar %{ $sets{ $fasta_id }[ $setscounter ] }; } } if( @{ $sets{ $fasta_id } } ) { pop @{ $sets{ $fasta_id } } unless scalar %{ $sets{ $fasta_id }[ $#{ $sets{ $fasta_id } } ] }; } if( @{ $sets{ $fasta_id } } ) { push @newfast, $h; } else { delete $sets{ $fasta_id }; } } @fastarray = @newfast; return %sets; }