Bio::SeqEvolution
Factory
Summary
Bio::SeqEvolution::Factory - Factory object to instantiate sequence evolving classes
Package variables
No package variables defined.
Included modules
Inherit
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
Methods description
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 |
Title : _load_format_module Usage : *INTERNAL SeqIO stuff* Function: Loads up (like use) a module at run time on demand Example : Returns : Args : |
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. |
Title : identity Usage : $obj->identity($newval) Function: Set the desired identity between original and mutated sequence Returns : value of identity Args : newvalue (optional) |
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 lenght. |
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) |
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. |
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. |
Title : get_mutation_counter Usage : $obj->get_mutation_counter() Function: Get the count of sequences created Returns : value of counter Args : - |
Title : reset_mutation_counter Usage : $obj->reset_mutation_counter() Function: Resert the counter of mutations Returns : value of counter Args : - |
Title : get_sequence_counter Usage : $obj->get_sequence_counter() Function: Get the count of sequences created Returns : value of counter Args : - |
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. |
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 : - |
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 |
Title : _increase_mutation_counter Usage : $obj->_increase_mutation_counter() Function: Internal method to increase the counter of mutations performed Returns : value of counter Args : - |
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
sub new
{ my($caller,@args) = @_;
my $class = ref($caller) || $caller;
my %param = @args;
@param{ map { lc $_ } keys %param } = values %param;
if ( $class eq 'Bio::SeqEvolution::Factory') {
if (exists $param{'-type'}) {
} else {
$param{'-type'} = 'Bio::SeqEvolution::DNAPoint';
}
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;
}} |
sub _initialize
{ my($self, @args) = @_;
$self->SUPER::_initialize(@args);
my %param = @args;
@param{ map { lc $_ } keys %param } = values %param;
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'});} |
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;} |
sub type
{ my $self = shift;
if (@_) {
$self->{'_type'} = shift @_;
$self->_load_module($self->{'_type'});
}
return $self->{'_type'} || 'Bio::SeqEvolution::DNAPoint';} |
sub identity
{ my $self = shift;
$self->{'_identity'} = shift @_ if @_;
return $self->{'_identity'};} |
sub pam
{ my $self = shift;
$self->{'_pam'} = shift @_ if @_;
return $self->{'_pam'};} |
sub mutation_count
{ my $self = shift;
$self->{'_mutation_count'} = shift @_ if @_;
return $self->{'_mutation_count'};} |
sub seq
{ my $self = shift;
if (@_) {
$self->{'_seq'} = shift @_ ;
return $self->{'_seq'};
$self->reset_mutation_counter;
$self->reset_sequence_counter;
}
return $self->{'_seq'};} |
sub seq_type
{ my $self = shift;
if (@_) {
$self->{'_seq_type'} = shift @_;
$self->_load_module($self->{'_seq_type'});
}
return $self->{'_seq_type'} || 'Bio::PrimarySeq';} |
sub get_mutation_counter
{ return shift->{'_mutation_counter'};} |
sub reset_mutation_counter
{ shift->{'_mutation_counter'} = 0;
return 1;} |
sub get_sequence_counter
{ return shift->{'_sequence_counter'};} |
sub reset_sequence_counter
{ my $self = shift;
$self->{'_sequence_counter'} = 0;
$self->_init_alignment;
return 1;} |
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;} |
sub each_mutation
{ my $self = shift;
my $string = shift;
return @{$self->{'_mutations'}} if $string;
return map {
/(\d+)(\w*)>(\w*)/;
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'}}} |
sub get_alignment_identity
{ my $self = shift;
return $self->{'_align'}->overall_percentage_identity;} |
sub get_alignmet
{ my $self = shift;
return $self->{'_align'}->remove_gaps('-', 'all-gaps');} |
sub _increase_mutation_counter
{ return shift->{'_mutation_counter'}++;} |
sub _increase_sequence_counter
{ return shift->{'_sequence_counter'}++;
}
1;} |
General documentation
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
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.
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:
http://bugzilla.open-bio.org/
Heikki Lehvaslaiho <heikki at bioperl dot org>
Additional contributor's names and emails here
The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _
The next three methods set a value to limit the number of mutations
introduced the the input sequence.