Bio::SeqEvolution Factory
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Toolbar
WebCvs
Summary
Bio::SeqEvolution::Factory - Factory object to instantiate sequence evolving classes
Package variables
No package variables defined.
Included modules
Bio::Root::Root
Bio::SeqEvolution::EvolutionI
Inherit
Bio::Root::Root Bio::SeqEvolution::EvolutionI
Synopsis
    # not an instantiable class
Description
This is the factory class that can be used to call for a specific
model to mutate a sequence.
Bio::SeqEvolution::DNAPoint is the default for nucleotide sequences
and the only implementation at this point.
Methods
newDescriptionCode
_initialize
No description
Code
_load_format_moduleDescriptionCode
typeDescriptionCode
identityDescriptionCode
pamDescriptionCode
mutation_countDescriptionCode
seqDescriptionCode
seq_typeDescriptionCode
get_mutation_counterDescriptionCode
reset_mutation_counterDescriptionCode
get_sequence_counterDescriptionCode
reset_sequence_counterDescriptionCode
each_seqDescriptionCode
each_mutationDescriptionCode
get_alignment_identity
No description
Code
get_alignmet
No description
Code
_increase_mutation_counterDescriptionCode
_increase_sequence_counterDescriptionCode
Methods description
newcode    nextTop
  Title   : new
Usage : my $obj = Bio::SeqEvolution::Factory->new();
Function: Builds a new Bio:SeqEvolution::EvolutionI object
Returns : Bio:SeqEvolution::EvolutionI object
Args : -type => class name
See Bio:SeqEvolution::EvolutionI
_load_format_modulecodeprevnextTop
 Title   : _load_format_module
Usage : *INTERNAL SeqIO stuff*
Function: Loads up (like use) a module at run time on demand
Example :
Returns :
Args :
typecodeprevnextTop
 Title   : type
Usage : $obj->type($newval)
Function: Set used evolution model. It is set by giving a
valid Bio::SeqEvolution::* class name
Returns : value of type
Args : newvalue (optional)
Defaults to Bio::SeqEvolution::DNAPoint.
identitycodeprevnextTop
 Title   : identity
Usage : $obj->identity($newval)
Function: Set the desired identity between original and mutated sequence
Returns : value of identity
Args : newvalue (optional)
pamcodeprevnextTop
 Title   : pam
Usage : $obj->pam($newval)
Function: Set the wanted Percentage of Accepted Mutations, PAM
Returns : value of PAM
Args : newvalue (optional)
When you are measuring sequence divergence, PAM needs to be
estimated. When you are generating sequences, PAM is simply the count
of mutations introduced to the reference sequence normalised to the
original sequence length.
mutation_countcodeprevnextTop
 Title   : mutation_count
Usage : $obj->mutation_count($newval)
Function: Set the number of wanted mutations to the sequence
Returns : value of mutation_count
Args : newvalue (optional)
seqcodeprevnextTop
 Title   : seq
Usage : $obj->seq($newval)
Function: Set the sequence object for the original sequence
Returns : The sequence object
Args : newvalue (optional)
Setting this will reset mutation and generated mutation counters.
seq_typecodeprevnextTop
 Title   : seq_type
Usage : $obj->seq_type($newval)
Function: Set the returned seq_type to one needed
Returns : value of seq_type
Args : newvalue (optional)
Defaults to Bio::PrimarySeq.
get_mutation_countercodeprevnextTop
 Title   : get_mutation_counter
Usage : $obj->get_mutation_counter()
Function: Get the count of sequences created
Returns : value of counter
Args : -
reset_mutation_countercodeprevnextTop
 Title   : reset_mutation_counter
Usage : $obj->reset_mutation_counter()
Function: Resert the counter of mutations
Returns : value of counter
Args : -
get_sequence_countercodeprevnextTop
 Title   : get_sequence_counter
Usage : $obj->get_sequence_counter()
Function: Get the count of sequences created
Returns : value of counter
Args : -
reset_sequence_countercodeprevnextTop
 Title   : reset_sequence_counter
