Bio::Protease::Role::WithCache - A role that adds optional memoization of ProteaseI methods
version 1.112980
package My::Protease; use Moose; with qw(Bio::ProteaseI Bio::Protease::Role::WithCache); sub _cuts { ... } # Done, all ProteaseI methods now support optional caching # through the 'has_cache' and 'cache' attributes 1;
Turn caching on, trading memory for speed. Defaults to 0 (no caching). Useful when any method is being called several times with the same argument.
my $p = Bio::Protease->new( specificity => 'trypsin', use_cache => 0 ); my $c = Bio::Protease->new( specificity => 'trypsin', use_cache => 1 ); my $substrate = 'MAAEELRKVIKPR' x 10; $p->digest( $substrate ) for (1..1000); # time: 5.11s $c->digest( $substrate ) for (1..1000); # time: 0.12s
The cache object, which has to do the Cache::Ref::Role::API role. Uses Cache::Ref::LRU by default with a cache size of 5000, but you can set this to your liking at construction time:
my $p = Bio::Protease->new( use_cache => 1, cache => Cache::Ref::Random->new( size => 50 ), specificity => 'trypsin' );
Bruno Vecchi <vecchi.b gmail.com>
This software is copyright (c) 2011 by Bruno Vecchi.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Bio::Protease, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Bio::Protease
CPAN shell
perl -MCPAN -e shell install Bio::Protease
For more information on module installation, please visit the detailed CPAN module installation guide.