example of using the Ensembl perl API to see the effect of a SNP on predicted transciption factor binding affinity

 


#!/usr/bin/perl
use strict;
use warnings;
use Bio::EnsEMBL::Registry;

use Bio::EnsEMBL::ApiVersion;
printf(STDERR "The API version used is %s\n", software_version() );

my $registry = 'Bio::EnsEMBL::Registry';
$registry->load_registry_from_db(
-host => 'ensembldb.ensembl.org',
-user => 'anonymous',
);

my $slice_adaptor = $registry -> get_adaptor('Human', 'Core', 'Slice');
my $regfeat_adaptor = $registry -> get_adaptor('Human', 'funcgen', 'regulatoryfeature');

my $slice = $slice_adaptor -> fetch_by_region('chromosome', 1, 1241196, 1241246);
my @reg_feats = @{ $regfeat_adaptor -> fetch_all_by_Slice( $slice ) };

print "motif\toriginal_score\tsnp_score\n";

foreach my $reg_feat ( @reg_feats ){
my @motif_feats = @{ $reg_feat -> regulatory_attributes( 'motif' ) };

foreach my $mf(@motif_feats){

my $seq = $mf->feature_Slice->seq;
my $binding_matrix = $mf->binding_matrix;

my @line;
push(@line, $mf->display_label);
push(@line, $binding_matrix->relative_affinity($seq));

my $new_seq = $seq;
$new_seq =~ s/TTTGC/TTTTC/;
push(@line, $binding_matrix->relative_affinity($new_seq));

print join("\t", @line) . "\n";

}
}