monkfan has asked for the wisdom of the Perl Monks concerning the following question:
#!/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 < $li +m && $g_portion < $lim ) { push @sel_array,$_; } else { print "$_\n"; next; } } #print Dumper \@sel_array ; return @sel_array; }
Rate limbic ewi fang roy auk1 brs_auk2 jdhed limbic 4029/s -- -58% -64% -67% -76% -77% -85% ewi 9693/s 141% -- -14% -21% -42% -45% -64% fang 11261/s 180% 16% -- -8% -32% -37% -58% roy 12211/s 203% 26% 8% -- -27% -31% -55% auk1 16620/s 313% 71% 48% 36% -- -6% -38% brs_auk2 17743/s 340% 83% 58% 45% 7% -- -34% jdhed 27022/s 571% 179% 140% 121% 63% 52% --
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Removing Poly-ATCG from and Array of Strings
by jdhedden (Deacon) on Jun 09, 2005 at 12:59 UTC | |
by Limbic~Region (Chancellor) on Jun 09, 2005 at 19:30 UTC | |
|
Re: Removing Poly-ATCG from and Array of Strings
by Roy Johnson (Monsignor) on Jun 09, 2005 at 13:24 UTC | |
|
Re: Removing Poly-ATCG from and Array of Strings
by aukjan (Friar) on Jun 09, 2005 at 12:32 UTC | |
by aukjan (Friar) on Jun 09, 2005 at 12:59 UTC | |
|
Re: Removing Poly-ATCG from and Array of Strings
by Fang (Pilgrim) on Jun 09, 2005 at 12:34 UTC | |
|
Re: Removing Poly-ATCG from and Array of Strings
by Limbic~Region (Chancellor) on Jun 09, 2005 at 12:38 UTC | |
|
Re: Removing Poly-ATCG from and Array of Strings
by mrborisguy (Hermit) on Jun 09, 2005 at 12:42 UTC |