Bioperl: relative-majority consensus, fast code sought
Matthew Pocock
mrp@sanger.ac.uk
Tue, 30 Mar 1999 12:44:03 +0100
I doubt that it will be faster as perl has to do extra work to remove the
letters matched, find memory to put the new string in, and free the old string.
Also, I think that tr/// has some gotcha's when the pattern is a variable
string. In general, avoid making perl alocate/re-alocate memory. That means
don't modify things unless you want the modified result.
Also, remember that by default Perl doesn't return memory to the system untill
it exits. It can be internaly re-used by perl for new objects/primatives, but
is not available to other processes.
Matthew
Gustavo Glusman wrote:
> Shouldn't this be faster?
>
> $_ = $string;
> foreach $letter (qw/A T C G/) { $count{$letter} = tr/$letter//; }
>
> The idea being that the string studied gets shorter every time. Added bonus
> is being left with the non-ACGT letters in $_ at the end.
>
> ____________________________________________________________
> Gustavo Glusman Founder/administrator of BioMOO
> Gustavo@bioinfo.weizmann.ac.il (public PGP key available)
> http://bioinfo.weizmann.ac.il/Gustavo
> Visit BioMOO, the biologists' virtual meeting place, at
> ___________ http://bioinfo.weizmann.ac.il/BioMOO ___________
>
> =========== Bioperl Project Mailing List Message Footer =======
> Project URL: http://bio.perl.org/
> For info about how to (un)subscribe, where messages are archived, etc:
> http://www.techfak.uni-bielefeld.de/bcd/Perl/Bio/vsns-bcd-perl.html
> ====================================================================
=========== Bioperl Project Mailing List Message Footer =======
Project URL: http://bio.perl.org/
For info about how to (un)subscribe, where messages are archived, etc:
http://www.techfak.uni-bielefeld.de/bcd/Perl/Bio/vsns-bcd-perl.html
====================================================================