NAME

CCO::Core::Relationship - A relationship between two terms or two relationships within an ontology.

SYNOPSIS

use CCO::Core::Relationship; use CCO::Core::Term; use strict;

# three new relationships my $r1 = CCO::Core::Relationship->new(); my $r2 = CCO::Core::Relationship->new(); my $r3 = CCO::Core::Relationship->new();

$r1->id("CCO:P0000001_is_a_CCO:P0000002"); $r2->id("CCO:P0000002_part_of_CCO:P0000003"); $r3->id("CCO:P0000001_has_child_CCO:P0000003");

$r1->type("is_a"); $r2->type("part_of"); $r3->type("has_child");

!$r1->equals($r2); !$r2->equals($r3); !$r3->equals($r1);

# three new terms my $n1 = CCO::Core::Term->new(); my $n2 = CCO::Core::Term->new(); my $n3 = CCO::Core::Term->new();

$n1->id("CCO:P0000001"); $n2->id("CCO:P0000002"); $n3->id("CCO:P0000003");

$n1->name("One"); $n2->name("Two"); $n3->name("Three");

# r1(n1, n2) $r1->head($n2); $r1->tail($n1);

# r2(n2, n3) $r2->head($n3); $r2->tail($n2);

# r3(n1, n3) $r3->head($n3); $r3->tail($n1);

# three new relationships my $r4 = CCO::Core::Relationship->new(); my $r5 = CCO::Core::Relationship->new(); my $r6 = CCO::Core::Relationship->new();

$r4->id("CCO:R0000004"); $r5->id("CCO:R0000005"); $r6->id("CCO:R0000006");

$r4->type("r4"); $r5->type("r5"); $r6->type("r6");

$r4->link($n1, $n2); $r5->link($n2, $n3); $r6->link($n1, $n3);

DESCRIPTION

A Relationship between two terms (CCO::Core::Term) in the ontology (CCO::Core::Ontology).

A relationships must have a unique ID (e.g. "CCO:P0000028_is_a_CCO:P0000005"), a type (e.g. "is_a") and it must known the linking terms (tail and head).

AUTHOR

Erick Antezana, <erant@psb.ugent.be>

COPYRIGHT AND LICENSE

Copyright (C) 2006, 2007 by erant

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.7 or, at your option, any later version of Perl 5 you may have available.

id

Usage    - print $relationship->id() or $relationship->id($id)
Returns  - the relationship ID (string)
Args     - the relationship ID (string)
Function - gets/sets an ID

type

Usage    - $relationship->type("is_a") or print $relationship->type()
Returns  - the type of the relationship (string)
Args     - the type of the relationship (string)
Function - gets/sets the type of the relationship

equals

Usage    - print $relationship->equals($another_relationship)
Returns  - either 1 (true) or 0 (false)
Args     - the relationship (CCO::Core::Relationship) to compare with
Function - tells whether this relationship is equal to the parameter
Usage    - $relationship->head($object) or $relationship->head()
Returns  - the CCO::Core::Term (object or target) or CCO::Core::RelationshipType (object or target) targeted by this relationship
Args     - the target term (CCO::Core::Term) or the target relationship type (CCO::Core::RelationshipType)
Function - gets/sets the term/relationship type attached to the head of the relationship

tail

Usage    - $relationship->tail($subject) or $relationship->tail()
Returns  - the CCO::Core::Term (subject or source) or CCO::Core::RelationshipType (object or target) sourced by this relationship
Args     - the source term (CCO::Core::Term) or the source relationship type (CCO::Core::RelationshipType)
Function - gets/sets the term/relationship type attached to the tail of the relationship
Usage    - $relationship->link($tail, $head) or $relationship->link()
Returns  - the two Terms or two RelationshipTypes (subject and source) connected by this relationship
Args     - the source(tail, CCO::Core::Term/CCO::Core::RelationshipType) and target(head, CCO::Core::Term/CCO::Core::RelationshipType) term/relationship type
Function - gets/sets the terms/relationship type attached to this relationship