ó
fb!Ic           @   s¢   y d  d l  Z  Wn- e k
 r? d  d l m Z e d ƒ ‚ n Xd  d l Z d „  Z d d d „  ƒ  YZ d „  Z e j Z	 e ƒ  e _ z e ƒ  Wd e	 e _ Xd S(	   iÿÿÿÿN(   t   MissingExternalDependencyErrors)   Install NumPy if you want to use Bio.PDB.c             s«   d d l  m ‰  d d l m }  d d ‡  f d †  ƒ  Y} xf t d d ƒ D]U } g  t d ƒ D] } | ƒ  ^ q\ } |  | ƒ } | j d	 ƒ } | d k sI t ‚ qI Wd
 GHd  S(   Niÿÿÿÿ(   t   random(   t   NeighborSearcht   Atomc              s    e  Z ‡  f d  †  Z d „  Z RS(   c            s   d ˆ  d ƒ |  _  d  S(   Nid   i   (   t   coord(   t   self(   R   (    s   test_PDB.pyt   __init__   s    c         S   s   |  j  S(   N(   R   (   R   (    (    s   test_PDB.pyt	   get_coord   s    (   t   __name__t
   __module__R   R   (    (   R   (    s   test_PDB.pyR      s   i    i   id   g      @t   Done(    (   t   numpy.randomR   t   Bio.PDB.NeighborSearchR   t   ranget
   search_allt   AssertionError(   R   R   t   it   jt   alt   nst   hits(    (   R   s   test_PDB.pyt   quick_neighbor_search_test   s    "t   TheVoidc           B   s   e  Z d  „  Z RS(   c         C   s   d  S(   N(    (   R   t   string(    (    s   test_PDB.pyt   write&   s    (   R   R	   R   (    (    (    s   test_PDB.pyR   $   s   c       	   C   s!  d d l  m }  m } m } |  d d ƒ } | j d d ƒ } xo| j ƒ  D]a} | j ƒ  } d | t | ƒ f GHx7| j ƒ  D])} | j ƒ  } d | t | ƒ f GHxÿ | j ƒ  D]ñ }	 |	 j ƒ  }
 |
 \ } } } d	 | | | t |	 ƒ f GH|	 j ƒ  d
 k r@d GHd } x" |	 j	 ƒ  D] } | | d } qW| d  d GHn  |	 j ƒ  d k r² d } x- |	 j ƒ  D] } | j ƒ  re| d } qeqeW| d k r£d | GHq£q² q² Wq~ WqJ Wd GH| ƒ  } x  | j
 | d ƒ D] } | GHqÑWd GH| ƒ  } x  | j
 | d ƒ D] } | GHqWd GHt ƒ  d  S(   Niÿÿÿÿ(   t	   PDBParsert	   PPBuildert   CaPPBuildert
   PERMISSIVEi   t   examples   PDB/a_structure.pdbs   Model %i contains %i chains.s!   	Chain '%s' contains %i residues.s-   		Residue ('%s', %i, '%s') contains %i atoms.i   sE   			There is a point mutation present in the crystal at this position.s!   			Residues at this position are t    t   .i    s,   			The residue contains %i disordered atoms.s   Polypeptides using C-Ns   Polypeptides using CA-CAs   NeighborSearch test(   t   Bio.PDBR   R   R   t   get_structuret   get_listt   get_idt   lent   is_disorderedt   disordered_get_id_listt   build_peptidesR   (   R   R   R   t   pt	   structuret   modelt   model_idt   chaint   chain_idt   residuet
   residue_idt   hetfieldt   resseqt   icodet   st   resnamet   disordered_countt   atomt   ppbt   pp(    (    s   test_PDB.pyt   run_test)   sH    				(    (
   t   numpyt   ImportErrort   BioR    t   sysR   R   R9   t   stderrt
   old_stderr(    (    (    s   test_PDB.pyt   <module>   s   		5	