Bio-Polloc

 view release on metacpan or  search on metacpan

lib/Bio/Polloc/Locus/amplicon.pm  view on Meta::CPAN

   return $self->{'_error'};
}

=head2 primersio

Sets the primers based on a L<Bio::Polloc::Polloc::IO> object.

=head3 Arguments

A L<Bio::Polloc::Polloc::IO> object.

=cut

sub primersio {
   my($self, $io) = @_;
   return unless defined $io;
   my $line = $io->_readline;
   unless(defined $line){
      defined $io->file or $self->throw('Empty primers file', $io);
      my $io2 = Bio::Polloc::Polloc::IO->new(-input=>$io->file);
      $line = $io2->_readline;
      $io2->close;
   }else{
      $io->_pushback($line);
   }
   my @p = split /\s+/, $line, 3;
   $self->fwd_primer($p[1]);
   $self->rev_primer($p[2]);
}

=head2 fwd_primer

Gets/sets the FWD primer (I<str>).

=cut

sub fwd_primer {
   my($self, $value) = @_;
   $self->{'_fwd_primer'} = $value if defined $value;
   return $self->{'_fwd_primer'};
}

=head2 rev_primer

Gets/sets the REV primer (I<str>).

=cut

sub rev_primer {
   my($self, $value) = @_;
   $self->{'_rev_primer'} = $value if defined $value;
   return $self->{'_rev_primer'};
}

=head2 score

Gets the score

=head3 Returns

The score (float or undef). As the percentage of the primers
matching the target sequence.

=cut

sub score {
   my($self,$value) = @_;
   $self->warn("Trying to set value via read-only method 'score()'") if defined $value;
   return 100 - 100 * ($self->errors || 0) * (
   		$self->fwd_primer and $self->rev_primer ?
		1/length $self->fwd_primer . $self->rev_primer : 1);
}

=head2 errors

Sets/gets the errors (in number of nucleotides).

=head3 Arguments

The errors (int, optional).

=head3 Returns

The errors (int or undef).

=cut

sub errors {
   my($self, $value) = @_;
   my $k = '_errors';
   $self->{$k} = $value if defined $value;
   return $self->{$k};
}

=head2 distance

Returns the difference in length with the given locus.

=head3 Arguments

=over

=item -locus I<Bio::Polloc::LocusI object>

The locus to compare with.

=item -locusref I<Bio::Polloc::LocusI object>

The reference locus.  If set, replaces the current loaded object.

=back

=head3 Returns

Float, the difference in length.

=head3 Throws

L<Bio::Polloc::Polloc::Error> if no locus or the loci are not of the
proper type.



( run in 0.529 second using v1.01-cache-2.11-cpan-99c4e6809bf )