ó
vIc           @   sa   d  Z  d d l Z d d l Z d d l Z d d l m Z d d l m Z d d d     YZ d S(   s.   
This module allows you to control Simcoal2.

i’’’’N(   t   copyfile(   t   debugt   SimCoalControllerc           B   s    e  Z d    Z d d d  Z RS(   c         C   sŠ   | |  _  t j |  _ t j |  j   } |  j d k sE t j d k rp d |  _ g  | D] } | j   ^ qU } n	 d |  _ |  j | k rĄ t j	 |  j  t j
 |  j t j  sĢ t d   qĢ n t d   d S(   s¹   Initializes the controller.
        
        simcoal_dir is the directory where simcoal is.
        
        The initializer checks for existance and executability of binaries.
        t   ntt   cygwins   simcoal2.exet   simcoal2s   SimCoal not executables   SimCoal not availableN(   t   simcoal_dirt   ost   namet   os_namet   listdirt   syst   platformt   bin_namet   lowert   accesst   sept   X_OKt   IOError(   t   selfR   t   dir_contentst   x(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PopGen/SimCoal/Controller.pyt   __init__   s    		"	t   1t   .c         C   sæ   | d k r- t j j t j d d g  } n  t j   } t j |  |  j t j |  j	 d | d t
 |  d | } t j d k r | d 7} n
 | d 7} t j |  t j |  d S(   s   Executes SimCoal.
        t   SimCoalt   runst    t   win32s    > nul 2>nuls    >/dev/null 2>&1N(   t   NoneR   R   t   joint   Configt   dataDirt   getcwdt   chdirR   R   t   strR   R   t   system(   R   t   par_filet   num_simst   ploydit   par_dirt   curr_dirt   cmd(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PopGen/SimCoal/Controller.pyt   run_simcoal+   s    !5
(   t   __name__t
   __module__R   R+   (    (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PopGen/SimCoal/Controller.pyR      s   	(    (	   t   __doc__R   R   t   tempfilet   shutilR    t   loggingR   R   (    (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PopGen/SimCoal/Controller.pyt   <module>	   s   