Bio.PDB.Entity module

Base class for Residue, Chain, Model and Structure classes.

It is a simple container class, with list and dictionary like properties.

class Bio.PDB.Entity.Entity(id)

Bases: object

Basic container object for PDB heirachy.

Structure, Model, Chain and Residue are subclasses of Entity. It deals with storage and lookup.

__init__(self, id)

Initialize the class.

__len__(self)

Return the number of children.

__getitem__(self, id)

Return the child with given id.

__delitem__(self, id)

Remove a child.

__contains__(self, id)

Check if there is a child element with the given id.

__iter__(self)

Iterate over children.

__eq__(self, other)

Test for equality. This compares full_id including the IDs of all parents.

__ne__(self, other)

Test for inequality.

__gt__(self, other)

Test greater than.

__ge__(self, other)

Test greater or equal.

__lt__(self, other)

Test less than.

__le__(self, other)

Test less or equal.

__hash__(self)

Hash method to allow uniqueness (set).

property id

Return identifier.

get_level(self)

Return level in hierarchy.

A - atom R - residue C - chain M - model S - structure

set_parent(self, entity)

Set the parent Entity object.

detach_parent(self)

Detach the parent.

detach_child(self, id)

Remove a child.

add(self, entity)

Add a child to the Entity.

insert(self, pos, entity)

Add a child to the Entity at a specified position.

get_iterator(self)

Return iterator over children.

get_list(self)

Return a copy of the list of children.

has_id(self, id)

Check if a child with given id exists.

get_parent(self)

Return the parent Entity object.

get_id(self)

Return the id.

get_full_id(self)

Return the full id.

The full id is a tuple containing all id’s starting from the top object (Structure) down to the current object. A full id for a Residue object e.g. is something like:

(“1abc”, 0, “A”, (” “, 10, “A”))

This corresponds to:

Structure with id “1abc” Model with id 0 Chain with id “A” Residue with id (” “, 10, “A”)

The Residue id indicates that the residue is not a hetero-residue (or a water) because it has a blank hetero field, that its sequence identifier is 10 and its insertion code “A”.

transform(self, rot, tran)

Apply rotation and translation to the atomic coordinates.

Parameters
  • rot (3x3 Numeric array) – A right multiplying rotation matrix

  • tran (size 3 Numeric array) – the translation vector

Examples

This is an incomplete but illustrative example:

from numpy import pi, array
from Bio.PDB.vectors import Vector, rotmat
rotation = rotmat(pi, Vector(1, 0, 0))
translation = array((0, 0, 1), 'f')
entity.transform(rotation, translation)
copy(self)

Copy entity recursively.

class Bio.PDB.Entity.DisorderedEntityWrapper(id)

Bases: object

Wrapper class to group equivalent Entities.

This class is a simple wrapper class that groups a number of equivalent Entities and forwards all method calls to one of them (the currently selected object). DisorderedResidue and DisorderedAtom are subclasses of this class.

E.g.: A DisorderedAtom object contains a number of Atom objects, where each Atom object represents a specific position of a disordered atom in the structure.

__init__(self, id)

Initialize the class.

__getattr__(self, method)

Forward the method call to the selected child.

__getitem__(self, id)

Return the child with the given id.

__setitem__(self, id, child)

Add a child, associated with a certain id.

__contains__(self, id)

Check if the child has the given id.

__iter__(self)

Return the number of children.

__len__(self)

Return the number of children.

__sub__(self, other)

Subtraction with another object.

__gt__(self, other)

Return if child is greater than other.

__ge__(self, other)

Return if child is greater or equal than other.

__lt__(self, other)

Return if child is less than other.

__le__(self, other)

Return if child is less or equal than other.

get_id(self)

Return the id.

disordered_has_id(self, id)

Check if there is an object present associated with this id.

detach_parent(self)

Detach the parent.

get_parent(self)

Return parent.

set_parent(self, parent)

Set the parent for the object and its children.

disordered_select(self, id)

Select the object with given id as the currently active object.

Uncaught method calls are forwarded to the selected child object.

disordered_add(self, child)

Add disordered entry.

This is implemented by DisorderedAtom and DisorderedResidue.

is_disordered(self)

Return 2, indicating that this Entity is a collection of Entities.

disordered_get_id_list(self)

Return a list of id’s.

disordered_get(self, id=None)

Get the child object associated with id.

If id is None, the currently selected child is returned.

disordered_get_list(self)

Return list of children.