[Bioperl-l] Bio::Variation::SeqDiff, Bio::Variation::VariantI
Eckhard Lehmann
ecky@e-lehmann.de
30 May 2002 11:07:03 +0200
Heikki,
I think the best way is to initiate a private (or public?) method
"_set_dnamut()" which sets up the dna_mut in the way described. It can
be called in the current "dna_mut()" method and can be changed
afterwards by someone else.
So I don't need to change too much of the existing methods.
The code at the end of this mail works fine for now.
Eckhard
#------------------------------------------------------------------
sub _set_dnamut {
my $self = shift;
return 0 unless $self->dna_ori && $self->each_Variant;
$self->dna_mut($self->dna_ori);
foreach ($self->each_Variant) {
next unless $_->isMutation;
my ($s, $la, $le);
#lies the mutation lesser than 25 bases after the start of sequence?
if ($_->start < 25) {$s = 0; $la = $_->start;}
else {$s = $_->start - 25; $la = 25;}
#is the mutation an insertion?
$_->end($_->start) unless $_->allele_ori->seq;
#does the mutation end greater than 25 bases before the end of
#sequence?
if (($_->end + 25) > length($self->dna_mut)) {
$le = length($self->dna_mut) - $_->end;
} else {$le = 25;}
$_->dnStreamSeq(substr($self->dna_mut, $s, $la));
$_->upStreamSeq(substr($self->dna_mut, $_->end, $le));
my $s_ori = $_->dnStreamSeq . $_->allele_ori->seq . $_->upStreamSeq;
my $s_mut = $_->dnStreamSeq . $_->allele_mut->seq . $_->upStreamSeq;
(my $str = $self->dna_mut) =~ s/$s_ori/$s_mut/;
$self->dna_mut($str);
}
}