Skip to content
Snippets Groups Projects
Commit c24cee23 authored by Emmanuel Mongin's avatar Emmanuel Mongin
Browse files

Added a script to load a chosen display id for each gene and transcript

parent d0fb6390
No related branches found
No related tags found
No related merge requests found
#Contact: Emmanuel Mongin (mongin@ebi.ac.uk)
use strict;
use DBI;
use Getopt::Long;
use Bio::EnsEMBL::DBSQL::DBAdaptor;
use Bio::EnsEMBL::DBSQL::DBEntryAdaptor;
use Bio::EnsEMBL::DBEntry;
use Bio::SeqIO;
#use MultiTestDB;
BEGIN {
my $script_dir = $0;
$script_dir =~ s/(\S+\/)\S+/$1/;
unshift (@INC, $script_dir);
require "mapping_conf.pl";
}
my %conf = %::mapping_conf; # configuration options
# global vars
my $dbname = $conf{'db'};
my $host = $conf{'host'};
my $user = $conf{'dbuser'};
my $pass = $conf{'password'};
my $organism = $conf{'organism'};
my %priority;
$priority{'HUGO'} = 1000;
$priority{'MarkerSymbol'} = 1000;
$priority{'SWISSPROT'} = 900;
$priority{'SPTREMBL'} = 800;
$priority{'RefSeq'} = 600;
if (!defined $organism) {
die "\nSome basic options have not been set up, have a look at mapping_conf\nCurrent set up (required options):\norganism: $organism\n\n";
}
print STDERR "Connecting to the database...\n";
#my $multi = MultiTestDB->new();
my $db = Bio::EnsEMBL::DBSQL::DBAdaptor->new(
-user => $user,
-dbname => $dbname,
-host => $host,
-pass => $pass,
-driver => 'mysql',
);
#my $db = $multi->get_DBAdaptor( 'core' );
my $transadaptor = $db->get_TranscriptAdaptor();
my $geneadaptor = $db->get_GeneAdaptor();
my $xrefadaptor = $db->get_DBEntryAdaptor();
my $query = "select transcript_id from transcript";
my $sth = $db->prepare($query);
$sth->execute();
while(my $id = $sth->fetchrow) {
my $trans = $transadaptor->fetch_by_dbID($id);
my $xrefs = $trans->get_all_DBLinks;
my $display;
my $current = 0;
foreach my $xref(@$xrefs) {
if ($priority{$xref->database} > $current) {
$display = $xref->dbID;
}
}
$trans->display_xref($display);
$transadaptor->update($trans);
#print STDERR "ID: $id\tDISPLAY: $display\tTEST: ".$transadaptor->get_display_xref_id($id)."\n";
}
my $query1 = "select gene_id from gene";
my $sth1 = $db->prepare($query1);
$sth1->execute();
while(my $gene_id = $sth1->fetchrow) {
my $gene = $geneadaptor->fetch_by_dbID($gene_id);
my $transcripts = $gene->get_all_Transcripts();
my $display;
my $current;
foreach my $trans(@$transcripts) {
my $id = $trans->dbID();
my $xrefid = $transadaptor->get_display_xref_id($id);
eval {
my $xref = $xrefadaptor->fetch_by_dbID($xrefid);
if ($priority{$xref->database} > $current) {
$display = $xref->dbID;
}
};
}
$gene->display_xref($display);
$geneadaptor->update($gene);
# print STDERR "GENE_ID: $gene_id\tDISPLAY: $display\tTEST: ".$geneadaptor->get_display_xref_id($gene_id)."\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