ó
±™xTc           @   s©   d  d l  m Z d  d l m Z d  d l Z d  d l Z d  d l m Z d  d l m	 Z	 d  d l
 Z
 d Z e
 j d „ Z e d „ Z e d	 k r¥ e e
 j d
 ƒ n  d S(   iÿÿÿÿ(   t   division(   t   crystal_symmetry_from_anyN(   t   crystal(   t   Sorrys>  
data = None
  .type = path
labels = None
  .type = str
sequence = None
  .type = path
model = None
  .type = path
space_group = None
  .type = space_group
unit_cell = None
  .type = unit_cell
n_residues = None
  .type = int(value_min=1)
  .optional = True
n_bases = None
  .type = int(value_min=1)
  .optional = True
c         C   sœ  t  j j d |  d t d d d d d d d	 d
 d d d d d d ƒ 	} | j j ƒ  } | j d  k sr | j d  k rO| j	 d  k r” t
 d d ƒ ‚ qOt j d | j	 ƒ } | j ƒ  } | j d  k rå | d  k	 r+| j ƒ  | _ q+nF | d  k	 r+| | j k r+| d d IJ| d | j | f IJq+n  | j d  k rO| j ƒ  | _ qOn  t | d t ƒ| j d  k	 rî| j | j k o‹d  k n s–t ‚ t  j j d | j d | ƒ } | d  k	 rÛ| j | _ | j | _ qÎt
 d d ƒ ‚ nà | j d  k	 rÎ| j | j k od  k n s%t ‚ d d l m } d | _ d | _ | | j ƒ } | j j }	 xi |	 j ƒ  d j ƒ  D]N }
 |
 j ƒ  r£| j |
 j ƒ  7_ qy|
 j ƒ  ry| j |
 j ƒ  7_ qyqyWn  | d | j IJ| d | j IJ| j d k r| d  | j IJn  | j d k r6| d! | j IJn  t j  d" | j d | j ƒ } d d# l! m" } | j# d$ | d | j d% | j ƒ } | j$ d& | ƒ | S('   Nt   argst   master_phil_stringt   pdb_file_deft   modelt   reflection_file_deft   datat   seq_file_deft   sequencet   space_group_deft   space_groupt   unit_cell_deft	   unit_cellt   integer_deft
   n_residuest   usage_strings¶   phenix.matthews [data.hkl] [space_group] [unit_cel] [sequence] [n_residues] ...

Calculate the expected Matthews coefficient given the crystal symmetry and
crystallized molecule(s).
s7   You must supply both a space group and a unit cell (or s)   a data file containing this information).t	   file_names3   WARNING: space group mismatch between command line s	   and file:s     %s (cmdline), %s (file)t   check_symmetryt   logs6   No composition information could be obtained from the s   sequence file.iÿÿÿÿ(   t   any_filei    s   Space group: %ss   Unit cell: %ss   Number of residues: %ds   Number of bases: %dt   space_group_info(   t   matthewst   crystal_symmetryt   n_basest   out(%   t   iotbxt   philt   process_command_line_with_filest   master_phil_strt   workt   extractR   t   NoneR   R	   R   R   t   extract_fromt   validate_paramst   TrueR   R   R   t   AssertionErrort   bioinformaticst   composition_from_sequence_fileR   t   iotbx.file_readerR   t   file_objectt	   hierarchyt   modelst   chainst
   is_proteint   residue_groups_sizet   is_naR   t   symmetryt   mmtbx.scalingR   t   matthews_ruppt   show(   R   R   t   cmdlinet   paramst   symmt   space_group_from_filet   seq_compR   t   pdb_inR+   t   chainR   t   result(    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/command_line/matthews.pyt   run!   s†    	(		(						c         C   s±   |  j  d  k rB |  j d  k rB |  j d  k rs |  j d  k rs qs n1 |  j d  k	 s` |  j d  k	 rs t d d ƒ ‚ n  | r­ |  j d  k s— |  j d  k r­ t d d ƒ ‚ q­ n  t S(   Ns8   You may only specify a sequence file OR a partial model s(   OR the numbers of residues and/or bases.s7   You must supply both a space group and a unit cell (or s)   a data file containing this information).(	   R   R"   R   R   R   R   R   R   R%   (   R6   R   (    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/command_line/matthews.pyR$   m   s    t   __main__i   (   t
   __future__R    R   R   t   iotbx.bioinformaticst
   iotbx.philt   cctbxR   t   libtbx.utilsR   t   sysR   t   stdoutR=   t   FalseR$   t   __name__t   argv(    (    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/command_line/matthews.pyt   <module>   s   L