Package intermine :: Module model :: Class Class
[hide private]
[frames] | no frames]

Class Class

source code

object --+
         |
        Class

An abstraction of database tables in the data model

These objects refer to the table objects in the InterMine ORM layer.

SYNOPSIS

>>>  service = Service("http://www.flymine.org/query/service")
>>>  model = service.model
>>>
>>>  if "Gene" in model.classes:
...      gene_cd = model.get_class("Gene")
...      print "Gene has", len(gene_cd.fields), "fields"
...      for field in gene_cd.fields:
...          print " - ", field.name

OVERVIEW

Each class can have attributes (columns) of various types, and can have references to other classes (tables), on either a one-to-one (references) or one-to-many (collections) basis

Classes should not be instantiated by hand, but rather used as part of the model they belong to.

Instance Methods [hide private]
 
__init__(self, name, parents)
This constructor is called when deserialising the model - you should have no need to create Classes by hand
source code
 
__repr__(self)
repr(x)
source code
subclass of intermine.model.Field
get_field(self, name)
The standard way of retrieving a field
source code
boolean
isa(self, other)
This method validates statements about inheritance.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]
list(Field) fields
The fields are returned sorted by name.
list(Attribute) attributes
list(Reference) references
list(Collection) collections

Inherited from object: __class__

Method Details [hide private]

__init__(self, name, parents)
(Constructor)

source code 

Constructor - Creates a new Class descriptor

>>> cd = intermine.model.Class("Gene", ["SequenceFeature"])
<intermine.model.Class: Gene>

This constructor is called when deserialising the model - you should have no need to create Classes by hand

Parameters:
  • name - The name of this class
  • parents - a list of parental names
Overrides: object.__init__

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

get_field(self, name)

source code 

Get a field by name

The standard way of retrieving a field

Returns: subclass of intermine.model.Field
Raises:
  • ModelError - if the Class does not have such a field

isa(self, other)

source code 

Check if self is, or inherits from other

This method validates statements about inheritance. Returns true if the "other" is, or is within the ancestry of, this class

Other can be passed as a name (str), or as the class object itself

Returns: boolean

Property Details [hide private]

fields

The fields of this class

The fields are returned sorted by name. Fields includes all Attributes, References and Collections

Get Method:
unreachable.fields(self) - The fields are returned sorted by name.
Type:
list(Field)

attributes

The fields of this class which contain data

Get Method:
unreachable.attributes(self)
Type:
list(Attribute)

references

fields which reference other objects

Get Method:
unreachable.references(self)
Type:
list(Reference)

collections

fields which reference many other objects

Get Method:
unreachable.collections(self)
Type:
list(Collection)