a
    Èhä  ã                   @   sF   d dl Z d dlZd dlZd dlZd dlZd dlZG dd„ dejƒZdS )é    Nc                       sT   e Zd Z‡ fdd„Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
‡  ZS )ÚExecutorc                    s   t t| ƒ |¡ d S ©N)Úsuperr   Ú__init__)ÚselfÚlog©Ú	__class__© úw/home/psgendb/BIRCHDEV/install/SPAdes-4.2.0-Linux/linux-x86_64/share/spades/spades_pipeline/executors/executor_local.pyr      s    zExecutor.__init__c                 C   s2  t |ƒD ]"\}}t ||j¡}tjjr\tj |¡r\d|jvr\d|jvr\| j	 
d|j ¡ qd|jvrx| j	 
d|j ¡ | ¡ dkr¤| j	 
d| ¡  ¡ | | j	¡ |  |¡ |  |¡ d|jvrÔ| j	 
d|j ¡ |  ||¡ tjj|jksd|jv rtjj|j d¡d	 kr| j	 
d
tjj ¡  d S qd S )NÚ_startÚ_finishz%===== Skipping %s (already processed)z
===== %s started. 
Útruez
== Running: %s
z
===== %s finished. 
Ú_r   z
======= Skipping the rest of SPAdes pipeline (--stop-after was set to '%s'). You can continue later with --continue or --restart-from options
)Ú	enumerateÚoptions_storageÚget_stage_filenameÚ
short_nameÚargsÚcontinue_modeÚosÚpathÚisfiler   ÚinfoÚSTAGEÚ__str__ÚrunÚrm_filesÚcheck_outputÚ
touch_fileÚ
stop_afterÚsplit)r   ÚcommandsÚnumÚcommandÚstage_checkpoint_pathr
   r
   r   Úexecute   s<    ÿþ



ÿþýzExecutor.executec                 C   s\   t jjrd S |jD ]D}tj t jj|¡}tj |¡r@t	 
|¡ qtj |¡rt |¡ qd S r   )r   r   Úno_clear_afterÚ	del_afterr   r   ÚjoinÚ
output_dirÚisdirÚshutilÚrmtreer   Úremove)r   r$   ÚfpathZ	fpath_absr
   r
   r   r   8   s    
zExecutor.rm_filesc                 C   s0   |j D ]$}tj |¡st |jd|  ¡ qd S )Nz# finished abnormally: %s not found!)Úoutput_filesr   r   r   ÚsupportÚerrorr   )r   r$   r/   r
   r
   r   r   C   s    
zExecutor.check_outputc                 C   s   t  ||¡ d S r   )Úcommands_parserÚwrite_commands_to_sh)r   r"   Ú
outputfiler
   r
   r   Údump_commandsH   s    zExecutor.dump_commandsc                 C   sF   t  ||j¡}tj tj |¡¡s4t tj |¡¡ t|dƒ 	¡  d S )NÚa)
r   r   r   r   r   ÚexistsÚdirnameÚmakedirsÚopenÚclose)r   r$   r#   r   r
   r
   r   r   K   s    zExecutor.touch_filec                 C   s   |d u sJ ‚d S r   r
   ©r   Újob_namer
   r
   r   r)   Q   s    zExecutor.joinc                 C   s   |d u sJ ‚d S r   r
   r=   r
   r
   r   ÚkillT   s    zExecutor.kill)Ú__name__Ú
__module__Ú__qualname__r   r&   r   r   r6   r   r)   r?   Ú__classcell__r
   r
   r   r   r      s   "r   )r   r,   r1   Ú	executorsr3   r   ÚExecutorBaser   r
   r
   r
   r   Ú<module>
   s   