Bruno Vecchi > Bio-Protease > Bio::Protease::Role::WithCache

Download:
Bio-Protease-1.112980.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 1.112980   Source  

NAME ^

Bio::Protease::Role::WithCache - A role that adds optional memoization of ProteaseI methods

VERSION ^

version 1.112980

SYNOPSIS ^

    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;

ATTRIBUTES ^

use_cache

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

cache

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'
    );

AUTHOR ^

Bruno Vecchi <vecchi.b gmail.com>

COPYRIGHT AND LICENSE ^

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.

syntax highlighting: