Back to index

python-biopython  1.60
Public Member Functions | Public Attributes | Private Member Functions
Bio.PDB.Residue.Residue Class Reference
Inheritance diagram for Bio.PDB.Residue.Residue:
Inheritance graph
[legend]
Collaboration diagram for Bio.PDB.Residue.Residue:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def __repr__
def add
def sort
def flag_disordered
def is_disordered
def get_resname
def get_unpacked_list
def get_segid
def __len__
def __getitem__
def __delitem__
def __contains__
def __iter__
def get_level
def set_parent
def detach_parent
def detach_child
def insert
def get_iterator
def get_list
def has_id
def get_parent
def get_id
def get_full_id
def transform
def copy

Public Attributes

 level
 disordered
 resname
 segid
 id
 full_id
 parent
 child_list
 child_dict
 xtra

Private Member Functions

def _sort

Detailed Description

Represents a residue. A Residue object stores atoms.

Definition at line 21 of file Residue.py.


Constructor & Destructor Documentation

def Bio.PDB.Residue.Residue.__init__ (   self,
  id,
  resname,
  segid 
)

Definition at line 25 of file Residue.py.

00025 
00026     def __init__(self, id, resname, segid):
00027         self.level="R"
00028         self.disordered=0
00029         self.resname=resname
00030         self.segid=segid
00031         Entity.__init__(self, id)


Member Function Documentation

def Bio.PDB.Entity.Entity.__contains__ (   self,
  id 
) [inherited]

Reimplemented in Bio.PDB.Chain.Chain.

Definition at line 44 of file Entity.py.

00044 
00045     def __contains__(self, id):
00046         "True if there is a child element with the given id."
00047         return (id in self.child_dict)

def Bio.PDB.Entity.Entity.__delitem__ (   self,
  id 
) [inherited]

Reimplemented in Bio.PDB.Chain.Chain.

Definition at line 40 of file Entity.py.

00040 
00041     def __delitem__(self, id):
00042         "Remove a child."
00043         return self.detach_child(id)

Here is the call graph for this function:

def Bio.PDB.Entity.Entity.__getitem__ (   self,
  id 
) [inherited]

Reimplemented in Bio.PDB.Chain.Chain.

Definition at line 36 of file Entity.py.

00036 
00037     def __getitem__(self, id):
00038         "Return the child with given id."
00039         return self.child_dict[id]

Here is the caller graph for this function:

def Bio.PDB.Entity.Entity.__iter__ (   self) [inherited]

Definition at line 48 of file Entity.py.

00048 
00049     def __iter__(self):
00050         "Iterate over children."
00051         for child in self.child_list:
00052             yield child

Here is the caller graph for this function:

def Bio.PDB.Entity.Entity.__len__ (   self) [inherited]

Definition at line 32 of file Entity.py.

00032 
00033     def __len__(self):
00034         "Return the number of children."
00035         return len(self.child_list)

Definition at line 34 of file Residue.py.

00034 
00035     def __repr__(self):
00036         resname=self.get_resname()
00037         hetflag, resseq, icode=self.get_id()
00038         full_id=(resname, hetflag, resseq, icode)
00039         return "<Residue %s het=%s resseq=%s icode=%s>" % full_id

Here is the call graph for this function:

def Bio.PDB.Residue.Residue._sort (   self,
  a1,
  a2 
) [private]
Sort the Atom objects.

Atoms are sorted alphabetically according to their name, 
but N, CA, C, O always come first.

Arguments:
o a1, a2 - Atom objects

Definition at line 42 of file Residue.py.

00042 
00043     def _sort(self, a1, a2):
00044         """Sort the Atom objects.
00045 
00046         Atoms are sorted alphabetically according to their name, 
00047         but N, CA, C, O always come first.
00048 
00049         Arguments:
00050         o a1, a2 - Atom objects
00051         """
00052         name1=a1.get_name()
00053         name2=a2.get_name()
00054         if name1==name2:
00055             return(cmp(a1.get_altloc(), a2.get_altloc()))
00056         if name1 in _atom_name_dict:
00057             index1=_atom_name_dict[name1]
00058         else:
00059             index1=None
00060         if name2 in _atom_name_dict:
00061             index2=_atom_name_dict[name2]
00062         else:
00063             index2=None
00064         if index1 and index2:
00065             return cmp(index1, index2)
00066         if index1:
00067             return -1
00068         if index2:
00069             return 1
00070         return cmp(name1, name2)

Here is the caller graph for this function:

def Bio.PDB.Residue.Residue.add (   self,
  atom 
)
Add an Atom object.

Checks for adding duplicate atoms, and raises a
PDBConstructionException if so.

Reimplemented from Bio.PDB.Entity.Entity.

Definition at line 73 of file Residue.py.

00073 
00074     def add(self, atom):
00075         """Add an Atom object.
00076 
00077         Checks for adding duplicate atoms, and raises a
00078         PDBConstructionException if so.
00079         """
00080         atom_id=atom.get_id()
00081         if self.has_id(atom_id):
00082             raise PDBConstructionException( \
00083                 "Atom %s defined twice in residue %s" % (atom_id, self))
00084         Entity.add(self, atom)

Here is the call graph for this function:

Here is the caller graph for this function:

def Bio.PDB.Entity.Entity.copy (   self) [inherited]

Definition at line 172 of file Entity.py.

00172 
00173     def copy(self):
00174         shallow = copy(self)
00175 
00176         shallow.child_list = []
00177         shallow.child_dict = {}
00178         shallow.xtra = copy(self.xtra)
00179 
00180         shallow.detach_parent()
00181 
00182         for child in self.child_list:
00183             shallow.add(child.copy())
00184         return shallow

Here is the caller graph for this function:

def Bio.PDB.Entity.Entity.detach_child (   self,
  id 
) [inherited]

Definition at line 74 of file Entity.py.

00074 
00075     def detach_child(self, id):
00076         "Remove a child."
00077         child=self.child_dict[id] 
00078         child.detach_parent()
00079         del self.child_dict[id]
00080         self.child_list.remove(child)

Here is the caller graph for this function:

def Bio.PDB.Entity.Entity.detach_parent (   self) [inherited]

Definition at line 70 of file Entity.py.

00070 
00071     def detach_parent(self):
00072         "Detach the parent."
00073         self.parent=None

Definition at line 88 of file Residue.py.

00088 
00089     def flag_disordered(self):
00090         "Set the disordered flag."
00091         self.disordered=1

def Bio.PDB.Entity.Entity.get_full_id (   self) [inherited]
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) beacuse it has a blank hetero field, that its sequence 
identifier is 10 and its insertion code "A".

Definition at line 122 of file Entity.py.

00122 
00123     def get_full_id(self):
00124         """Return the full id.
00125 
00126         The full id is a tuple containing all id's starting from
00127         the top object (Structure) down to the current object. A full id for
00128         a Residue object e.g. is something like:
00129 
00130         ("1abc", 0, "A", (" ", 10, "A"))
00131 
00132         This corresponds to:
00133 
00134         Structure with id "1abc"
00135         Model with id 0
00136         Chain with id "A"
00137         Residue with id (" ", 10, "A")
00138 
00139         The Residue id indicates that the residue is not a hetero-residue 
00140         (or a water) beacuse it has a blank hetero field, that its sequence 
00141         identifier is 10 and its insertion code "A".
00142         """
00143         if self.full_id==None:
00144             entity_id=self.get_id()
00145             l=[entity_id]   
00146             parent=self.get_parent()
00147             while not (parent is None):
00148                 entity_id=parent.get_id()
00149                 l.append(entity_id)
00150                 parent=parent.get_parent()
00151             l.reverse()
00152             self.full_id=tuple(l)
00153         return self.full_id

Here is the call graph for this function:

def Bio.PDB.Entity.Entity.get_id (   self) [inherited]

Definition at line 118 of file Entity.py.

00118 
00119     def get_id(self):
00120         "Return the id."
00121         return self.id

Here is the caller graph for this function:

def Bio.PDB.Entity.Entity.get_iterator (   self) [inherited]

Definition at line 101 of file Entity.py.

00101 
00102     def get_iterator(self):
00103         "Return iterator over children."
00104         for child in self.child_list:
00105             yield child

def Bio.PDB.Entity.Entity.get_level (   self) [inherited]
Return level in hierarchy.

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

Definition at line 55 of file Entity.py.

00055 
00056     def get_level(self):
00057         """Return level in hierarchy.
00058 
00059         A - atom
00060         R - residue
00061         C - chain
00062         M - model
00063         S - structure
00064         """
00065         return self.level

def Bio.PDB.Entity.Entity.get_list (   self) [inherited]

Definition at line 106 of file Entity.py.

00106 
00107     def get_list(self):
00108         "Return a copy of the list of children."
00109         return copy(self.child_list)

