ó
±™xTc           @   s¢   d  d l  m Z d  d l Z d  d l m Z m Z d  d l m Z d  d l	 Z	 e j
 j d ƒ Z d
 d e	 j d „ Z d „  Z e d k rž e e	 j d	 ƒ n  d S(   iÿÿÿÿ(   t   divisionN(   t   Sorryt   Usage(   t
   group_argss™  
symmetry_search
  .short_caption = PDB symmetry search
  .caption = This utility allows you to search the PDB for structures with     similar unit cell parameters.  Crystallization artifacts due to     impurities in the protein solution can often be detected this way, if the     protein which actually crystallized has been solved before.  Note that     a large number of false positives are usually expected for genuinely     novel structures, so the presence of similar unit cells is not     necessarily a bad sign.
  .style = box auto_align caption_img:icons/custom/pdb_import64.png
{
  file_name = None
    .type = path
    .short_caption = File name (PDB or MTZ)
  unit_cell = None
    .type = unit_cell
  space_group = None
    .type = space_group
  max_rmsd = None
    .type = float
    .short_caption = Max. RMSD to consider
  max_hits_to_display = 50
    .type = int
    .short_caption = Max. number of hits
}
c         C   sš  t  |  ƒ d k rN t j j d |  d t d d d d ƒ } | j j ƒ  j } n$ | d  k ri t	 d ƒ ‚ n	 | j } d d	 l
 m } d d
 l m } d d l m } | j ƒ  } | j d  k	 r1| j d | j ƒ } | d  k rô t d | j ƒ ‚ qO| j ƒ  d  k s| j ƒ  d  k rOt d | j ƒ ‚ qOn | j d | j d | j ƒ } | d IJ| d IJ| j ƒ  | j | | d | j ƒ}	 | j ƒ  j ƒ  j ƒ  }
 | d IJ| d IJg  } xÊ |	 | j  D]» } | d | j j | j | j f IJ| d | j j j ƒ  j ƒ  IJ| d | j j j ƒ  j ƒ  IJ| d |
 IJ| d IJ| j  t! d | j j d | j d | j d | j j ƒ ƒ qÈWt! d | d | ƒ S(   Ni    t   argst   master_philt   pdb_file_defs   symmetry_search.file_namet   reflection_file_defsz   mmtbx.search_pdb_symmetry [file] [space_group] [unit_cell]
  Utility for finding similar unit cells deposited in the PDB.
iÿÿÿÿ(   t   pdb_symmetry(   t   crystal_symmetry_from_any(   t   crystalt	   file_names2   The file %s does not include symmetry information.s&   Incomplete symmetry information in %s.t	   unit_cellt   space_group_infot    s   Input symmetry:t   max_rmsds    Top %d matches (sorted by RMSD):s%   %s (rmsd = %.3f, volume ratio = %.2f)s2       Unit cell: %8.3f %8.3f %8.3f %8.3f %8.3f %8.3fs2     Niggli cell: %8.3f %8.3f %8.3f %8.3f %8.3f %8.3fs2     Target cell: %8.3f %8.3f %8.3f %8.3f %8.3f %8.3ft   pdb_idt   rmsdt   volume_ratioR   t   crystal_symmetryt   hits("   t   lent   iotbxt   philt   process_command_line_with_filesR   t   workt   extractt   symmetry_searcht   NoneR   t   mmtbxR   R	   t   cctbxR
   t   load_dbR   t   extract_fromR   t   space_groupR   t   symmetryt   show_summaryR   t   niggli_cellt
   parameterst   max_hits_to_displayt   entryR   R   R   R   t   appendR   (   R   t   paramst   outt   cmdlineR   R	   R
   t   dbt   symmt   scoresR$   t   resultst   scored(    (    sT   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/command_line/search_pdb_symmetry.pyt   run$   sf    		$		





		c         C   sJ   |  j  }  d  |  j |  j g k } | rF |  j d  k rF t d ƒ ‚ n  t S(   Ns+   Missing or incomplete symmetry information.(   R   R   R   R!   R   R   t   True(   R)   t	   have_symm(    (    sT   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/command_line/search_pdb_symmetry.pyt   validate_params\   s
    	t   __main__i   (    (   t
   __future__R    t
   iotbx.philR   t   libtbx.utilsR   R   t   libtbxR   t   sysR   t   parseR   R   t   stdoutR1   R4   t   __name__t   argv(    (    (    sT   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/command_line/search_pdb_symmetry.pyt   <module>   s   		8	