From: kirovs <ki...@us...> - 2007-09-14 18:10:42
|
Update of /cvsroot/cogs/ensupdate In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv16156 Added Files: generate_keywords.pl Log Message: generate mysql table for searching ensembl --- NEW FILE: generate_keywords.pl --- #!/stf/sys/bin/perl use BMS::ensembl::talk; use strict; my %uh; my $host=$ENV{ENS_HOST}; my $port=$ENV{ENS_PORT}; my $drv=$ENV{ENS_DRV}; my $user=$ENV{ENS_ADMIN}; my $pass=$ENV{ENS_ADMINPASS}; my $ens=new BMS::ensembl::talk(DRV=>$drv,HOST=>$host,ADD=>$port,PASS=>$pass,USER=>$user)||die; my @tables=$ens->marttables('xref'); my $dbh=$ens->get_mart; foreach my $table (@tables) { next if ($table=~/concat/); my $sth=$dbh->prepare("select gene_stable_id,transcript_stable_id,translation_stable_id,display_id_list,dbprimary_id from $table")||die; $sth->execute||die; my $all=$sth->fetchall_arrayref; $sth->finish; foreach my $row (@$all) { my ($gid,$tid,$pid,$list,$ppid)=@$row; $list=~s/[,:]/|/g if ($list); my $com; if ($list) { $com=$ppid?"$ppid|$list|":"$list|"; } else { $com="$ppid|"; } next if ($com eq '|'); if ($gid) { unless (exists($uh{$gid})) {$uh{$gid}='|'; } $uh{$gid} .= $com; next; } if ($tid) { unless (exists($uh{$tid})) {$uh{$tid}='|'; } $uh{$tid} .= $com; next; } if ($pid) { unless (exists($uh{$pid})) {$uh{$pid}='|'; } $uh{$pid} .= $com; next; } } } $dbh->disconnect; my $dbh=$ens->{ENSdbh1}; my $sth=$dbh->prepare("update stable_org set keywords=? where stable_id=?")||die; foreach my $key (keys %uh) { $sth->execute($uh{$key},$key); } $sth->finish; $dbh->disconnect; |