Skip to content
Snippets Groups Projects
Commit 9fc1080e authored by Daniel Rios's avatar Daniel Rios
Browse files

AlignSlice can print sequences with different length, adding - when no base present

parent 0a312863
No related branches found
No related tags found
No related merge requests found
......@@ -302,7 +302,33 @@ sub get_all_Slices {
undef $ref_strain->{'alleleFeatures'};
push @strains, @{$self->strains};
my $new_feature;
my $indel;
my $aligned_features;
my $indels = (); #reference to a hash containing indels in the different strains
#we need to realign all Features in the different Slices and add '-' in the reference Slice
foreach my $strain (@{$self->strains}){
foreach my $af (@{$strain->get_all_AlleleFeatures_Slice()}){
$new_feature = $self->alignFeature($af); #align feature in AlignSlice coordinates
push @{$aligned_features},$new_feature if($new_feature->seq_region_start <= $strain->end); #some features might map outside slice
if ($af->start != $af->end){ #an indel, need to add to the reference, and realign in the strain
#make a shallow copy of the indel
%{$indel} = %{$new_feature};
bless $indel, ref($new_feature);
$indel->allele_string('-');
push @{$indels},$indel; #and include in the list of potential indels
}
}
undef $strain->{'alleleFeatures'}; #remove all features before adding new aligned features
push @{$strain->{'alleleFeatures'}}, @{$aligned_features};
undef $aligned_features;
}
push @strains, $ref_strain;
#need to add indels in the different strains, if not present
foreach my $strain (@strains){
#inlcude the indels in the StrainSlice object
push @{$strain->{'alignIndels'}},@{$indels};
}
return \@strains;
}
......
......@@ -243,13 +243,20 @@ sub seq {
my $seqAdaptor = $self->adaptor()->db()->get_SequenceAdaptor();
my $reference_sequence = $seqAdaptor->fetch_by_Slice_start_end_strand($self,1,undef,1); #get the reference sequence for that slice
#apply all differences to the reference sequence
#first, in case there are any indels, create the new sequence (containing the '-' bases)
# sort edits in reverse order to remove complication of
# adjusting downstream edits
my @indels_ordered = sort {$b->start() <=> $a->start()} @{$self->{'alignIndels'}} if (defined $self->{'alignIndels'});
foreach my $vf (@indels_ordered){
$vf->apply_edit($reference_sequence); #change, in the reference sequence, the vf
}
#need to find coverage information if diffe
# sort edits in reverse order to remove complication of
# adjusting downstream edits
my @variation_features_ordered = sort {$b->start() <=> $a->start()} @{$self->{'alleleFeatures'}} if (defined $self->{'alleleFeatures'});
foreach my $vf (@variation_features_ordered){
next if ($vf->start != $vf->end); #quick fix to remove indels from sequence
$vf->apply_edit($reference_sequence); #change, in the reference sequence, the vf
}
#need to find coverage information if different from reference
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment