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.


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.


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 method to allow uniqueness (set).

property id

Return identifier.


Return level in hierarchy.

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

set_parent(self, entity)

Set the parent Entity object.


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.


Return iterator over children.


Return a copy of the list of children.

has_id(self, id)

Check if a child with given id exists.


Return the parent Entity object.


Return the id.


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.

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

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


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 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.


Return the number of children.


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.


Return the id.

disordered_has_id(self, id)

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


Detach the parent.


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.


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


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.


Return list of children.