ó
{™xTc           @   s¢   d  d l  m Z d  d l m Z d  d l m Z d  d l m Z d  d l m Z d  d l m	 Z	 m
 Z
 m Z d e	 f d „  ƒ  YZ e Z d	 e f d
 „  ƒ  YZ d S(   iÿÿÿÿ(   t   division(   t   crystal_symmetry_from_any(   t   crystal(   t   sgtbx(   t   uctbx(   t   libtbx_option_parsert   OptionErrort   make_optiont   option_parserc           B   sz   e  Z d	 d	 d	 d  „ Z d „  Z d „  Z d „  Z d „  Z d	 d „ Z d	 d „ Z	 d	 d	 d „ Z
 d	 d	 d	 d	 d „ Z RS(
   c         C   s/   t  j |  d | d | d | ƒt ƒ  |  _ d  S(   Nt   usaget   descriptiont	   more_help(   R   t   __init__t   symmetry_callback(   t   selfR	   R
   R   (    (    sA   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/option_parser.pyR   
   s    c         C   sG   |  j  t d  d d d d d d |  j d d d d	 ƒƒ t |  j _ |  S(
   Ns   --unit_cellt   actiont   callbackt   typet   stringt   helps   External unit cell parameterst   metavars   10,10,20,90,90,120|FILENAME(   t
   add_optionR   t   NoneR   t   Truet
   is_enabled(   R   (    (    sA   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/option_parser.pyt   enable_unit_cell   s    	
c         C   sG   |  j  t d  d d d d d d |  j d d d d	 ƒƒ t |  j _ |  S(
   Ns   --space_groupR   R   R   R   R   s   External space group symbolR   s   P212121|FILENAME(   R   R   R   R   R   R   (   R   (    (    sA   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/option_parser.pyt   enable_space_group   s    	
c         C   sG   |  j  t d  d d d d d d |  j d d d d	 ƒƒ t |  j _ |  S(
   Ns
   --symmetryR   R   R   R   R   s'   External file with symmetry informationR   t   FILENAME(   R   R   R   R   R   R   (   R   (    (    sA   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/option_parser.pyt   enable_symmetry#   s    	
c         C   s"   |  j  ƒ  |  j ƒ  |  j ƒ  |  S(   N(   R   R   R   (   R   (    (    sA   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/option_parser.pyt   enable_symmetry_comprehensive-   s    


c         C   s8   |  j  t d  d d d d | d d d d d	 d
 ƒƒ |  S(   Ns   --resolutionR   t   storet   defaultR   t   floatR   s0   High resolution limit (minimum d-spacing, d_min)R   t   FLOAT(   R   R   R   (   R   R   (    (    sA   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/option_parser.pyt   enable_resolution3   s    
c         C   s8   |  j  t d  d d d d | d d d d d	 d
 ƒƒ |  S(   Ns   --low_resolutionR   R   R   R   R    R   s/   Low resolution limit (maximum d-spacing, d_max)R   R!   (   R   R   R   (   R   R   (    (    sA   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/option_parser.pyt   enable_low_resolution<   s    
c         C   s$   |  j  d | ƒ |  j d | ƒ |  S(   NR   (   R"   R#   (   R   t   default_lowt   default_high(    (    sA   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/option_parser.pyt   enable_resolutionsE   s    c      
   C   s=   t  j |  d | d | d | d | ƒ} |  j j ƒ  | _ | S(   Nt   argst   nargst	   min_nargst	   max_nargs(   R   t   processR   t   gett   symmetry(   R   R'   R(   R)   R*   t   result(    (    sA   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/option_parser.pyR+   J   s    N(   t   __name__t
   __module__R   R   R   R   R   R   R"   R#   R&   R+   (    (    (    sA   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/option_parser.pyR      s   	
	
	
			R   c           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C   s   t  |  _ d  |  _ d  |  _ d  S(   N(   t   FalseR   R   t	   unit_cellt   space_group_info(   R   (    (    sA   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/option_parser.pyR   T   s    		c         C   s  | d k r¦ d  } y t j | ƒ } Wn t k
 r8 n X| d  k	 rQ | |  _ qt j | ƒ } | d  k s~ | j ƒ  d  k r” t d | | ƒ ‚ n  | j ƒ  |  _ n^| d k rad  } t j d | ƒ } y t j d | ƒ } Wn t k
 ró n X| d  k	 r| |  _ qt j | ƒ } | d  k s9| j ƒ  d  k rOt d | | ƒ ‚ n  | j ƒ  |  _ n£ | d k rût j | ƒ } | d  k sš| j ƒ  d  k r°t d | | ƒ ‚ n  | j ƒ  d  k	 rÔ| j ƒ  |  _ n  | j ƒ  d  k	 r| j ƒ  |  _ qn	 t	 d ‚ d  S(	   Ns   --unit_cells   cannot read parameters: s   --space_groupt   symbols   unknown space group: s
   --symmetrys   cannot read symmetry: s   Programming error.(
   R   R   R2   t	   ExceptionR   t   extract_fromR   R   R3   t   RuntimeError(   R   t   optiont   optt   valuet   parserR2   t   crystal_symmetryR3   (    (    sA   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/option_parser.pyt   __call__Y   sJ        c         C   s   t  j d |  j d |  j ƒ S(   NR2   R3   (   R   R-   R2   R3   (   R   (    (    sA   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/option_parser.pyR,      s    		(   R/   R0   R   R=   R,   (    (    (    sA   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/option_parser.pyR   R   s   		&N(   t
   __future__R    t   iotbxR   t   cctbxR   R   R   t   libtbx.option_parserR   R   R   R   t   iotbx_option_parsert   objectR   (    (    (    sA   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/option_parser.pyt   <module>   s   H