Skip to content

Commit

Permalink
Merge branch 'postreleasefix/110'
Browse files Browse the repository at this point in the history
  • Loading branch information
nuno-agostinho committed Apr 19, 2023
2 parents 290f78d + 2b183d6 commit fb90395
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 3 deletions.
45 changes: 42 additions & 3 deletions modules/Bio/EnsEMBL/Variation/DBSQL/VariationFeatureAdaptor.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2368,12 +2368,48 @@ sub get_reference{

my $tr_mapper = $transcript->get_TranscriptMapper();

# If the codon overlaps an exon-intron boundary @coords can return two coordinates:
# one for the first exon where the codon starts
# a second coordinate for the exon where the codon ends
my @coords = defined($pos2) ? $tr_mapper->pep2genomic($pos, $pos2) : $tr_mapper->pep2genomic($pos, $pos);

my $start = $coords[0]->start();
my $end = $coords[0]->end();
my $start;
my $end;
my $real_start;
my $real_end;
my $strand = $coords[0]->strand();

# Assign start and end when we have two coordinates
# This is the most common alternative
if(scalar(@coords) == 2){
if(($coords[0]->end() - $coords[0]->start() + 1) % 2 == 0) {
if($strand == 1) {
$start = $coords[0]->start();
$end = $start + 2;
$real_end = $coords[1]->end();
}
else {
$end = $coords[0]->end();
$start = $end - 2;
$real_start = $coords[1]->start();
}
}
elsif($strand == 1) {
$end = $coords[1]->end();
$start = $end - 2;
$real_start = $coords[0]->start();
}
else {
$start = $coords[0]->start();
$end = $start + 2;
$real_end = $coords[1]->end();
}
}
else{
$start = $coords[0]->start();
$end = $coords[0]->end();
}

my $seq_length = $type_del == 1 ? ($end-$start) + 1 : 3;

## find reference sequence
Expand All @@ -2390,8 +2426,11 @@ sub get_reference{

my $from_codon_ref = $from_slice->seq();

$start = $real_start ? $real_start : $start;
$end = $real_end ? $real_end : $end;

## correct for strand
reverse_comp(\$from_codon_ref) if $strand <0;
reverse_comp(\$from_codon_ref) if $strand <0;

return ($from_codon_ref, $start, $end, $strand);
}
Expand Down
8 changes: 8 additions & 0 deletions modules/t/variationFeatureAdaptor.t
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ ok($vfs16a->[0]->variation_name() eq $vf_somatic_name, "somatic vf with phenotyp
# test fetching VF with empty consequence type column
is($vfa->fetch_by_dbID(997738282)->display_consequence, 'sequence_variant', 'empty consequence column');

ok(scalar @{$vfa->fetch_all_by_location_identifier('18:40228819:A_G')} == 1, "fetch_all_by_location_identifier '18:40228819:A_G'");

# test fetch Iterator
print "\n# Test - fetch_Iterator\n";
Expand Down Expand Up @@ -445,6 +446,13 @@ ok($vfa->fetch_by_hgvs_notation($hgvs_str)->allele_string eq 'C/T', 'HGVSp notat
ok($vfa->fetch_by_hgvs_notation('ENST00000470094:c.55_111del')->end eq 32954180, 'HGVSc multi-exon deletion');
ok($vfa->fetch_by_hgvs_notation('NM_000484:c.196_*3del')->end eq 27542743, 'HGVSc multi-exon *deletion');

# test HGVS protein when codon is within two exons
# forward strand
ok($vfa->fetch_by_hgvs_notation('ENSP00000422007.1:p.Gly469Glu')->start eq 66325646, 'HGVSp multi-exon (forward)');
# reverse strand
ok($vfa->fetch_by_hgvs_notation('ENSP00000293261:p.Arg232Met')->start eq 48846578, 'HGVSp multi-exon (reverse)');


print "\n# Test - fetch_by_spdi_notation\n";
my $spdi_str = 'NC_000013.10:32954017::';
throws_ok {$vfa->fetch_by_spdi_notation($spdi_str); } qr/Could not parse the SPDI notation $spdi_str/, 'Throw on invalid SPDI notation.';
Expand Down

0 comments on commit fb90395

Please sign in to comment.