Usage : $obj->reset_sequence_counter()
Function: Resert the counter of sequences created
Returns : value of counter
Args : -
This is called when ever mutated sequences are reassigned new values
using methods seq() and mutated_seq(). As a side affect, this method
also recreates the intermal alignment that is used to calculate the
sequence identity.
each_seqcodeprevnextTop
 Title   : each_seq
Usage : $obj->each_seq($int)
Function:
Returns : an array of sequences mutated from the reference sequence
according to evolutionary parameters given
Args : -
each_mutationcodeprevnextTop
  Title   : each_mutation
Usage : $obj->each_mutation
Function: return the mutations leading to the last generated
sequence in objects
Returns : an array of Bio::Variation::DNAMutation objects
Args : optional argument to return an array of stringified names
_increase_mutation_countercodeprevnextTop
 Title   : _increase_mutation_counter
Usage : $obj->_increase_mutation_counter()
Function: Internal method to increase the counter of mutations performed
Returns : value of counter
Args : -
_increase_sequence_countercodeprevnextTop
 Title   : _increase_sequence_counter
Usage : $obj->_increase_sequence_counter()
Function: Internal method to increase the counter of sequences created
Returns : value of counter
Args : -
Methods code
newdescriptionprevnextTop
sub new {
    my($caller,@args) = @_;
    my $class = ref($caller) || $caller;

    my %param = @args;
    @param{ map { lc $_ } keys %param } = values %param; # lowercase keys
if ( $class eq 'Bio::SeqEvolution::Factory') { #my %param = @args;
#@param{ map { lc $_ } keys %param } = values %param; # lowercase keys
if (exists $param{'-type'}) { # $self->type($param{'-type'});
} else { $param{'-type'} = 'Bio::SeqEvolution::DNAPoint'; #$self->type('Bio::SeqEvolution::DNAPoint'} unless $seq->alphabet == 'protein'
} my $type = $param{'-type'}; return unless( $class->_load_format_module($param{'-type'}) ); return $type->new(%param); } else { my ($self) = $class->SUPER::new(%param); $self->_initialize(%param); return $self; }
}
_initializedescriptionprevnextTop
sub _initialize {
    my($self, @args) = @_;

    $self->SUPER::_initialize(@args);
    my %param = @args;
    @param{ map { lc $_ } keys %param } = values %param; # lowercase keys
exists $param{'-seq'} && $self->seq($param{'-seq'}); exists $param{'-set_mutated_seq'} && $self->set_mutated_seq($param{'-set_mutated_seq'}); exists $param{'-identity'} && $self->identity($param{'-identity'}); exists $param{'-pam'} && $self->pam($param{'-pam'}); exists $param{'-mutation_count'} && $self->mutation_count($param{'-mutation_count'});
}
_load_format_moduledescriptionprevnextTop
sub _load_format_module {
	my ($self, $format) = @_;
	my $module =  $format;
	my $ok;

	eval {
		$ok = $self->_load_module($module);
	};
	if ( $@ ) {
		print STDERR <<END;
$self: $format cannot be found
Exception $@
END
; } return $ok;
}
typedescriptionprevnextTop
sub type {
   my $self = shift;
   if (@_) {
       $self->{'_type'} = shift @_;
       $self->_load_module($self->{'_type'});
   }
   return $self->{'_type'} || 'Bio::SeqEvolution::DNAPoint';
}
identitydescriptionprevnextTop
sub identity {
   my $self = shift;
   $self->{'_identity'} = shift @_ if @_;
   return $self->{'_identity'};
}
pamdescriptionprevnextTop
sub pam {
   my $self = shift;
   $self->{'_pam'} = shift @_ if @_;
   return $self->{'_pam'};
}
mutation_countdescriptionprevnextTop
sub mutation_count {
   my $self = shift;
   $self->{'_mutation_count'} = shift @_ if @_;
   return $self->{'_mutation_count'};
}
seqdescriptionprevnextTop
sub seq {
   my $self = shift;
   if (@_) {
       $self->{'_seq'} = shift @_ ;
       return $self->{'_seq'};
       $self->reset_mutation_counter;
       $self->reset_sequence_counter;
   }
   return $self->{'_seq'};
}
seq_typedescriptionprevnextTop
sub seq_type {
   my $self = shift;
   if (@_) {
       $self->{'_seq_type'} = shift @_;
       $self->_load_module($self->{'_seq_type'});
   }
   return $self->{'_seq_type'} || 'Bio::PrimarySeq';
}
get_mutation_counterdescriptionprevnextTop
sub get_mutation_counter {
   return shift->{'_mutation_counter'};
}
reset_mutation_counterdescriptionprevnextTop
sub reset_mutation_counter {
   shift->{'_mutation_counter'} = 0;
   return 1;
}
get_sequence_counterdescriptionprevnextTop
sub get_sequence_counter {
   return shift->{'_sequence_counter'};
}
reset_sequence_counterdescriptionprevnextTop
sub reset_sequence_counter {
   my $self = shift;
   $self->{'_sequence_counter'} = 0;
   $self->_init_alignment;
   return 1;
}
each_seqdescriptionprevnextTop
sub each_seq {
   my $self = shift;
   my $number = shift;

   $self->throw("[$number] ". ' should be a positive integer')
       unless $number =~ /^[+\d]+$/;

   my @array;
   for (my $count=1; $count<$number; $count++) {
       push @array, $self->next_seq();

   }
   return @array;
}
each_mutationdescriptionprevnextTop
sub each_mutation {
    my $self = shift;
    my $string = shift;

    return @{$self->{'_mutations'}} if $string;

    return map {
        /(\d+)(\w*)>(\w*)/;
#        print;
my $dnamut = Bio::Variation::DNAMutation->new ('-start' => $1, '-end' => $1, '-length' => 1, '-isMutation' => 1 ); $dnamut->allele_ori( Bio::Variation::Allele->new(-seq => $2, -alphabet => 'dna') ); $dnamut->add_Allele( Bio::Variation::Allele->new(-seq => $3, -alphabet => 'dna') ); $dnamut; } @{$self->{'_mutations'}}
}
get_alignment_identitydescriptionprevnextTop
sub get_alignment_identity {
    my $self = shift;
    return $self->{'_align'}->overall_percentage_identity;
}
get_alignmetdescriptionprevnextTop
sub get_alignmet {
   my $self = shift;
   return $self->{'_align'}->remove_gaps('-', 'all-gaps');
}
_increase_mutation_counterdescriptionprevnextTop
sub _increase_mutation_counter {
   return shift->{'_mutation_counter'}++;
}
_increase_sequence_counterdescriptionprevnextTop
sub _increase_sequence_counter {
   return shift->{'_sequence_counter'}++;
}


1;
}
General documentation
FEEDBACKTop
Mailing ListsTop
User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to
the Bioperl mailing list. Your participation is much appreciated.
  bioperl-l@bioperl.org                  - General discussion
http://bioperl.org/wiki/Mailing_lists - About the mailing lists
Support Top
Please direct usage questions or support issues to the mailing list:
bioperl-l@bioperl.org
rather than to the module maintainer directly. Many experienced and
reponsive experts will be able look at the problem and quickly
address it. Please include a thorough description of the problem
with code and data examples if at all possible.
Reporting BugsTop
Report bugs to the Bioperl bug tracking system to help us keep track
of the bugs and their resolution. Bug reports can be submitted via the
web:
  https://redmine.open-bio.org/projects/bioperl/
AUTHORTop
  Heikki Lehvaslaiho <heikki at bioperl dot org>
CONTRIBUTORSTop
Additional contributor's names and emails here
APPENDIXTop
The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _
mutation countersTop
The next three methods set a value to limit the number of mutations
introduced the the input sequence.
Internal methodsTop