Decorators and metaclasses used by atomium structures.

class atomium.base.StructureClass[source]

A metaclass which can be applied to structure class. It will override the instantation behaviour so that all methods that belong to a preset list (‘atoms’, ‘chains’ etc.) will have the query() decorator applied and a copy with the getone() decorator applied.

mro() → list

return a type’s method resolution order

class atomium.base.StructureSet(*args)[source]

A data structure for holding sub-structures. It stores them internally as a dictionary where they keys are IDs (to allow rapid lookup by ID) and the values are all structures with that ID (to allow for duplicate IDs).

Parameters:args (*) – the structures that will make up the StructureSet.

Adds a structure to the StructureSet.

Parameters:obj – the structure to add.

Gets a structure by ID.

Returns:some structure.

Returns the IDs of the StructureSet.

Return type:set

Removes a structure from the StructureSet.

Parameters:obj – the structure to remove.

Returns the structures of the StructureSet.

Return type:list
atomium.base.filter_objects(objects, key, value)[source]

Takes a StructureSet of objects, and filters them on object properties.

  • objects (StructreSet) – the dictionary of objects - the keys are unimportant.
  • key (str) – the attribute to search. This can be an attribute of the object, or attr__regex, or attr__gt etc.
  • value – the value that the attribute must have.
Return type:



A decorator which can be applied to any function which returns an iterable. It produces a function which just gets the first item in that iterable.

Parameters:func – the function to modify.
Return type:function
atomium.base.query(func, tuple_=False)[source]

A decorator which can be applied to any function which returns a StructureSet and which takes no other paramters other than self. It will query the returned objects by any keyword argument, or use a positional argument to search by ID.

  • func – the function to modify.
  • tuple (bool) – if True, objects will be returned in a tuple not a set.
Return type: