Package biana :: Package BianaObjects :: Module Ontology' :: Class Ontology
[hide private]
[frames] | no frames]

Class Ontology

source code


Class to represent a general ontology

The Ontology is an external entity itself. Each of its elemens is also an ExternalEntityObject

Each ontology as a "linkedAttribute", which is the primary attribute to represent the ontology (for example, taxID for taxonomy), and a "descriptionAttribute", which is an attribute that describes the external entity element

Instance Methods [hide private]
 
__init__(self, source_database, name, linkedAttribute, descriptionAttribute, id=None, levelAttribute=None)
"source_database" is the source database id where this entity is described
source code
 
_recursive_tree_print(self, id, outmethod, depth=0)
Prints recursively in stdout a tree representing the ontology, using the external entity id.
source code
 
_recursive_tree_xml(self, id) source code
 
_set_external_entities_dict(self, externalEntitiesDict)
Sets the external entity objects corresponding to the elements of the ontology
source code
 
_traverse_tree_for_leafs(self, id)
Helper function to reach leafs traversing the tree
source code
 
add_element(self, ontologyElementID, isA=[], isPartOf=[], linkedAttributeValue=None)
Adds an element to the ontology.
source code
 
get_all_external_entity_ids(self)
Returns a list with the external entity ids of all the elements in the ontology
source code
 
get_all_linked_attributes(self)
Returns a list with the main attribute for all the elements in the ontology
source code
 
get_descendants(self, ontologyElementID)
Gets all the descendants, using the "is_a" relation
source code
 
get_leafs(self)
Returns a list of leafs in the ontology tree To execute this method, is necessary to load in the ontology all the external Entity Objects
source code
 
get_linked_attr_and_description_tuples(self)
Returns a list of tuples with the format: (linked_attr, descriptive_attr)
source code
 
get_parents_ids(self, elementID)
Returns a list with the parents of the element with this externalEntityID (using the relation is_a)
source code
 
get_part_parents_ids(self, elementID)
Returns a list with the parents of the element with this externalEntityID (using the relation is_part_of)
source code
 
get_xml(self)
Returns a String with an XML representation of the ontology
source code
 
has_element(self, linkedAttributeID)
Returns a boolean indicating if an external entity with this attribute is found in the ontology
source code
 
linkedAttrID2ID(self, attr_id) source code
 
print_tree(self, outmethod=<bound method _DevNull.write of <epydoc.docintrospecter._DevNu...)
Prints recursively in stdout a tree representing the ontology, using the external entity id.
source code

Inherited from ExternalEntity'.ExternalEntity: __eq__, __str__, add_attribute, get_attribute, get_attributes_dict, get_id, get_source_database, get_type, set_id

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__

Static Methods [hide private]

Inherited from ExternalEntity'.ExternalEntity: get_valid_external_entity_types, isValidType

Class Variables [hide private]

Inherited from ExternalEntity'.ExternalEntity: PROMISCUOUS_EXTERNAL_ENTITY_TYPES_DICT

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, source_database, name, linkedAttribute, descriptionAttribute, id=None, levelAttribute=None)
(Constructor)

source code 

"source_database" is the source database id where this entity is described

"name" is the name for the ontology. It must be UNIQUE! There cannot be different ontologies with the same name

"linkedAttribute" is the attribute_identifier for the primary attribute of the ontology (for example, taxID for taxonomy ontology)

"descriptionAttribute" is the attribute_identifier for representing a human readable description of the element. This attribute is used when showing the ontolgy to users

"id" is the UNIQUE identifier in the database for this external entity (as the ontology is an External Entity)

Overrides: object.__init__

_recursive_tree_print(self, id, outmethod, depth=0)

source code 

Prints recursively in stdout a tree representing the ontology, using the external entity id.

Only for testing purposes

_set_external_entities_dict(self, externalEntitiesDict)

source code 

Sets the external entity objects corresponding to the elements of the ontology

"externalEntitiesDict": Dictionary with all the external entities. Key: externalEntityID. Value: externalEntity Object

Objects are only required for printing the ontology

add_element(self, ontologyElementID, isA=[], isPartOf=[], linkedAttributeValue=None)

source code 

Adds an element to the ontology.

"ontologyElementID": externalEntityID that identifies the externalEntityObject belonging to the ontology

"isA": list with the externalEntityIDs of the parents of this element

"isPartOf": list with the externalEntityIDs of the elements to which this element is part of

"linkedAttributeValue" is the value of the main attribute of the added external entity. Not mandatory.

get_xml(self)

source code 

Returns a String with an XML representation of the ontology

To execute this method, is necessary to load in the ontology all the external Entity Objects

print_tree(self, outmethod=<bound method _DevNull.write of <epydoc.docintrospecter._DevNu...)

source code 

Prints recursively in stdout a tree representing the ontology, using the external entity id.

Only for testing purposes