From 3d760cff156c94628b7734f16c4442dce9e116fa Mon Sep 17 00:00:00 2001 From: Magali Ruffier <mr6@ebi.ac.uk> Date: Fri, 17 Aug 2012 15:56:36 +0000 Subject: [PATCH] if there is no previous database, no mapping needed --- misc-scripts/update_mapping_set.pl | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/misc-scripts/update_mapping_set.pl b/misc-scripts/update_mapping_set.pl index 1b4a747577..4b9e41dd84 100644 --- a/misc-scripts/update_mapping_set.pl +++ b/misc-scripts/update_mapping_set.pl @@ -151,17 +151,30 @@ foreach my $h ($host,$host2) { my $schema_build; foreach my $db_name (@{$dbs}){ print STDERR "Going to update mapping for $db_name->[0]....\n"; + my $mapping_set_id = 1; + my $sth_seq_mapping = $dbh->prepare("INSERT INTO $db_name->[0].seq_region_mapping VALUES(?,?,?)"); + my $sth_mapping_set = $dbh->prepare("INSERT INTO $db_name->[0].mapping_set VALUES(?,?)"); + $schema_build = get_schema_and_build($db_name->[0]); + my $current_assembly = get_assembly($dbh, $db_name->[0]) ; my $previous_dbname = &get_previous_dbname($old_dbh,$db_name->[0],$release); + +# If there is no previous database, no mapping needed + if (!defined($previous_dbname)) { + $sth_mapping_set->execute($mapping_set_id, $schema_build) unless $dry_run; + next; + } my $old_assembly = get_assembly($old_dbh, $previous_dbname); - if ($old_assembly ne $current_assembly) { next; } - my $mapping_set_id; + +# If it is a new assembly, no mapping needed + if ($old_assembly ne $current_assembly) { + $sth_mapping_set->execute($mapping_set_id, $schema_build) unless $dry_run; + next; + } + my $current_seq_region = (); # hash containing the relation seq_region_name->seq_region_id for the current database my $old_seq_region = (); #hash containing the previous database relation seq_region_name->seq_region_id - my $sth_seq_mapping = $dbh->prepare("INSERT INTO $db_name->[0].seq_region_mapping VALUES(?,?,?)"); - my $sth_mapping_set = $dbh->prepare("INSERT INTO $db_name->[0].mapping_set VALUES(?,?)"); $status = &mapping_status($dbh,$old_dbh, $db_name->[0],\$mapping_set_id,$release); - $schema_build = get_schema_and_build($db_name->[0]); ## prune newly added mapping_set entries # $dbh->do(qq(delete from $db_name->[0].mapping_set where schema_build = '$schema_build')); -- GitLab