ó
š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	 m
 Z
 d  d l Z d  d l Z d „  Z d d „ Z d	 „  Z d d e e d
 „ Z d „  Z d e f d „  ƒ  YZ d e j f d „  ƒ  YZ e d k rù e e j d ƒ n  d S(   iÿÿÿÿ(   t   division(   t   nma_perturb(   t   program_result(   t   runtime_utils(   t   Usaget   SorryNc           C   s   t  j d t ƒ S(   Nt   include_domains(   R   t   master_paramst   True(    (    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/command_line/sceds.pyR      s    c         C   sL  | d  k r t j } n  t ƒ  } t |  ƒ d k rL t d | j ƒ  ƒ ‚ n  d d  l } | j j	 d |  d | d d ƒ } | j
 j ƒ  } t j | ƒ | j d  k rÓ t j j t j j | j ƒ d ƒ d | _ n  | j d	 } t j | | ƒ } t j d
 | j d | j d | j d t d | ƒ } t d | d
 | j d | j d t ƒ }	 | j d }
 t |
 d ƒ } | d IJx* |	 D]" } | d | IJ| d | IJqyW| d IJ| j ƒ  } g  | D] } t j j | ƒ ^ q¼} y d d l m } Wn t k
 rn X| j d d | ƒt  d d d | j! d t j" ƒ  d | d  | d! |
 g ƒ S("   Ni    s<   phenix.sceds model.pdb [ndom=X] [options]

Full keywords:
%siÿÿÿÿt   argst   master_philt   pdb_file_deft	   file_namet   _NMAs   .logt   pdb_filet   roott   paramst   domain_findingt   logt   phaser_resultt   validatet   run_from_commands   _selections.philt   ws   Atom selectionss     s   selection = %st    (   t	   citationst   scedst   outt   program_names   phenix.scedst	   job_titlet	   directoryt   log_filet	   pdb_filest
   phil_files(#   t   Nonet   syst   stdoutR   t   lenR   t   as_strt
   iotbx.philt   philt   process_command_line_with_filest   workt   extractR   t   validate_params_basicR   t   ost   patht   basenamet   splitextR   t   setup_loggingt
   run_phasert   keywordsR   t   analyze_domainst   validate_domainst   opent   getPdbFilest   phenix.utilitiesR   t   ImportErrort   show_citationt   sceds_resultR   t   getcwd(   R	   R   R
   t   iotbxt   cmdlineR   R   t   out2R   t
   selectionst	   phil_filet   ft   seleR   R   (    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/command_line/sceds.pyt   run   sd     		"								

%	c         C   sI   d d  l  } | j j d ƒ } | j j d |  ƒ } | j d | ƒ j ƒ  S(   Niÿÿÿÿs+   
selection = None
  .type = atom_selection
R   t   source(   R&   R'   t   parset   fetchR*   (   R   R<   t   sele_mastert	   file_phil(    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/command_line/sceds.pyt   load_selectionsG   s
    		c      	   C   sL  d d l  m } d d l m } |  j ƒ  } | d  k	 r~ | d  k sJ t ‚ | j | d d ƒ} | j d ƒ | j	 j
 ƒ  } n  | d  k	 s� t ‚ g  }	 xÚ | D]Ò }
 |
 j d ƒ r¸ q� n  | j |
 d d ƒ} | j d ƒ | j	 j
 ƒ  } t | j ƒ  ƒ d k st ‚ | | ƒ } t | ƒ d k s+t ‚ t | ƒ d k r^|	 j d d	 j | ƒ d
 ƒ q� |	 j | d ƒ q� W| rH| j ƒ  } xÀ t |	 ƒ D]¯ \ } } | j | ƒ } x‘ t |	 ƒ D]ƒ \ } } | | k rØqºn  | j | ƒ } | | @j t ƒ sºd } | rd d } n  t d | d | | d | | f ƒ ‚ qºqºWq’Wn  |	 S(   Niÿÿÿÿ(   t   file_reader(   t   get_contiguous_rangest
   force_typet   pdbs   excluded.pdbi   t   (s   ) or (t   )i    R   s0   
To skip this check, set validate_domains=False s7   (or from the GUI, uncheck "Validate domain selections")s+   Overlapping selections:
%d: "%s"
%d: "%s"%si   (   R<   RJ   t   iotbx.pdb.hierarchyRK   R6   R!   t   AssertionErrort   any_filet   assert_file_typet   file_objectt   construct_hierarchyt   endswithR$   t   modelst   appendt   joint   atom_selection_cachet	   enumeratet	   selectiont   all_eqt   FalseR   (   R   R   t   pdb_hierarchyR   R   RJ   RK   t   filest   pdb_inR?   R   t   domain_hierarchyt   clausest	   sel_cachet   it   sel_strRB   t   jt	   other_strt   sele2t	   extra_msg(    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/command_line/sceds.pyR3   P   sL    ! 
/c         C   s   t  j |  ƒ S(   N(   R   t   validate_params(   R   (    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/command_line/sceds.pyRk   €   s    R:   c           B   s   e  Z d  „  Z RS(   c         C   s/   g  |  j  ƒ  D] } | d f ^ q } | i  f S(   Ns   Domain model(   t   get_pdb_files(   t   selfRA   t   output_files(    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/command_line/sceds.pyt
   finish_job„   s    %(   t   __name__t
   __module__Ro   (    (    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/command_line/sceds.pyR:   ƒ   s   t   launcherc           B   s   e  Z d  „  Z RS(   c         C   s6   t  j |  j ƒ t  j |  j ƒ t |  j d t j ƒS(   NR   (   R,   t   makedirst
   output_dirt   chdirRC   R	   R"   R#   (   Rm   (    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/command_line/sceds.pyRC   ‰   s    (   Rp   Rq   RC   (    (    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/command_line/sceds.pyRr   ˆ   s   t   __main__i   (   t
   __future__R    t   phaser.command_lineR   t   libtbx.program_utils.resultR   t   libtbxR   t   libtbx.utilsR   R   R,   R"   R   R!   RC   RI   R^   R3   Rk   R:   t   target_with_save_resultRr   Rp   t   argv(    (    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/command_line/sceds.pyt   <module>   s$   	8	+	