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