Back to index

python-biopython  1.60
Functions | Variables
Bio.PDB.Selection Namespace Reference

Functions

def uniqueify
def get_unique_parents
def unfold_entities
def _test

Variables

list entity_levels = ["A", "R", "C", "M", "S"]

Function Documentation

def Bio.PDB.Selection._test ( ) [private]
Run the Bio.PDB.Selection module's doctests (PRIVATE).

Definition at line 84 of file Selection.py.

00084 
00085 def _test():
00086     """Run the Bio.PDB.Selection module's doctests (PRIVATE)."""
00087     import doctest
00088     print "Runing doctests ..."
00089     doctest.testmod()
00090     print "Done"
00091 

def Bio.PDB.Selection.get_unique_parents (   entity_list)
Translate a list of entities to a list of their (unique) parents.

Definition at line 23 of file Selection.py.

00023 
00024 def get_unique_parents(entity_list):
00025     """Translate a list of entities to a list of their (unique) parents.""" 
00026     parents = [entity.get_parent() for entity in entity_list]
00027     return uniqueify(parents)
00028 

Here is the call graph for this function:

def Bio.PDB.Selection.unfold_entities (   entity_list,
  target_level 
)
Unfold entities list to a child level (e.g. residues in chain).

Unfold a list of entities to a list of entities of another 
level.  E.g.:

list of atoms -> list of residues
list of modules -> list of atoms
list of residues -> list of chains

o entity_list - list of entities or a single entity
o target_level - char (A, R, C, M, S)

Note that if entity_list is an empty list, you get an empty list back:

>>> unfold_entities([], "A")
[]

Definition at line 29 of file Selection.py.

00029 
00030 def unfold_entities(entity_list, target_level):
00031     """Unfold entities list to a child level (e.g. residues in chain).
00032 
00033     Unfold a list of entities to a list of entities of another 
00034     level.  E.g.:
00035 
00036     list of atoms -> list of residues
00037     list of modules -> list of atoms
00038     list of residues -> list of chains
00039 
00040     o entity_list - list of entities or a single entity
00041     o target_level - char (A, R, C, M, S)
00042 
00043     Note that if entity_list is an empty list, you get an empty list back:
00044 
00045     >>> unfold_entities([], "A")
00046     []
00047 
00048     """
00049     if not target_level in entity_levels:
00050         raise PDBException("%s: Not an entity level." % target_level)
00051     if entity_list == []:
00052         return []
00053     if isinstance(entity_list, Entity):
00054         # single entity
00055         entity_list=[entity_list]
00056     # level of entity list
00057     level=entity_list[0].get_level()
00058     for entity in entity_list:
00059         if not (entity.get_level()==level):
00060             raise PDBException("Entity list is not homogeneous.")
00061     target_index=entity_levels.index(target_level)
00062     level_index=entity_levels.index(level)
00063     if level_index==target_index:
00064         # already right level
00065         return entity_list
00066     if level_index>target_index:
00067         # we're going down, e.g. S->A
00068         for i in range(target_index, level_index):
00069             new_entity_list=[]
00070             for entity in entity_list:
00071                 new_entity_list=new_entity_list+entity.get_list()
00072             entity_list=new_entity_list
00073     else:
00074         # we're going up, e.g. A->S
00075         for i in range(level_index, target_index):
00076             new_entity_list=[]  
00077             for entity in entity_list:
00078                 parent=entity.get_parent()
00079                 new_entity_list.append(parent)
00080             # find unique parents
00081             entity_list=uniqueify(new_entity_list)
00082     return entity_list
00083 

Here is the call graph for this function:

Here is the caller graph for this function:

def Bio.PDB.Selection.uniqueify (   items)
Return a list of the unique items in the given iterable.

Order is NOT preserved.

Definition at line 15 of file Selection.py.

00015 
00016 def uniqueify(items):
00017     """Return a list of the unique items in the given iterable.
00018 
00019     Order is NOT preserved.
00020     """
00021     return list(set(items))
00022 

Here is the caller graph for this function:


Variable Documentation

list Bio.PDB.Selection.entity_levels = ["A", "R", "C", "M", "S"]

Definition at line 12 of file Selection.py.