[MOBY-guts] biomoby commit
Mark Wilkinson
mwilkinson at pub.open-bio.org
Fri Aug 26 20:30:41 UTC 2005
mwilkinson
Fri Aug 26 16:30:41 EDT 2005
Update of /home/repository/moby/moby-live/Database
In directory pub.open-bio.org:/tmp/cvs-serv7780
Modified Files:
Update_DB_085_to_086.pl
Log Message:
tweak of database migration script
moby-live/Database Update_DB_085_to_086.pl,1.1,1.2
===================================================================
RCS file: /home/repository/moby/moby-live/Database/Update_DB_085_to_086.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Database/Update_DB_085_to_086.pl 2005/08/07 10:01:39 1.1
+++ /home/repository/moby/moby-live/Database/Update_DB_085_to_086.pl 2005/08/26 20:30:41 1.2
@@ -107,7 +107,7 @@
$dbh->do("update object set is_primitive='1' where object_id='$id'");
}
-my @deprecated_ids; # will hold a list of the database ids of all deprecated types
+my %deprecated_to_new; # will hold a map of all deprecated ids to all new ids;
my $sth_primitives = $dbh->prepare("select object_id, object_type from object where is_primitive = '1'");
$sth_primitives->execute();
@@ -117,7 +117,6 @@
$sth2_inherits_from_primitive->execute($primitive_id);
while (my ($O1id) = $sth2_inherits_from_primitive->fetchrow_array){
next unless ($O1id);
- push @deprecated_ids, $O1id;
my $sth3_inherited_object_details = $dbh->prepare("select object_type, object_lsid, description, authority, contact_email from object where object_id=?");
$sth3_inherited_object_details->execute($O1id);
my ($type, $lsid, $description, $authority, $contact_email) = $sth3_inherited_object_details->fetchrow_array();
@@ -144,6 +143,7 @@
next;
}
my $new_object_id = $dbh->{'mysql_insertid'};
+ $deprecated_to_new{$O1id} = $new_object_id; # map the old id to the new id
my $sth_insertnew_relationships = $dbh->prepare("insert into object_term2term(relationship_type, object1_id, object2_id, object2_articlename) values (?,?,?,?)");
$sth_insertnew_relationships->execute($isa, $new_object_id, $OBJECT_ID, ""); # insert isa Object
$sth_insertnew_relationships->execute($hasa, $new_object_id, $primitive_id, $type); #insert hasa String(plain_text) ...for example
@@ -154,20 +154,49 @@
my $sth_insertnew = $dbh->prepare("insert into object (object_type, object_lsid, description, authority, contact_email, is_primitive) values (?,?,?,?,?,?)");
$sth_insertnew->execute("ISO_DateTime", "urn:lsid:biomoby.org:objectclass:ISO_DateTime", "A Date/Time in ISO 8601 format", "biomoby.org", 'markw at illuminae.com', "1");
-print "\n\nAll updates were apparently successful!\n\n";
-foreach (@deprecated_ids){
- my $sth_downstream_from_deprecated = $dbh->prepare("select object1_id from object_term2term where object2_id = ?");
+foreach (keys(%deprecated_to_new)){
+ my $new_id = $deprecated_to_new{$_};
+ my $sth_downstream_from_deprecated = $dbh->prepare("select assertion_id, object1_id from object_term2term where relationship_type='urn:lsid:biomoby.org:objectrelation:isa' and object2_id = ?");
$sth_downstream_from_deprecated->execute($_);
- my ($O1id) = $sth_downstream_from_deprecated->fetchrow_array;
+ my ($relationship_id, $O1id) = $sth_downstream_from_deprecated->fetchrow_array;
next unless ($O1id);
my $sth3_inherited_object_details = $dbh->prepare("select object_type, object_lsid, description, authority, contact_email from object where object_id=?");
$sth3_inherited_object_details->execute($O1id);
my ($type, $lsid, $description, $authority, $contact_email) = $sth3_inherited_object_details->fetchrow_array();
next unless ($type);
open OUT, ">>UPDATE_ERROR_LOG";
- print OUT "Object $type and its children are now broken\n";
+ print OUT "Object $type and its children are now broken through ISA linkage\n";
close OUT;
print " Object $type in your ontology is now broken as it inherits from a deprecated object!\n";
+
+ $sth_downstream_from_deprecated = $dbh->prepare("select assertion_id, object1_id from object_term2term where relationship_type='urn:lsid:biomoby.org:objectrelation:hasa' and object2_id = ?");
+ $sth_downstream_from_deprecated->execute($_);
+ ($relationship_id, $O1id) = $sth_downstream_from_deprecated->fetchrow_array;
+ next unless ($O1id);
+ $sth3_inherited_object_details = $dbh->prepare("select object_type, object_lsid, description, authority, contact_email from object where object_id=?");
+ $sth3_inherited_object_details->execute($O1id);
+ ($type, $lsid, $description, $authority, $contact_email) = $sth3_inherited_object_details->fetchrow_array();
+ next unless ($type);
+ open OUT, ">>UPDATE_ERROR_LOG";
+ print OUT "Object $type and its children are now broken through HASA linkage\n";
+ close OUT;
+ print " Object $type in your ontology is now broken as it contains (HASA) a deprecated object!\n";
+
+ $sth_downstream_from_deprecated = $dbh->prepare("select assertion_id, object1_id from object_term2term where relationship_type='urn:lsid:biomoby.org:objectrelation:has' and object2_id = ?");
+ $sth_downstream_from_deprecated->execute($_);
+ ($relationship_id, $O1id) = $sth_downstream_from_deprecated->fetchrow_array;
+ next unless ($O1id);
+ $sth3_inherited_object_details = $dbh->prepare("select object_type, object_lsid, description, authority, contact_email from object where object_id=?");
+ $sth3_inherited_object_details->execute($O1id);
+ ($type, $lsid, $description, $authority, $contact_email) = $sth3_inherited_object_details->fetchrow_array();
+ next unless ($type);
+ open OUT, ">>UPDATE_ERROR_LOG";
+ print OUT "Object $type and its children are now broken through HAS linkage\n";
+ close OUT;
+ print " Object $type in your ontology is now broken as it contains (HAS) a deprecated object!\n";
+
}
-print "\n\nAny error messages have been written to the file UPDATE_ERROR_LOG\n\nDone!\n\n";
\ No newline at end of file
+print "\n\nDone!\n\n";
+print "\n\nNOTE: A list of all broken object types resulting from this transformation have been written to the file UPDATE_ERROR_LOG in this script's folder\nYou will need to re-create these objects with the correct inheritence.\n\n";
+
More information about the MOBY-guts
mailing list