[MOBY-guts] biomoby commit
Mark Wilkinson
mwilkinson at dev.open-bio.org
Mon Nov 18 02:19:19 UTC 2002
Sun Nov 17 21:19:15 EST 2002
Update of /home/repository/moby/moby-live/Ishmael
In directory dev:/tmp/cvs-serv8424
Modified Files:
IshmaelMain.pm Ishmael_wdr.pl MOBY_Ontology.pm
Log Message:
ontology parsing done. Still not displayed
moby-live/Ishmael IshmaelMain.pm,1.1,1.2 Ishmael_wdr.pl,1.1,1.2 MOBY_Ontology.pm,1.1,1.2
===================================================================
RCS file: /home/repository/moby/moby-live/Ishmael/IshmaelMain.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /tmp/T0LLaWEq 2002-11-17 21:19:15.180007287 -0500
+++ /tmp/T1MLaWEq 2002-11-17 21:19:15.190007933 -0500
@@ -21,6 +21,7 @@
EVT_CHOICE EVT_COMBOBOX EVT_TEXT EVT_TEXT_ENTER EVT_RADIOBOX);
use strict;
use Carp;
+use MOBY_Ontology;
use vars qw($AUTOLOAD @ISA);
@ISA = qw(Wx::Frame);
@@ -34,18 +35,18 @@
my %_attr_data = # DEFAULT ACCESSIBILITY
(
title => ["Call Me Ishmael", 'read/write'],
-
- app => [undef, 'read/write'],
- ObjectTypes => [undef, 'read/write'],
- ServiceTypes => [undef, 'read/write'],
- NamespaceTypes => [undef, 'read/write'],
+
+ app => [undef, 'read/write'],
+ ObjectTypes => [undef, 'read/write'],
+ ServiceTypes => [undef, 'read/write'],
+ NamespaceTypes => [undef, 'read/write'],
FileMenu => [undef, 'read/write'],
EditMenu => [undef, 'read/write'],
ViewMenu => [undef, 'read/write'],
OptionsMenu => [undef, 'read/write'],
ToolsMenu => [undef, 'read/write'],
MainMenuBar => [undef, 'read/write'],
-
+
ObjectOntologyWindow => [undef, 'read/write'],
);
@@ -76,7 +77,7 @@
my( $caller, %args ) = @_;
my $caller_is_obj = ref($caller);
my $class = $caller_is_obj || $caller;
- my( $self ) = $class->SUPER::new( undef, -1, "Call Me Ishmael", [20,20], [500,340] );
+ my( $self ) = $class->SUPER::new( undef, -1, "Call Me Ishmael", [100,100], [500,340] );
Wx::InitAllImageHandlers();
@@ -95,18 +96,18 @@
#$self->CreateStatusBar( 3, 0, -1,"mainStatusBar" );
#$self->SetStatusText( "Welcome!", 0);
- my $SOwin = Wx::Frame->new($self, -1, "Service Ontology", [20,20], [300,100]);
- my $OOwin = Wx::Frame->new($self, -1, "Object Ontology", [20,20], [300,100]);
- my $DVwin = Wx::Frame->new($self, -1, "DataViewer", [20,20], [300,100]);
- my $SO = ServiceOntology($SOwin);
- my $OO = ObjectOntology($OOwin);
+ my $SOwin = Wx::Frame->new($self, -1, "Service Ontology", [10,10], [300,100]);
+ my $OOwin = Wx::Frame->new($self, -1, "Object Ontology", [320,10], [300,100]);
+ my $DVwin = Wx::Frame->new($self, -1, "DataViewer", [640,10], [300,100]);
+ my $SOW = ServiceOntologyWindow($SOwin);
+ my $ServiceOntology = MOBY_Ontology->new(type =>"service");
+ my $OOW = ObjectOntologyWindow($OOwin);
+ my $ObjectOntology = MOBY_Ontology->new(type => "object");
my $DV = DataViewer($DVwin);
$SOwin->Show(1);
$OOwin->Show(1);
$DVwin->Show(1);
-
-
# insert main window here
# WDR: handler declarations for MainWindow
===================================================================
RCS file: /home/repository/moby/moby-live/Ishmael/Ishmael_wdr.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /tmp/T0fNayFq 2002-11-17 21:19:15.270004545 -0500
+++ /tmp/T1gNayFq 2002-11-17 21:19:15.280009600 -0500
@@ -53,7 +53,7 @@
use vars qw($ID_SRV_TREECTRL); $ID_SRV_TREECTRL = 10002;
-sub ServiceOntology {
+sub ServiceOntologyWindow {
my( $item0 ) = Wx::BoxSizer->new( wxVERTICAL );
my( $item1 ) = Wx::TreeCtrl->new( $_[0], $main::ID_TREECTRL, wxDefaultPosition, [300,160], wxTR_HAS_BUTTONS|wxSUNKEN_BORDER );
@@ -78,7 +78,7 @@
use vars qw($ID_OBJ_TREECTRL); $ID_OBJ_TREECTRL = 100020;
-sub ObjectOntology {
+sub ObjectOntologyWindow {
my( $item0 ) = Wx::BoxSizer->new( wxVERTICAL );
my( $item1 ) = Wx::TreeCtrl->new( $_[0], $main::ID_TREECTRL, wxDefaultPosition, [300,160], wxTR_HAS_BUTTONS|wxSUNKEN_BORDER );
===================================================================
RCS file: /home/repository/moby/moby-live/Ishmael/MOBY_Ontology.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /tmp/T0VNaaGq 2002-11-17 21:19:15.310006316 -0500
+++ /tmp/T1WNaaGq 2002-11-17 21:19:15.320009751 -0500
@@ -1,27 +1,51 @@
-package MOBY_Ontology
+package MOBY_Ontology;
+use lib 'C:\BIO\moby-live\Client';
use strict;
use Carp;
use vars qw($AUTOLOAD);
use DBI;
use DBD::mysql;
use Graph::Directed;
+use MOBY::Client::Central;
+
{
#Encapsulated class data
- my $osth = "select oe2.term, oe2.authority, oe2.accession, oe2.description from OntologyEntry as oe, OntologyEntry as oe2, Term2Term as t, Ontology as o where oe.id = t.ontologyentry1_id and oe2.id = t.ontologyentry2_id and oe.term=? and oe.ontology_id=o.id and o.name='MOBY_Object'";
- my $ssth = "select oe2.term, oe2.authority, oe2.accession, oe2.description from OntologyEntry as oe, OntologyEntry as oe2, Term2Term as t, Ontology as o where oe.id = t.ontologyentry1_id and oe2.id = t.ontologyentry2_id and oe.term=? and oe.ontology_id=o.id and o.name='MOBY_Service'";
- my $root = "select term from OntologyEntry where is_root='y' and ontology_id = Ontology.id and Ontology.name = ?"
+ # the following statement handle gets child terms from Object and Service ontologies
+ my $child = "
+ select
+ oe2.term,
+ oe2.authority,
+ oe2.accession,
+ oe2.description,
+ r.type
+
+ from
+
+ OntologyEntry as oe,
+ OntologyEntry as oe2,
+ Term2Term as t,
+ Ontology as o,
+ RelationshipType as r
+ where r.id = t.relationship_type_id and
+ oe.id = t.ontologyentry1_id and
+ oe2.id = t.ontologyentry2_id and
+ oe.term=? and
+ oe.ontology_id=o.id and
+ o.name=?";
+ # this statement gets the root of whatever ontology you are intersted in
+ my $root = "select term from OntologyEntry, Ontology where is_root='y' and ontology_id = Ontology.id and Ontology.name = ?";
#___________________________________________________________
#ATTRIBUTES
my %_attr_data = # DEFAULT ACCESSIBILITY
(
- Object => [undef, 'read/write'],
- obj_sth => [$osth, 'read/write'],
- Service => [undef, 'read/write'],
- serv_sth => [$ssth, 'read/write'],
- root_sth => [$root, 'read/write'],
+ type => [undef, 'read/write'],
+ dbh => [undef, 'read/write'],
+ child_sql => [$child, 'read/write'],
+ root_sql => [$root, 'read/write'],
+ graph => [undef, 'read/write'],
);
@@ -64,22 +88,66 @@
else {
$self->{$attrname} = $self->_default_for($attrname) }
}
+
+ return undef unless $self->type;
+ $self->type("MOBY_Object") if ($self->type =~ /object/i);
+ $self->type("MOBY_Service") if ($self->type =~ /service/i);
+ $self->graph(Graph::Directed->new);
my $dbh = dbAccess();
- my $root = $dbh->prepare($self->root_sth);
-
+ $self->dbh($dbh);
+ my $root_sth = $dbh->prepare($self->root_sql);
+ $root_sth->execute($self->type);
+ my ($root) = $root_sth->fetchrow_array;
+ return "bummer" unless $root; # somethin' has gone terribly wrong!
+ $self->expand($root); # fill in the grapph
+
return $self;
}
+sub expand {
+ my ($self, $root) = @_;
+ my $g = $self->graph;
+ $g->add_vertex($root);
+
+ my @children = $self->addChildren($root, $self->type);
+ do {
+ my @new_children;
+ foreach (@children){
+ push @new_children, $self->addChildren($_);
+ }
+ @children = @new_children;
+ } until (!(scalar @children));
+}
+
+sub addChildren {
+ my ($self, $node) = @_;
+ my @children;
+ my $g = $self->graph;
+
+ my $child_sth = $self->dbh->prepare($self->child_sql);
+ $child_sth->execute($node, $self->type);
+ while (my ($term, $authority, $accession, $description, $relationship) = $child_sth->fetchrow_array){
+ push @children, $term;
+ $g->add_edge($node, $term);
+ $g->set_attribute("relationship", $node, $term, "$relationship");
+ $g->set_attribute("authority", $term, $authority);
+ $g->set_attribute("accession", $term, $accession);
+ $g->set_attribute("description", $term, $description);
+ }
+ return @children;
+}
+
sub dbAccess {
- my ($dsn) = "DBI:mysql:moby_central:mobycentral.cbr.nrc.ca:3306";
+ my ($dsn) = "DBI:mysql:MOBY_Central:mobycentral.cbr.nrc.ca:3306";
my ($user_name) = "moby";
my ($password) = "";
- $dbh = DBI->connect($dsn, $user_name, $password, {RaiseError => 1});
+ my $dbh = DBI->connect($dsn, $user_name, $password, {RaiseError => 1});
return $dbh;
}
+
sub DESTROY {}
sub AUTOLOAD {
More information about the MOBY-guts
mailing list