Ñò
à~,Jc        
   @   sµ   d  d k  Z  d  d k Z d  d k Z d  d k Z d  d k Td  d k Td  d k l Z d  d k Z e i	 ƒ  Z
 d Z d Z e  i d ƒ Z e  i d ƒ Z d „  Z d	 „  Z d
 „  Z d S(   iÿÿÿÿN(   t   *(   t   OptionParsers	   /bin/greps   /bin/cats   \+s   \-c      
   C   sn   xg |  D]_ } | d } | | } y+ t  i d t | | | f ƒ o ‚  n Wq t i i d ƒ q Xq Wd  S(   Ns   [[:space:]]s   %s %s %s > %ss   grep failed
(   t   ost   systemt   grept   syst   stderrt   write(   t   chromst   filet	   extensiont   chromt   matcht   tmpFile(    (    sK   /woldlab/castor/data00/home/georgi/SICER_v1.01/SICER/lib/SeparateByChrom.pyt   separateByChrom"   s     

	  c      	   C   sz   t  | d ƒ } | i ƒ  xZ |  D]R } | | } y( t i d t | | f ƒ o ‚  n Wq  t i i d ƒ q  Xq  W| S(   sN   
		Combine the seperately processed chromosomes, return the output file name
	t   ws   %s %s >> %ss   cat failed
(   t   opent   closeR   R   t   catR   R   R   (   R   R
   t	   final_outt   outfileR   R	   (    (    sK   /woldlab/castor/data00/home/georgi/SICER_v1.01/SICER/lib/SeparateByChrom.pyt   combineAllGraphFiles,   s    
 
	  c         C   sX   xQ |  D]I } | | } y t  i d | ƒ o ‚  n Wq t i i d ƒ q Xq Wd  S(   Ns   %ss   clean up failed
(   R   t   removeR   R   R   (   R   R
   R   R	   (    (    sK   /woldlab/castor/data00/home/georgi/SICER_v1.01/SICER/lib/SeparateByChrom.pyt   cleanup<   s     
	  (   t   reR   R   t   shutilt   matht   stringt   optparseR   t   operatort   getcwdt   DirR   R   t   compilet   plust   minusR   R   R   (    (    (    sK   /woldlab/castor/data00/home/georgi/SICER_v1.01/SICER/lib/SeparateByChrom.pyt   <module>   s   0

	
	