ó
°áåHc           @   sZ   d  d l  m Z d  d l m Z d Z d d d d d g Z d	 „  Z d
 „  Z d „  Z d S(   iÿÿÿÿ(   t   ListType(   t   PDBExceptions"   Selection of atoms, residues, etc.t   At   Rt   Ct   Mt   Sc         C   s=   i  } x* |  D]" } | j  | ƒ s d | | <q q W| j ƒ  S(   s   Return unique items in list l.N(   t   has_keyt   Nonet   keys(   t   lt   dt   i(    (    s„   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/Selection.pyt	   uniqueify   s
    c         C   s:   g  } x' |  D] } | j  ƒ  } | j | ƒ q Wt | ƒ S(   sO   
    Translate a list of entities to a list of their
    (unique) parents.
    (   t
   get_parentt   appendR   (   t   entity_listR
   t   entityt   parent(    (    s„   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/Selection.pyt   get_unique_parents   s
    c   	      C   s]  | t  k r t d | ƒ ‚ n  t |  ƒ t k r= |  g }  n  |  d j ƒ  } x/ |  D]' } | j ƒ  | k sT t d ƒ ‚ qT qT Wt  j | ƒ } t  j | ƒ } | | k r­ |  S| | k rx t | | ƒ D]3 } g  } x |  D] } | | j ƒ  } qÜ W| }  qÉ WnV xS t | | ƒ D]B } g  } x' |  D] } | j ƒ  } | j	 | ƒ q&Wt
 | ƒ }  qW|  S(   s-  
    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)
    s   %s: Not an entity level.i    s   Entity list is not homogeneous.(   t   entity_levelsR   t   typeR    t	   get_levelt   indext   ranget   get_listR   R   R   (	   R   t   target_levelt   levelR   t   target_indext   level_indexR   t   new_entity_listR   (    (    s„   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/Selection.pyt   unfold_entities"   s2    N(	   t   typesR    t   PDBExceptionsR   t   __doc__R   R   R   R   (    (    (    s„   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/Selection.pyt   <module>   s   		