I believe you could easily use grep in your subroutine, as in:
sub remove_poly
{
my ($array,$lim) = @_;
my $len = length $array->[0];
my @sel_array = grep {
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;
$_ if ( $a_portion < $lim && $t_portion < $lim && $c_portion <
+$lim && $g_portion < $lim )
} @$array;
return @sel_array;
}
The initial array being big, you could also return a reference to the resulting set, instead of the whole array.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.