From: elserj Date: Tue, 27 Mar 2018 22:02:10 +0000 (+0000) Subject: Fix broken synonyms inserts X-Git-Url: http://gitweb.planteome.org/?a=commitdiff_plain;h=4c84234b003270589a4eb8094a0d8f861895854f;p=old-jaiswallab-svn%2F.git Fix broken synonyms inserts svn path=/; revision=656 --- diff --git a/interactome_scripts/load_species_db.pl b/interactome_scripts/load_species_db.pl index bdfce67..014f2c4 100755 --- a/interactome_scripts/load_species_db.pl +++ b/interactome_scripts/load_species_db.pl @@ -79,7 +79,8 @@ foreach my $file (@files) { $dbh->do("CREATE TABLE if NOT EXISTS $safe_syn_table( `gene_id` VARCHAR( 255 ) NOT NULL , `species` VARCHAR( 255 ) NOT NULL , - `synonyms` TEXT + `synonyms` TEXT , + UNIQUE KEY `gene_species_idx` (`gene_id`, `species`) ) TYPE = MYISAM"); # and the statement handler to do the inserts @@ -103,6 +104,10 @@ foreach my $file (@files) { if(defined($gene)) { $seq_hash{$gene}->{'sequence'} = $seq; $seq_hash{$gene}->{'gene_header'} = $gene_header; + if($defined($synonyms)) { + $seq_hash{$gene}->{'synonyms'} = $synonyms; + undef $synonyms; + } } $gene_header = $line; $gene_header =~ s/^>//; @@ -118,12 +123,15 @@ foreach my $file (@files) { # add the last gene to the hash $seq_hash{$gene}->{'sequence'} = $seq; $seq_hash{$gene}->{'gene_header'} = $gene_header; + if(defined($synonyms)) { + $seq_hash{$gene}->{'synonyms'} = $synonyms; + } foreach my $key (keys %seq_hash) { $insert_sth->execute($key,$seq_hash{$key}->{'gene_header'},$seq_hash{$key}->{'sequence'}); - if($synonyms ne "null") { - $insert_syn_sth->execute($key,$species,$synonyms); + if($seq_hash{$key}->{'synonyms'} ne "null") { + $insert_syn_sth->execute($key,$species,$seq_hash{$key}->{'synonyms'}); } } }