Skip to content
Snippets Groups Projects
Commit cb4537c1 authored by Bronwen Aken's avatar Bronwen Aken
Browse files

Bugfix? Previous revision of this script assumed that we could have only one...

Bugfix? Previous revision of this script assumed that we could have only one ensembl_id (gene) associated with an OTTG. This is not true as projected genes have the same OTTG attached to them as theier parent gene on the primary assembly.
parent 95c3a80a
No related branches found
No related tags found
No related merge requests found
...@@ -66,10 +66,13 @@ $sth->execute; ...@@ -66,10 +66,13 @@ $sth->execute;
$sth->bind_columns(\$gene_id, \$vega_stable_id); $sth->bind_columns(\$gene_id, \$vega_stable_id);
while ($sth->fetch){ while ($sth->fetch){
$vega_to_ens_id{$vega_stable_id} = $gene_id; # sometimes we will see more than one gene associated with an OTTG
# this happens when an OTTG on the primary assemby has been projected to a patch
$vega_to_ens_id{$vega_stable_id}{$gene_id} = $gene_id;
} }
$sth->finish; $sth->finish;
print "\nFetched ".(scalar(keys %vega_to_ens_id))." vega_stable_ids\n";
my $vega_dba = Bio::EnsEMBL::DBSQL::DBAdaptor->new(-host => $vhost||'ens-staging1', my $vega_dba = Bio::EnsEMBL::DBSQL::DBAdaptor->new(-host => $vhost||'ens-staging1',
-user => $vuser||'ensro', -user => $vuser||'ensro',
...@@ -101,23 +104,26 @@ $sth->bind_columns(\$alt_id, \$vega_stable_id); ...@@ -101,23 +104,26 @@ $sth->bind_columns(\$alt_id, \$vega_stable_id);
my %no_gene_id; my %no_gene_id;
my $cnt_vega_rows = 0;
while($sth->fetch()){ while($sth->fetch()){
my $gene_id = $vega_to_ens_id{$vega_stable_id}; $cnt_vega_rows++;
if ( defined($gene_id) ) { if (exists $vega_to_ens_id{$vega_stable_id} ) {
foreach my $gene_id ( keys %{$vega_to_ens_id{$vega_stable_id}} ) {
push @{$alt_alleles{$alt_id}}, $gene_id ; push @{$alt_alleles{$alt_id}}, $gene_id ;
}
} else { } else {
push @{$no_gene_id{$alt_id}}, $vega_stable_id; push @{$no_gene_id{$alt_id}}, $vega_stable_id;
print STDERR "no ensembl gene_id found for vega stable id $vega_stable_id in core\n"; print STDERR "no ensembl gene_id found for vega stable id $vega_stable_id in core\n";
} }
} }
$sth->finish; $sth->finish;
print STDERR "Fetched $cnt_vega_rows rows from the vega db alt_allele table\n";
# #
# Delete the old data # Delete the old data
# #
print STDERR "\n\nDeleting all alt_alleles...\n\n";
my $sth = $core_dba->dbc->prepare("delete from alt_allele"); my $sth = $core_dba->dbc->prepare("delete from alt_allele");
$sth->execute; $sth->execute;
...@@ -126,6 +132,7 @@ $sth->execute; ...@@ -126,6 +132,7 @@ $sth->execute;
# Store alt_alleles. # Store alt_alleles.
# #
print STDERR "Storing new alt alleles...\n\n";
my $alt_allele_count=0; my $alt_allele_count=0;
my $gene_count = 0; my $gene_count = 0;
...@@ -143,4 +150,4 @@ foreach my $key (keys %alt_alleles){ ...@@ -143,4 +150,4 @@ foreach my $key (keys %alt_alleles){
$gene_count += scalar(@genes) if ($alt_allele_id); $gene_count += scalar(@genes) if ($alt_allele_id);
} }
print "Added $alt_allele_count alt_allele ids for $gene_count genes\n"; print "Added $alt_allele_count alt_allele ids for $gene_count genes\nDONE\n";
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