Skip to content
Snippets Groups Projects
Commit 420b66f6 authored by William McLaren's avatar William McLaren
Browse files

Added expanded_length method and changed seq method to use it

parent 9e8910b0
No related branches found
No related tags found
No related merge requests found
......@@ -261,6 +261,7 @@ sub seq {
if($self->adaptor()) {
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
......@@ -270,6 +271,7 @@ sub seq {
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
......@@ -278,18 +280,32 @@ sub seq {
foreach my $vf (@variation_features_ordered){
$vf->apply_edit($reference_sequence); #change, in the reference sequence, the vf
}
#need to find coverage information if different from reference
my $indAdaptor = $self->adaptor->db->get_db_adaptor('variation')->get_IndividualAdaptor;
my $ref_strain = $indAdaptor->get_reference_strain_name;
$self->_add_coverage_information($reference_sequence) if ($with_coverage == 1 && $self->strain_name ne $ref_strain);
return substr(${$reference_sequence},0,1) if ($self->length == 1);
return substr(${$reference_sequence},0,$self->length); #returns the reference sequence, applying the variationFeatures. Remove additional bases added due to indels
return substr(${$reference_sequence},0,$self->expanded_length); #returns the reference sequence, applying the variationFeatures. Remove additional bases added due to indels
}
# no attached sequence, and no db, so just return Ns
return 'N' x $self->length();
}
sub expanded_length() {
my $self = shift;
my $length = $self->SUPER::length();
foreach my $af(@{$self->{'alleleFeatures'}}) {
$length += $af->length_diff() if $af->length_diff > 0;
}
return $length;
}
sub _add_coverage_information{
my $self = shift;
......
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