ó
	šxTc           @   s@  d  d l  m Z d  d l m Z d  d l m Z m Z m Z m Z d  d l	 m
 Z
 d  d l	 m Z d  d l Z	 d  d l Z	 d  d l Z d  d l Z d Z e d Z e d	 „ Z d
 „  Z d d „ Z d d e e d d „ Z 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   program_result(   t   Sorryt   Usaget   null_outt	   multi_out(   t   runtime_utils(   t   easy_pickleNs—  
  nma
    .short_caption = NMA input options
    .expert_level = 1
    .style = phaser:mode:NMAYXZ,SCEDS auto_align box
  {
    mode = None
      .type = floats
      .short_caption = Modes
    combinations = None
      .type=float
  }

  enm
    .short_caption = NMA method options
    .expert_level = 2
    .style = phaser:mode:NMAXYZ,SCEDS auto_align box
  {
    oscillators = *rtb ca all
      .type=choice
      .short_caption = Atoms used for NMA
      .caption = Rotation-translation_block C-alpha_atoms_only All_atoms
    rtb_maxblocks = None
      .type=int
      .short_caption = RTB max. blocks
    rtb_nresidues = None
      .type=int
      .short_caption = RTB number of residues
    radius = None
      .type=float
      .short_caption = Elastic Network Model interaction radius
    force = None
      .type=float
      .short_caption = Elastic Network Model force constant
  }

  perturb
    .short_caption = Normal mode calculation options
    .expert_level = 1
    .style = phaser:mode:NMAYXZ,SCEDS auto_align box
  {
    increment = *rms dq
      .type=choice
    rms {
      step = None
        .type=float
      stretch = None
        .type=float
      clash = None
        .type=float
      maximum = None
        .type=float
      direction = *forward backward tofro
        .type=choice
    }
    dq = None
      .type = float
      .multiple=True
      .optional=True
      .short_caption = DQ factor
  }

s�  
  sceds
    .short_caption = NMA domain finding
    .expert_level = 1
    .style = phaser:mode:NMAYXZ,SCEDS auto_align box
  {
    enable = None
      .type = bool
    ndom = None
      .type = int
      .short_caption = Number of domains to find
    weight {
      equality = None
        .type = float
        .short_caption = Weight for equality test
      sphericity = None
        .type = float
        .short_caption = Weight for sphericity test
      density = None
        .type = float
        .short_caption = Weight for density test
      continuity = None
        .type = float
        .short_caption = Weight for continuity test
    }
  }

  ddm
    .short_caption = NMA domain options
    .expert_level = 1
    .style = phaser:mode:NMAYXZ,SCEDS auto_align box
  {
    slider = None
      .type = int
    distance
      .style = box auto_align
    {
      step = None
        .type = int
      min = None
        .type = int
      max = None
        .type = int
    }
    separation
      .style = box auto_align
    {
      min = None
        .type = int
       max = None
        .type = int
    }
    sequence
      .style = box auto_align
    {
      min = None
        .type = int
      max = None
        .type = int
    }
    join
      .style = box auto_align
    {
      min = None
        .type = int
      max = None
        .type = int
    }
    cluster = *max first last
      .type = choice
  }
c         C   sÆ   t  } d } |  r! t } d } n  d | | f } t j j d ƒ } t j j | ƒ sd t d ƒ ‚ n  t j	 j
 | d t ƒ} t j	 j
 d | ƒ g } |  r¶ | j t j	 j
 d ƒ ƒ n  | j d	 | ƒ S(
   Nt    sV   
validate_domains = True
  .type = bool
  .short_caption = Validate domain selections
sw  
file_name = None
  .type = path
  .short_caption = PDB file
  .style = file_type:pdb bold input_file
root = None
  .type = str
  .short_caption = Output prefix
  .input_size = 200
gui_output_dir = None
  .type = path
  .short_caption = Output directory
  .style = bold output_dir default_cwd directory
include scope libtbx.phil.interface.tracking_params
%s
keywords {
  %s
}s    include/phaser_nma_defaults.phils;   Missing default parameters - re-run libtbx.configure phasert   process_includest	   file_names   keywords.nmapdb.mode=Nonet   sources(   t   keywords_phil_strt   keywords_phil_nmad_strt   libtbxt   envt   under_buildt   ost   patht   existst   RuntimeErrort   philt   parset   Truet   appendt   fetch(   t   include_domainst   keywords_phil_str_t
   other_philt   master_phil_strt   defaults_filet   phil1R   (    (    sM   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/command_line/nma_perturb.pyt   master_params•   s    	c         C   s<   t  |  d ƒ } t ƒ  } | j d | ƒ | j d | ƒ | S(   Nt   wt   logfilet   stdout(   t   openR   t   register(   t   log_filet   outt   ft   out2(    (    sM   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/command_line/nma_perturb.pyt   setup_logging»   s
    	c         C   s…  | 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 d  k rÐ t j j t j j | j ƒ d ƒ d | _ n  | j d	 } t | | ƒ } t d
 | j d | j d | j d t d | ƒ } | j ƒ  | j ƒ  }	 g  |	 D] }
 t j j |
 ƒ ^ q9}	 t d d d | j d t j ƒ  d | d |	 ƒ S(   Ni    s9   phaser.nma_perturb model.pdb [options]

Full keywords:
%siÿÿÿÿt   argst   master_philt   pdb_file_defR
   t   _NMAs   .logt   pdb_filet   roott   paramst   domain_findingt   logt   program_names   phaser.nma_perturbt	   job_titlet	   directoryR&   t	   pdb_files(   t   Nonet   sysR#   R    t   lenR   t   as_strt
   iotbx.philR   t   process_command_line_with_filest   workt   extractt   validate_params_basicR0   R   R   t   basenamet   splitextR
   R*   t
   run_phasert   keywordst   Falset   closet   getPdbFilest   nma_perturb_resultR5   t   getcwd(   R+   R'   R,   t   iotbxt   cmdlineR1   R&   R)   t   phaser_resultR7   R(   (    (    sM   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/command_line/nma_perturb.pyt   runÂ   sB     		
"				
%	c      	   C   sÁ  | d  k r t ƒ  } n  | d  k r9 t ƒ  j ƒ  j } n  | d  k	 r` | sQ t ‚ | | j _ n  t d | ƒ } | j d ƒ j	 d j
 d | ƒ } d d l m }	 d d l m }
 d d  l } | j ƒ  } | j d |  d	 ƒ | j | ƒ | rÿ | j t ƒ n  | r| j t ƒ n  |	 d
 | d | d d d t ƒ  ƒ | j ƒ  } | j | ƒ | rk| j | | ƒ } n | j | | ƒ } | j ƒ  r¤t t | j ƒ  ƒ ƒ ‚ n  | s½t j  d | ƒ n  | S(   NR   RD   i    t   python_objectiÿÿÿÿ(   t   convert_keywords(   t	   callbackst   modelg      ð?t   inputt   keyword_philt   modet   NMAt
   script_outs   .phaser_result.pkl(!   R8   R   R    R?   RD   t   AssertionErrort   scedt   numbert   gett   objectst   formatt   phaser.phenix_interface.driverRO   t   phaser.phenix_interfaceRP   t   phasert   InputNMAt   addENSE_PDB_IDt   setROOTt   setEIGE_WRITRE   t   setMUTER   t   Outputt   setPackagePhenixt   runSCEDSt	   runNMAXYZt   FailedR   t   strt   ErrorMessageR   t   dump(   R/   R0   R1   R3   t   quietR2   t	   n_domainsR,   RS   RO   RP   R_   RR   t   outputt   run_nma(    (    sM   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/command_line/nma_perturb.pyRC   æ   sF     	
c         C   sM   |  j  d  k r t d ƒ ‚ n+ t j j |  j  ƒ sI t d |  j  ƒ ‚ n  t S(   Ns   PDB file not specified.s   %s is not a valid file.(   R
   R8   R   R   R   t   isfileR   (   R1   (    (    sM   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/command_line/nma_perturb.pyR@     s
    c         C   s
   t  |  ƒ S(   N(   R@   (   R1   (    (    sM   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/command_line/nma_perturb.pyt   validate_params  s    RH   c           B   s   e  Z d  „  Z RS(   c         C   s/   g  |  j  ƒ  D] } | d f ^ q } | i  f S(   Ns   Perturbed model(   t   get_pdb_files(   t   selfR(   t   output_files(    (    sM   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/command_line/nma_perturb.pyt
   finish_job"  s    %(   t   __name__t
   __module__Rv   (    (    (    sM   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/command_line/nma_perturb.pyRH   !  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   chdirRM   R+   R9   R#   (   Rt   (    (    sM   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/command_line/nma_perturb.pyRM   '  s    (   Rw   Rx   RM   (    (    (    sM   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/command_line/nma_perturb.pyRy   &  s   t   __main__i   (   t
   __future__R    t   libtbx.program_utils.resultR   t   libtbx.utilsR   R   R   R   R   R   R   t   libtbx.load_envt   libtbx.philR   R9   R   R   RE   R    R*   R8   RM   RC   R@   Rr   RH   t   target_with_save_resultRy   Rw   t   argv(    (    (    sM   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/command_line/nma_perturb.pyt   <module>   s2   "@G&	'(			