Here is the call graph for this function:

Here is the caller graph for this function:

def Bio.PDB.Entity.Entity.get_parent (   self) [inherited]

Definition at line 114 of file Entity.py.

00114 
00115     def get_parent(self):
00116         "Return the parent Entity object."
00117         return self.parent

Here is the caller graph for this function:

Definition at line 96 of file Residue.py.

00096 
00097     def get_resname(self):
00098         return self.resname

Here is the caller graph for this function:

Definition at line 112 of file Residue.py.

00112 
00113     def get_segid(self):
00114         return self.segid
00115 

Returns the list of all atoms, unpack DisorderedAtoms."

Definition at line 99 of file Residue.py.

00099 
00100     def get_unpacked_list(self):
00101         """
00102         Returns the list of all atoms, unpack DisorderedAtoms."
00103         """
00104         atom_list=self.get_list()
00105         undisordered_atom_list=[]
00106         for atom in atom_list:
00107             if atom.is_disordered():
00108                 undisordered_atom_list=(undisordered_atom_list+ atom.disordered_get_list())
00109             else:
00110                 undisordered_atom_list.append(atom)
00111         return undisordered_atom_list       

Here is the call graph for this function:

def Bio.PDB.Entity.Entity.has_id (   self,
  id 
) [inherited]
True if a child with given id exists.

Reimplemented in Bio.PDB.Chain.Chain.

Definition at line 110 of file Entity.py.

00110 
00111     def has_id(self, id):
00112         """True if a child with given id exists."""
00113         return (id in self.child_dict)

Here is the caller graph for this function:

def Bio.PDB.Entity.Entity.insert (   self,
  pos,
  entity 
) [inherited]

Definition at line 91 of file Entity.py.

00091 
00092     def insert(self, pos, entity):
00093         "Add a child to the Entity at a specified position."
00094         entity_id=entity.get_id()
00095         if self.has_id(entity_id):
00096             raise PDBConstructionException( \
00097                 "%s defined twice" % str(entity_id))
00098         entity.set_parent(self)
00099         self.child_list[pos:pos] = [entity]
00100         self.child_dict[entity_id]=entity        

Here is the call graph for this function:

Definition at line 92 of file Residue.py.

00092 
00093     def is_disordered(self):
00094         "Return 1 if the residue contains disordered atoms."
00095         return self.disordered

def Bio.PDB.Entity.Entity.set_parent (   self,
  entity 
) [inherited]

Definition at line 66 of file Entity.py.

00066 
00067     def set_parent(self, entity):
00068         "Set the parent Entity object."
00069         self.parent=entity

Definition at line 85 of file Residue.py.

00085 
00086     def sort(self):
00087         self.child_list.sort(self._sort)

Here is the call graph for this function:

def Bio.PDB.Entity.Entity.transform (   self,
  rot,
  tran 
) [inherited]
Apply rotation and translation to the atomic coordinates.

Example:
>>> rotation=rotmat(pi, Vector(1,0,0))
>>> translation=array((0,0,1), 'f')
>>> entity.transform(rotation, translation)

@param rot: A right multiplying rotation matrix
@type rot: 3x3 Numeric array

@param tran: the translation vector
@type tran: size 3 Numeric array

Definition at line 154 of file Entity.py.

00154 
00155     def transform(self, rot, tran):
00156         """
00157         Apply rotation and translation to the atomic coordinates.
00158 
00159         Example:
00160                 >>> rotation=rotmat(pi, Vector(1,0,0))
00161                 >>> translation=array((0,0,1), 'f')
00162                 >>> entity.transform(rotation, translation)
00163 
00164         @param rot: A right multiplying rotation matrix
00165         @type rot: 3x3 Numeric array
00166 
00167         @param tran: the translation vector
00168         @type tran: size 3 Numeric array
00169         """
00170         for o in self.get_list():
00171             o.transform(rot, tran)

Here is the call graph for this function:


Member Data Documentation

Definition at line 26 of file Entity.py.

Definition at line 25 of file Entity.py.

Definition at line 27 of file Residue.py.

Definition at line 23 of file Entity.py.

Definition at line 22 of file Entity.py.

Definition at line 26 of file Residue.py.

Definition at line 24 of file Entity.py.

Definition at line 28 of file Residue.py.

Definition at line 29 of file Residue.py.

Definition at line 28 of file Entity.py.


The documentation for this class was generated from the following file: