Skip to content

Commit

Permalink
Update clinvar somatic format
Browse files Browse the repository at this point in the history
  • Loading branch information
dglemos committed Nov 20, 2024
1 parent 9beeb6b commit 4200871
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 84 deletions.
76 changes: 20 additions & 56 deletions modules/Bio/EnsEMBL/VEP/AnnotationSource/Database/Variation.pm
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,6 @@ sub get_features_by_regions_uncached {
$attribs_clinical_impact = $adaptor->get_somatic_clin_impact_by_location($chr_is_seq_region ? $chr : $sr_cache->{$chr}, $s, $e, $source_id);
}

print "\n->attribs_clinical_impact: ", Dumper($attribs_clinical_impact);

my $phenotype_attrib_id = $self->phenotype_attrib_id || 0;

my $sth = $self->var_dbc->prepare(qq{
Expand Down Expand Up @@ -219,7 +217,6 @@ sub get_features_by_regions_uncached {

if($v_clin_impact){
$v_copy{clinical_impact} = _format_clinical_impact($v_clin_impact);
print "---v_clin_impact specific key after format: ", Dumper($v_clin_impact);
}

$v_copy{variation_id} = $var_id;
Expand All @@ -240,73 +237,40 @@ sub get_features_by_regions_uncached {
return \@return;
}

sub _format_clinical_impact {
my $v_clin_impact = shift;
=head2 _format_clinical_impact
my @somatic_clin_sig_list;
my @impact_assertion_list;
my @impact_clin_sig_list;
my @oncogenic_clin_sig_list;
Example : $clinical_impact = _format_clinical_impact($v_clin_impact)
Description: Internal method to format the clinvar somatic classification
Returntype : string
Exceptions : none
Caller : get_features_by_regions_uncached()
Status : Stable
# print "\n(_format_clinical_impact) ", Dumper($v_clin_impact);
=cut

for my $pheno_feat (@{$v_clin_impact}) {
my @tmp;
my $classification;
sub _format_clinical_impact {
my $v_clin_impact = shift;

# If somatic clinical significance already has '(' then the prognostic/diagnostic
# is already attached to it
if($pheno_feat->{final_somatic_clin_sig}) {
return $v_clin_impact;
}
my @somatic_clin_sig_list = ();

for my $pheno_feat (@{$v_clin_impact}) {
# Get the somatic clinical impact
# Example: Tier IV - Benign/Likely benign
if($pheno_feat->{somatic_clin_sig}) {
@somatic_clin_sig_list = split(",", $pheno_feat->{somatic_clin_sig});
}

# The impact assertion is optional
# Example: diagnostic,prognostic
if($pheno_feat->{impact_assertion}) {
@impact_assertion_list = split(",", $pheno_feat->{impact_assertion});
}

# The impact_clin_sig is optional
# Example: supports diagnosis,better outcome
if($pheno_feat->{impact_clin_sig}) {
@impact_clin_sig_list = split(",", $pheno_feat->{impact_clin_sig});
$pheno_feat->{somatic_clin_sig} =~ s/,/;/g;
my $tmp = $pheno_feat->{phenotype} . "(" . $pheno_feat->{somatic_clin_sig} . ")";
push @somatic_clin_sig_list, $tmp;
}

if($pheno_feat->{oncogenic_clin_sig}) {
@oncogenic_clin_sig_list = split(",", $pheno_feat->{oncogenic_clin_sig});
my $tmp = $pheno_feat->{phenotype} . "(oncogenicity:" . $pheno_feat->{oncogenic_clin_sig} . ")";
push @somatic_clin_sig_list, $tmp;
}

for (my $i=0; $i<(scalar @somatic_clin_sig_list); $i++) {
my $somatic_clin_sig = $somatic_clin_sig_list[$i];
if(scalar @impact_assertion_list && scalar @impact_clin_sig_list) {
$somatic_clin_sig .= " (" . $impact_assertion_list[$i] . ":" . $impact_clin_sig_list[$i] . ")";
push @tmp, $somatic_clin_sig;
}
}

if(scalar @tmp) {
$classification = join(",", @tmp);
# $pheno_feat->{somatic_clin_sig} = $classification;
$pheno_feat->{final_somatic_clin_sig} = $pheno_feat->{phenotype}." ".$classification;
}
elsif($pheno_feat->{somatic_clin_sig} && $pheno_feat->{oncogenic_clin_sig}) {
$pheno_feat->{final_somatic_clin_sig} = $pheno_feat->{phenotype}." ".$pheno_feat->{somatic_clin_sig}."(oncogenicity:".$pheno_feat->{oncogenic_clin_sig}.")";
}
elsif($pheno_feat->{somatic_clin_sig}) {
$pheno_feat->{final_somatic_clin_sig} = $pheno_feat->{phenotype}." ".$pheno_feat->{somatic_clin_sig};
}

# print "somatic_clin_sig: ", Dumper($pheno_feat->{somatic_clin_sig});

}

return $v_clin_impact;
my $classification = join(";", @somatic_clin_sig_list);

return $classification;
}

=head2 seq_region_cache
Expand Down
30 changes: 2 additions & 28 deletions modules/Bio/EnsEMBL/VEP/OutputFactory.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1050,35 +1050,9 @@ sub add_colocated_variant_info {
# VEP fetches the variation synonyms from the cache
push @{$hash->{VAR_SYNONYMS}}, $ex->{var_synonyms} if $self->{var_synonyms} && $ex->{var_synonyms} && !$self->{_config}->{_params}->{is_vr};

# print Dumper($ex);

# Find allele specific clin_sig data if it exists
# ClinVar somatic classification
if(defined($ex->{clinical_impact}) && $self->{somatic_classification}) {

print "\n---Output factory: ", Dumper($ex->{clinical_impact});

if(ref($ex->{clinical_impact}) eq "ARRAY") {
my @final_clin_impact;
foreach my $pf (@{$ex->{clinical_impact}}) {
push @final_clin_impact, $pf->{final_somatic_clin_sig} if $pf->{final_somatic_clin_sig};
}
$hash->{SOMATIC_CLASSIFICATION} = join(";", @final_clin_impact);
}
else {
$hash->{SOMATIC_CLASSIFICATION} = $ex->{clinical_impact};
}

print "Somatic classification: ", $hash->{SOMATIC_CLASSIFICATION}, "\n";

# for my $ci (@{$ex->{clinical_impact}}) {
# if(defined $ci->{somatic_clin_sig}) {
# my $somatic_clin_sig = $ci->{somatic_clin_sig};
# if(defined $ci->{oncogenic_clin_sig}) {
# $somatic_clin_sig = $somatic_clin_sig . " (Oncogenicity:" . $ci->{oncogenic_clin_sig} . ")";
# }
# push @final_clin_impact, $somatic_clin_sig;
# }
# }
$hash->{SOMATIC_CLASSIFICATION} = $ex->{clinical_impact};
}

if(defined($ex->{clin_sig_allele}) && $self->{clin_sig_allele} )
Expand Down

0 comments on commit 4200871

Please sign in to comment.