ó
,§xTc           @   s|   d  d l  Z  d  d l Z d  d l Z d  d l Z d  d l Z d	 Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d „  Z d S(
   iÿÿÿÿNg      à?c          C   sR   t  j d k r> d }  t  j j |  ƒ r+ |  St j j d ƒ n t j j d ƒ Sd  S(   Nt   nts   C:/WinCoot/runwincoot.bats   WinCoot not found.t   coot(   t   ost   namet   patht   existst   c4t   utilst	   put_errort   syspath(   t   default_path(    (    s5   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/c4/coot.pyt	   find_path
   s    c          C   se   t  ƒ  }  |  s d S|  j d d ƒ } y t j | d g ƒ } Wn t j k
 rZ d  } n X|  | f S(   Ns   runwincoot.bats   bin/coot-real.exes	   --version(   NN(   R   t   Nonet   replacet
   subprocesst   check_outputt   CalledProcessError(   t	   coot_patht   coot_for_vert   version_str(    (    s5   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/c4/coot.pyt   find_path_and_version   s    	
c         C   sx   d } |  r | d |  7} n  | r4 | d | 7} n  | rT | d t  | | ƒ 7} n  | rk | d | 7} n  t j | ƒ S(   Ns\           # coot script generated by dimple
        #set_nomenclature_errors_on_read("ignore")s"   
        molecule = read_pdb('%s')s>   
        set_rotation_centre(%g, %g, %g)
        set_zoom(30.)s,   
        set_view_quaternion(%g, %g, %g, %g)s£   
        mtz = '%s'
        map21 = make_and_draw_map(mtz, "2FOFCWT", "PH2FOFCWT", "", 0, 0)
        map11 = make_and_draw_map(mtz, "FOFCWT", "PHFOFCWT", "", 0, 1)(   t   view_as_quatt   textwrapt   dedent(   t   pdbt   mtzt   centert   towardt   text(    (    s5   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/c4/coot.pyt   basic_script"   s        c         C   s>  |  d  k s | d  k r d S| d |  d | d |  d | d |  d f } t j | d | d | d | d | d | d ƒ } | d | | d | | d | f } | d | d d f } | d | d | d d | d f } t j t d „  | Dƒ ƒ ƒ } | d | | d | | d | | d | f S(	   Ng        g      ð?i    i   i   c         s   s   |  ] } | | Vq d  S(   N(    (   t   .0t   a(    (    s5   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/c4/coot.pys	   <genexpr>?   s    i   (   g        g        g        g      ð?(   R   t   matht   sqrtt   sum(   t   p1t   p2t   dt   lengtht   prodt   quatt   qlen(    (    s5   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/c4/coot.pyR   5   s    3;'&c   
      C   s¤   |  \ } } } } | \ } } } }	 | | | |	 | | | | | | | |	 | | | | | | | |	 | | | | | |	 | | | | | | f S(   N(    (
   t   q1t   q2t   xt   yt   zt   wt   axt   ayt   azt   aw(    (    s5   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/c4/coot.pyt	   mult_quatC   s    c   
      C   s¼   t  |  | ƒ } | t | d t d t f ƒ t | t d d t f ƒ g } g  } d |  } xW t | ƒ D]I \ } } | d | 7} d | | d f }	 | d |	 7} | j |	 ƒ qe W| | f S(   Ng        s.   
set_rotation_centre(%g, %g, %g)
set_zoom(30.)s$   
set_view_quaternion(%g, %g, %g, %g)s   %sv%di   sX   
graphics_draw() # this is needed only for coot in --no-graphics mode
raster3d("%s.r3d")(   R   R4   t	   M_SQRT1_2t	   enumeratet   append(
   R   R   t   blobnamet   quat0t   quaternionst	   basenamest   scriptt   nR(   t   basename(    (    s5   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/c4/coot.pyt
   r3d_scriptL   s    
gÍ;fž æ?(   R   R    R   t   c4.utilsR   R   R5   R   R   R   R   R4   R?   (    (    (    s5   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/c4/coot.pyt   <module>   s   						