#!/usr/bin/perl -w use strict; use Data::Dumper; my @set = qw (AAAAAT ATCGAT TTTTTG GCCCCC GTGGGG); my $lim = 0.75; my @sel = remove_poly( \@set, $lim); print "BEFORE:",scalar(@set),"\n"; print "AFTER:",scalar(@sel),"\n"; #print Dumper \@sel; sub remove_poly { my ($array,$lim) = @_; my $len = length $array->[0]; my @sel_array; foreach ( @{$array} ) { my $a_count = $_ =~ tr/A//; my $t_count = $_ =~ tr/T//; my $c_count = $_ =~ tr/C//; my $g_count = $_ =~ tr/G//; my $a_portion = $a_count/$len; my $t_portion = $t_count/$len; my $c_portion = $c_count/$len; my $g_portion = $g_count/$len; #print "$_ $a_portion $t_portion $c_portion $g_portion \n"; if ( $a_portion < $lim && $t_portion < $lim && $c_portion < $lim && $g_portion < $lim ) { push @sel_array,$_; } else { print "$_\n"; next; } } #print Dumper \@sel_array ; return @sel_array; }