pestifer.core.objmanager module

A dictionary object for containing all objs from a task specification. Objs are objects that handle various modifications to a molecular structure, such as cleavages, translations, rotations, and so on. These are all defined in the pestifer.objs subpackage. This module defines the ObjManager class, which is responsible for managing these objects and their organization. It provides methods for ingesting objects, filtering them, and managing their categories. The ObjManager inherits from collections.UserDict, allowing it to behave like a dictionary while providing additional functionality specific to managing molecular objects. It also includes methods for counting objects, retiring categories, and expelling objects based on specific criteria.

class pestifer.core.objmanager.ObjManager(input_specs={})[source]

Bases: UserDict[str, UserDict[str, BaseObjList]]

A class for initializing and collecting all objs into a single, organized object. Outermost key is the object category and the innermost is the object type name.

Parameters:

input_specs (dict, optional) – A dictionary of object specifications to be ingested into the ObjManager. If not provided, an empty dictionary is used.

used

A dictionary that stores retired objects, allowing for retrieval of previously used objects.

Type:

dict

counts_by_header() dict[source]

Counts the number of objects in each category and header. This method logs the counts of objects in each category and header. It iterates through the object classes and their corresponding categories and headers, counting the number of objects in each header within each category.

expel(expelled_residues: ResidueList) ObjManager[source]

Expel all objects that match the given residues from the ObjManager.

Parameters:

expelled_residues (list) – list of residues to expel; each residue should have a resseqnum and insertion attribute

Returns:

a new ObjManager containing the expelled objects; the original ObjManager is modified to remove these objects

Return type:

ObjManager

filter_copy(condition: Callable[[BaseObj], bool], objnames: list[str] = []) ObjManager[source]

Returns a copy of the ObjManager with only the objects that match the given fields.

Parameters:
  • objnames (list) – list of object names to filter by; if empty, all objects are included

  • fields (dict) – dictionary of fields to filter by; only objects that match all fields are included

Returns:

a new ObjManager containing only the objects that match the given fields. If no object names are provided, an empty ObjManager is returned.

Return type:

ObjManager

ingest(input_obj, overwrite=False)[source]

Ingest an object or list of objects into the ObjManager.

Parameters:
  • input_obj (object, list, or dict) – an object of type Obj, a list of objects, or a dictionary of objects to be ingested

  • overwrite (bool) – if True, overwrite existing objects with the same header; if False, append to existing objects

retire(objcat)[source]

Retire an object category from the ObjManager.

Parameters:

objcat (str) – the object category to retire; if it exists, it will be removed from the ObjManager and stored in the used dictionary