Bio::Ontology Relationship
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Toolbar
WebCvsRaw content
Summary
Relationship - a relationship for an ontology
Package variables
No package variables defined.
Included modules
Bio::Ontology::RelationshipI
Bio::Ontology::TermI
Bio::Root::Root
Inherit
Bio::Ontology::RelationshipI Bio::Root::Root
Synopsis
  $rel = Bio::Ontology::Relationship->new( -identifier     => "16847",
-subject_term => $subj,
-object_term => $obj,
-predicate_term => $pred );
Description
This is a basic implementation of Bio::Ontology::RelationshipI.
The terminology we use here is the one commonly used for ontologies,
namely the triple of (subject, predicate, object), which in addition
is scoped in a namespace (ontology). It is called triple because it is
a tuple of three ontology terms.
There are other terminologies in use for expressing relationships. For
those who it helps to better understand the concept, the triple of
(child, relationship type, parent) would be equivalent to the
terminology chosen here, disregarding the question whether the notion
of parent and child is sensible in the context of the relationship
type or not. Especially in the case of ontologies with a wide variety
of predicates the parent/child terminology and similar ones can
quickly become ambiguous (e.g., A synthesises B), meaningless (e.g., A
binds B), or even conflicting (e.g., A is-parent-of B), and are
therefore strongly discouraged.
Methods
_check_class
No description
Code
identifierDescriptionCode
initDescriptionCode
newDescriptionCode
object_termDescriptionCode
ontologyDescriptionCode
predicate_termDescriptionCode
subject_termDescriptionCode
to_stringDescriptionCode
Methods description
identifiercode    nextTop
 Title   : identifier
Usage : $rel->identifier( "100050" );
or
print $rel->identifier();
Function: Set/get for the identifier of this Relationship.
Returns : The identifier [scalar].
Args : The identifier [scalar] (optional).
initcodeprevnextTop
 Title   : init()
Usage : $rel->init();
Function: Initializes this Relationship to all undef.
Returns :
Args :
newcodeprevnextTop
 Title   : new
Usage : $rel = Bio::Ontology::Relationship->new(-identifier => "16847",
-subject_term => $subject,
-object_term => $object,
-predicate_term => $type );
Function: Creates a new Bio::Ontology::Relationship.
Returns : A new Bio::Ontology::Relationship object.
Args : -identifier => the identifier of this relationship [scalar]
-subject_term => the subject term [Bio::Ontology::TermI]
-object_term => the object term [Bio::Ontology::TermI]
-predicate_term => the predicate term [Bio::Ontology::TermI]
object_termcodeprevnextTop
 Title   : object_term
Usage : $rel->object_term( $object );
or
$object = $rel->object_term();
Function: Set/get for the object term of this Relationship.
The common convention for ontologies is to express relationships between terms as triples (subject, predicate, object). Returns : The object term [Bio::Ontology::TermI]. Args : The object term [Bio::Ontology::TermI] (optional).
ontologycodeprevnextTop
 Title   : ontology
Usage : $ont = $obj->ontology()
Function: Get/set the ontology that defined this relationship.
Example :
Returns : an object implementing Bio::Ontology::OntologyI
Args : on set, undef or an object implementing
Bio::Ontology::OntologyI (optional)
predicate_termcodeprevnextTop
 Title   : predicate_term
Usage : $rel->predicate_term( $type );
or
$type = $rel->predicate_term();
Function: Set/get for the predicate (relationship type) of this
relationship.
The common convention for ontologies is to express relationships between terms as triples (subject, predicate, object). Returns : The predicate term [Bio::Ontology::TermI]. Args : The predicate term [Bio::Ontology::TermI] (optional).
subject_termcodeprevnextTop
 Title   : subject_term
Usage : $rel->subject_term( $subject );
or
$subject = $rel->subject_term();
Function: Set/get for the subject term of this Relationship.
The common convention for ontologies is to express relationships between terms as triples (subject, predicate, object). Returns : The subject term [Bio::Ontology::TermI]. Args : The subject term [Bio::Ontology::TermI] (optional).
to_stringcodeprevnextTop
 Title   : to_string()
Usage : print $rel->to_string();
Function: to_string method for Relationship.
Returns : A string representation of this Relationship.
Args :
Methods code
_check_classdescriptionprevnextTop
sub _check_class {
    my ( $self, $value, $expected_class ) = @_;
    
    if ( ! defined( $value ) ) {
        $self->throw( "Found [undef] where [$expected_class] expected" );
    }
    elsif ( ! ref( $value ) ) {
        $self->throw( "Found [scalar] where [$expected_class] expected" );
    } 
    elsif ( ! $value->isa( $expected_class ) ) {
        $self->throw( "Found [" . ref( $value ) . "] where [$expected_class] expected" );
    }    

} # _check_type
#################################################################
# aliases for backwards compatibility
#################################################################
}
identifierdescriptionprevnextTop
sub identifier {
    my ( $self, $value ) = @_;

    if ( defined $value ) {
        $self->{ "_identifier" } = $value;
    }

    return $self->{ "_identifier" };
} # identifier
}
initdescriptionprevnextTop
sub init {
    my( $self ) = @_;
    
    $self->{ "_identifier" }     = undef;
    $self->{ "_subject_term" }   = undef;
    $self->{ "_object_term" }    = undef;
    $self->{ "_predicate_term" } = undef;
    $self->ontology(undef);
   
} # init
}
newdescriptionprevnextTop
sub new {
    my( $class, @args ) = @_;
    
    my $self = $class->SUPER::new( @args );
   
    my ( $identifier,
         $subject_term,
	 $child,        # for backwards compatibility
$object_term, $parent, # for backwards compatibility
$predicate_term, $reltype, # for backwards compatibility
$ont) = $self->_rearrange( [qw( IDENTIFIER SUBJECT_TERM CHILD_TERM OBJECT_TERM PARENT_TERM PREDICATE_TERM RELATIONSHIP_TYPE ONTOLOGY) ], @args ); $self->init(); $self->identifier( $identifier ); $subject_term = $child unless $subject_term; $object_term = $parent unless $object_term; $predicate_term = $reltype unless $predicate_term; $self->subject_term( $subject_term) if $subject_term; $self->object_term( $object_term) if $object_term; $self->predicate_term( $predicate_term ) if $predicate_term; $self->ontology($ont) if $ont; return $self; } # new
}
object_termdescriptionprevnextTop
sub object_term {
    my ( $self, $term ) = @_;
  
    if ( defined $term ) {
        $self->_check_class( $term, "Bio::Ontology::TermI" );
        $self->{ "_object_term" } = $term;
    }

    return $self->{ "_object_term" };
}
ontologydescriptionprevnextTop
sub ontology {
    my $self = shift;
    my $ont;

    if(@_) {
	$ont = shift;
	if($ont) {
	    $ont = Bio::Ontology::Ontology->new(-name => $ont) if ! ref($ont);
	    if(! $ont->isa("Bio::Ontology::OntologyI")) {
		$self->throw(ref($ont)." does not implement ".
			     "Bio::Ontology::OntologyI. Bummer.");
	    }
	} 
	return $self->{"_ontology"} = $ont;
    } 
    return $self->{"_ontology"};
}
predicate_termdescriptionprevnextTop
sub predicate_term {
    my ( $self, $term ) = @_;
  
    if ( defined $term ) {
        $self->_check_class( $term, "Bio::Ontology::TermI" );
        $self->{ "_predicate_term" } = $term;
    }

    return $self->{ "_predicate_term" };
}
subject_termdescriptionprevnextTop
sub subject_term {
    my ( $self, $term ) = @_;
  
    if ( defined $term ) {
        $self->_check_class( $term, "Bio::Ontology::TermI" );
        $self->{ "_subject_term" } = $term;
    }

    return $self->{ "_subject_term" };
    
} # subject_term
}
to_stringdescriptionprevnextTop
sub to_string {
    my( $self ) = @_;
    
    local $^W = 0;

    my $s = "";

    $s .= "-- Identifier:\n";
    $s .= $self->identifier()."\n";
    $s .= "-- Subject Term Identifier:\n";
    $s .= $self->subject_term()->identifier()."\n";
    $s .= "-- Object Term Identifier:\n";
    $s .= $self->object_term()->identifier()."\n";
    $s .= "-- Relationship Type Identifier:\n";
    $s .= $self->predicate_term()->identifier();
    
    return $s;
    
} # to_string
}
General documentation
FEEDBACKTop
Mailing ListsTop
User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to the
Bioperl mailing lists Your participation is much appreciated.
  bioperl-l@bioperl.org                         - General discussion
http://bio.perl.org/MailList.html - About the mailing lists
Reporting BugsTop
report bugs to the Bioperl bug tracking system to help us keep track
the bugs and their resolution. Bug reports can be submitted via
email or the web:
  bioperl-bugs@bio.perl.org
http://bugzilla.bioperl.org/
AUTHORTop
Christian M. Zmasek
Email: czmasek@gnf.org or cmzmasek@yahoo.com
WWW: http://www.genetics.wustl.edu/eddy/people/zmasek/
Address:
  Genomics Institute of the Novartis Research Foundation
10675 John Jay Hopkins Drive
San Diego, CA 92121
CONTRIBUTORSTop
 Hilmar Lapp, email: hlapp at gmx.net
APPENDIXTop
The rest of the documentation details each of the object
methods. Internal methods are usually preceded with a _
Deprecated MethodsTop
  These methods are deprecated and defined here solely to preserve
backwards compatibility.