ó
ª Ic           @   sA   d  d l  Z  e  j d ƒ Z e  j d ƒ Z d d d „  ƒ  YZ d S(   iÿÿÿÿNs   ^(\w\w\w\w)(?:$|\s+|_)(.*)s    \(?(\w:)?(-?\w*)-?(-?\w*)\)?(.*)t   Residuesc           B   s,   e  Z d  Z d d „ Z d „  Z d „  Z RS(   sæ  A collection of residues from a PDB structure.

    This class provides code to work with SCOP domain definitions. These
    are concisely expressed as a one or more chain fragments. For example,
    "(1bba A:10-20,B:)" indicates residue 10 through 20 (inclusive) of
    chain A, and every residue of chain B in the pdb structure 1bba. The pdb
    id and brackets are optional. In addition "-" indicates every residue of
    a pbd structure with one unnamed chain.

    Start and end residue ids consist of the residue sequence number and an
    optional single letter insertion code. e.g. "12", "-1", "1a", "1000"


    pdbid -- An optional PDB id, e.g. "1bba"

    fragments -- A sequence of tuples (chainID, startResID, endResID)
    
    c         C   s2   d |  _  d |  _ | d  k	 r. |  j | ƒ n  d  S(   Nt    (    (   t   pdbidt	   fragmentst   Nonet   _parse(   t   selft   str(    (    s„   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SCOP/Residues.pyt   __init__%   s    		 c   	      C   s]  | j  ƒ  } t j | ƒ } | d  k	 rK | j d ƒ |  _ | j d ƒ } n  | d k so | d k so | d k rs d  Sg  } xÎ | j d ƒ D]½ } t j | ƒ } | d  k r½ t d | ƒ ‚ n  | j	 ƒ  \ } } } } | d k rô t d | ƒ ‚ n  | r*| d d	 k rt d
 | ƒ ‚ n  | d  } n d } | j
 | | | f ƒ q‰ Wt | ƒ |  _ d  S(   Ni   i   R   t   -s   (-)t   ,s#   I don't understand the format of %siÿÿÿÿt   :s"   I don't understand the chain in %s(   t   stript	   _pdbid_ret   matchR   t   groupR   t   splitt   _fragment_ret
   ValueErrort   groupst   appendt   tupleR   (	   R   R   t   mR   t   lt   chaint   startt   endt   postfix(    (    s„   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SCOP/Residues.pyR   +   s,    $c         C   sº   d } |  j  r |  j  d } n  |  j s0 | d Sg  } xp |  j D]e \ } } } g  } | ro | j d | ƒ n  | r | j d | | f ƒ n  | j d j | ƒ ƒ q@ W| d j | ƒ S(   NR   t    R	   s   %s:s   %s-%sR
   (   R   R   R   t   join(   R   t   prefixt   strsR   R   R   t   s(    (    s„   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SCOP/Residues.pyt   __str__K   s    		   N(   t   __name__t
   __module__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/SCOP/Residues.pyR       s   	 (    (   t   ret   compileR   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/SCOP/Residues.pyt   <module>	   s   