entity_management.base

Base simulation entities

Inheritance diagram of entity_management.base

Functions

attributes([attr_dict, repr])

decorator to simplify creation of classes that have args and kwargs

custom_getattr(obj, name)

Overload of __getattribute__ to trigger instantiation of Nexus object if the attribute is NotInstantiated

Classes

BlankNode()

Blank node.

BrainLocation(*, brainRegion)

Brain location.

Derivation(*, entity)

Derivation.

Frozen()

Utility class making derived classed immutable.

Identifiable()

Represents collapsed/lazy loaded entity having type and id.

OntologyTerm(*, url[, label])

Ontology term such as brain region or species

QuantitativeValue(*, value[, unitText, unitCode])

External resource representations, this can be a file or a folder on gpfs

Subject(*[, species, strain])

Subject.

Unconstrained(*, json)

Shapeless data.

class entity_management.base.BlankNode

Bases: Frozen

Blank node.

class entity_management.base.BrainLocation(*, brainRegion)

Bases: BlankNode

Brain location.

Parameters:

brainRegion (OntologyTerm) – Brain region ontology term.

class entity_management.base.Derivation(*, entity)

Bases: BlankNode

Derivation.

class entity_management.base.Frozen

Bases: object

Utility class making derived classed immutable. Use evolve method to introduce changes.

evolve(**changes)

Create new instance of the frozen(immutable) object with changes applied.

Parameters:

changes – Keyword changes in the new copy, should be a subset of class constructor(__init__) keyword arguments.

Returns:

New instance of the same class with changes applied.

class entity_management.base.Identifiable

Bases: Frozen

Represents collapsed/lazy loaded entity having type and id. Access to any attributes will load the actual entity from nexus and forward property requests to that entity.

as_json_ld(include_rev=False)

Get json-ld representation of the Entity Return json with added json-ld properties such as @context and @type

clone(**changes)

Create new instance of the frozen(immutable) object with changes applied.

Note: A clone is stripped of its id if present.

Parameters:

changes – Keyword changes in the new copy, should be a subset of class constructor(__init__) keyword arguments.

Returns:

New instance of the same class with changes applied.

deprecate(sync_index=False, use_auth=None)

Mark entity as deprecated. Deprecated entities are not possible to retrieve by name.

Parameters:

use_auth (str) – OAuth token in case access is restricted. Token should be in the format for the authorization header: Bearer VALUE.

evolve(**changes)

Create new instance of the frozen(immutable) object with changes applied.

Parameters:

changes – Keyword changes in the new copy, should be a subset of class constructor(__init__) keyword arguments.

Returns:

New instance of the same class with changes applied.

classmethod from_id(resource_id, *, on_no_result=None, cross_bucket=False, resolve_context=False, base=None, org=None, proj=None, use_auth=None, **kwargs)

Load entity from resource id.

Parameters:
  • resource_id (str) – id of the entity to load.

  • on_no_result (Callable) – A function to be called when no result found. It will receive resource_id as a first argument.

  • cross_bucket (bool) – Use the resolvers instead of the resources endpoint. Default False.

  • resolve_context (bool) – Resolve ontological term curies using the resource’s context. Default False.

  • kwargs – Keyword arguments which will be forwarded to on_no_result function.

  • use_auth (str) – OAuth token in case access is restricted. Token should be in the format for the authorization header: Bearer VALUE.

classmethod from_url(url, *, resolve_context=False, base=None, org=None, proj=None, use_auth=None)

Load entity from url.

Parameters:
  • url (str) – Full url to the entity in nexus. _self content is a valid full URL.

  • resolve_context (bool) – Resolve ontological term curies using the resource’s context. Default False.

  • use_auth (str) – OAuth token in case access is restricted. Token should be in the format for the authorization header: Bearer VALUE.

classmethod get_constrained_url(base=None, org=None, proj=None)

Get schema constrained url.

get_id()

Retrieve _id property.

get_rev()

Retrieve _rev property.

get_url()

Retrieve URL of the nexus entity.

Returns:

Content of the _self property.

classmethod list_by_schema(**kwargs)

List all instances belonging to the schema this type defines.

Parameters:

changes – Keyword changes in the new copy, should be a subset of class constructor(__init__) keyword arguments.

Returns:

New instance of the same class with changes applied.

publish(*, resource_id=None, sync_index=False, base=None, org=None, proj=None, use_auth=None, include_rev=False)

Create or update entity in nexus. Makes a remote call to nexus instance to persist entity attributes.

Parameters:
  • resource_id (str) – Resource identifier. If not provided nexus will generate one.

  • use_auth (str) – OAuth token in case access is restricted. Token should be in the format for the authorization header: Bearer VALUE.

  • include_rev (bool) – Whether to include _rev in the linked entities or not.

Returns:

New instance of the same class with revision updated.

class entity_management.base.OntologyTerm(*, url, label=None)

Bases: Frozen

Ontology term such as brain region or species

Parameters:
  • url (str) – Ontology term url identifier.

  • label (str) – Label for the ontology term.

class entity_management.base.QuantitativeValue(*, value, unitText=None, unitCode=None)

Bases: Frozen

External resource representations, this can be a file or a folder on gpfs

Parameters:
  • value (str) – Value.

  • unitText (str) – Unit text.

  • unitCode (str) – The unit of measurement given using the UN/CEFACT Common Code (3 characters) or a URL. Other codes than the UN/CEFACT Common Code may be used with a prefix followed by a colon.

class entity_management.base.Subject(*, species=None, strain=None)

Bases: BlankNode

Subject.

Parameters:
class entity_management.base.Unconstrained(*, json)

Bases: Identifiable

Shapeless data.

Parameters:

json (dict) – python dictionary which will be seralized into json.

entity_management.base.attributes(attr_dict=None, repr=True)

decorator to simplify creation of classes that have args and kwargs

entity_management.base.custom_getattr(obj, name)

Overload of __getattribute__ to trigger instantiation of Nexus object if the attribute is NotInstantiated