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; }