The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Bio::Polloc::TypingI - Generic typing interface

DESCRIPTION

Use this interface to initialize the Bio::Polloc::Typing::* objects. Any rule inherits from this Interface. Usually, rules are initialized from files (via the Bio::Polloc::TypingIO package).

AUTHOR - Luis M. Rodriguez-R

Email lrr at cpan dot org

IMPLEMENTS OR EXTENDS

APPENDIX

Methods provided by the package

new

Attempts to initialize a Bio::Polloc::Typing::* object

Arguments

-type str

The typing method. For further description of the different type, see:

  Li, W., Raoult, D., & Fournier, P.-E. (2009).
  Bacterial strain typing in the genomic era.
  FEMS Microbiology Reviews, 33(5), 892-916.

http://www.mendeley.com/research/bacterial-strain-typing-in-the-genomic-era/.

One of:

bandingPattern

"DNA banding pattern-based methods which classify bacteria according to the size of fragments generated by amplification and/or enzymatic digestion of genomic DNA" (Li et al 2009)

bandingPattern::amplification

Same of bandingPattern, but specifying fragments generated by amplification.

bandingPattern::restriction

Same of bandingPattern, but specifying fragments generated by enzymatic digestion.

sequencing

"DNA sequencing-based methods, which study the polymorphism of DNA sequences" (Li et al 2009)

hybridization

"DNA hybridization-based methods using nucleotidic probes" (Li et al 2009)

-locigroup Bio::Polloc::LociGroup object

Group of loci (Bio::Polloc::LociGroup) to be use for typing.

Returns

The Bio::Polloc::Typing::* object

Throws

Bio::Polloc::Polloc::Error if unable to initialize the proper object

type

Gets/sets the type of typing method

Arguments

Value (str). See new and the corresponding Bio::Polloc::Typing::* objects for further details.

Some variations can be introduced, like case variations or short versions like banding or seq.

Return

Value (str). The typing method, or undef if undefined. The value returned is undef or a string from the above list, regardless of the input variations.

Throws

Bio::Polloc::Polloc::Error if an unsupported type is received.

locigroup

Sets/gets the group of loci to be used.

Arguments

A Bio::Polloc::LociGroup object (optional).

Returns

A Bio::Polloc::LociGroup object or undef.

matrix

Generates a matrix of values for the given group of loci.

Arguments

-locigroup Bio::Polloc::LociGroup object

The group of loci to be used as base. If not provided, attempts to find the last value returned by scan. If never called (or not cached by the implementation) looks for the base loci (setted via locigroup or at initialization). If everything fails to provide a base group of loci, warns about it and returns undef.

-binary bool (int)

If true, returns a binary matrix (presence/absence) instead of the native typing value.

-names bool (int)

If true, returns a hash with the names of the genomes as keys instead of an array.

Returns

A reference to an array or a hash (if -names is true). The key correspond to the incremental number or the name of the genomes, and the values can be either numeric or an array of numeric values, depending on the typing_value implemented by the genotyping method. If -binary is true, the values are always 0 or 1, regardless of the typing method.

binary

Alias of matrix with -binary true.

graph

Returns a GD::Simple object containing the graphic representation of the typing results.

Arguments

-locigroup Bio::Polloc::LociGroup

The group to be used as a basis. If any, attempts to locate the last value returned by scan. If never called, looks for the value stored via locigroup or at initialization. Otherwise, warns about it and returns undef,

-width int

Width of the image in pixels. 600 by default.

-height int

Height of the image in pixels. 300 by default.

-font str

Font of the text in the image (if any). 'Times' by default, but certain images require a TrueType Font in order to work properly. This argument is optional, but we strongly reccomend to provide the path to Lucida Sans Regular, or any other similar TrueType Font.

Returns

A GD::Simple object.

Synopsis

    # ...
    $typing->scan($lociGroup);
    my $graph = $typing->graph(-font=>'/path/to/LucidaSansRegular.ttf');
    if($graph){
       open IMG, ">", "graph.png" or die "I can not open graph.png: $!\n";
       binmode IMG;
       print IMG $graph->png;
       close IMG;
    }

METHODS TO BE IMPLEMENTED

Methods that should be implemented by objects using this interface as base. All the methods in this section can throw Bio::Polloc::Polloc::NotImplementedException if not implemented.

scan

Scans the genomes using the specified loci as base.

Arguments

-locigroup Bio::Polloc::LociGroup

Loci to use as genotyping base. Optional if provided via locigroup or at initialization.

Returns

A Bio::Polloc::LociGroup object containing the actual loci employed for typing.

cluster

Clusters the genomes based on the provided loci.

Arguments

-locigroup Bio::Polloc::LociGroup object

The base group of loci. Same behavior as matrix.

Returns

A Bio::Tree object.

typing_value

Provides a value for the passed loci associated with the typing method.

Arguments

-loci Array of Bio::Polloc::LocusI

The loci to be evaluated. Note that it is a reference array of Bio::Polloc::LocusI objects, and NOT a Bio::Polloc::LociGroup. This is because all the loci are expected to be part of the same genome, and the same group (if grouped). This argument is mandatory.

Returns

A numeric value or a reference to an array of numeric values, depending on the genotyping method.

INTERNAL METHODS

Methods intended to be used only witin the scope of Bio::Polloc::*

_qualify_type

_scan_locigroup

Gets/sets the group of loci after scanning. This should be called at the end of all the implementations of scan.

_initialize