Created
June 17, 2016 11:21
-
-
Save guillermomarco/be0751f77b798d37ded14e5a884e4ff0 to your computer and use it in GitHub Desktop.
Var_phenotype.pm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=head1 LICENSE | |
This software is distributed under a modified Apache license. | |
=head1 CONTACT | |
Guillermo Marco | |
=cut | |
=head1 NAME | |
=head1 SYNOPSIS | |
=head1 DESCRIPTION | |
=cut | |
package Var_phenotype; | |
use strict; | |
use warnings; | |
use Data::Dumper; | |
use Bio::EnsEMBL::Variation::Utils::BaseVepPlugin; | |
use base qw(Bio::EnsEMBL::Variation::Utils::BaseVepPlugin); | |
sub new { | |
my $class = shift; | |
my $self = $class->SUPER::new(@_); | |
$self->{config}->{check_existing} = 1; | |
return $self; | |
} | |
sub version { | |
return '1.0'; | |
} | |
sub feature_types { | |
return ['Feature']; | |
} | |
sub get_header_info { | |
return { | |
Phenotype_association => "Phentoype asociation description", | |
ClinVar_ID => "ClinVar ID", | |
ClinVar_Sig_Level => "ClinVar significance level", | |
ClinVar_Clinical_Sig => "ClinVar clinical significance" | |
}; | |
} | |
sub parse_description{ | |
my $string = shift; | |
$string =~ s/^\s+|\s+$//g; | |
$string =~ s/,/%25/g; | |
$string =~ s/ /%20/g; | |
$string =~ s/;/%27/g; | |
$string =~ s/\|/%21/g; | |
$string =~ s/&/%26/g; | |
$string =~ s/@/%22/g; | |
$string =~ s/_+/_/g; | |
$string =~ s/[^a-zA-Z0-9_%-]//g; | |
return $string; | |
} | |
sub run { | |
$Data::Dumper::Maxdepth = 3; | |
## Def vars | |
my %res; | |
my @phenotype_descriptions = (); | |
my @clinvar_ids = (); | |
my @clinvar_is_significant = (); | |
my @clinvar_clinical_sig = (); | |
my ($self, $tva) = @_; | |
## Def Handlers | |
my $vf = $tva->variation_feature; | |
my $pfa = $self->{config}->{reg}->get_adaptor('human','variation','phenotypefeature'); | |
my $omim_counter = 0; | |
my $clinvar_counter = 0; | |
foreach my $known_var(@{$vf->{existing} || []}) { | |
foreach my $pf(@{$pfa->fetch_all_by_object_id($known_var->{variation_name})}){ | |
@phenotype_descriptions = (); | |
if ($pf->source_name =~ /clinvar/i && defined $pf->risk_allele){ | |
if ($pf->risk_allele eq $tva->variation_feature_seq){ | |
push(@clinvar_ids, $pf->external_id) if (defined($pf->external_id)); | |
push(@clinvar_is_significant, $pf->is_significant) if (defined($pf->is_significant)); | |
push(@clinvar_clinical_sig, parse_description($pf->clinical_significance)) if (defined($pf->clinical_significance)); | |
} | |
} | |
elsif ($pf->source_name =~ /omim/i){ | |
if($pf->phenotype->description !~ @phenotype_descriptions){ | |
#Todo: atm Ensembl has no MIM ID for variant-phenotype association | |
#Todo: when they implement it we should distinguish between OMIM and Clinvar descrptions and IDs | |
push(@phenotype_descriptions, parse_description($pf->phenotype->description)) | |
} | |
} | |
} | |
} | |
$res{"Phenotype_association"} = join('&', @phenotype_descriptions); | |
$res{"ClinVar_ID"} = join('&', @clinvar_ids); | |
$res{"ClinVar_Sig_Level"} = join('&', @clinvar_is_significant); | |
$res{"ClinVar_Clinical_Sig"} = join('&', @clinvar_clinical_sig); | |
return { %res }; | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment