3
D^<                 @   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                   sD   e Zd Z fddZdd Zdd Zdd Zd	d
 Zdd Z  Z	S )Executorc                s   t t| j| d S )N)superr   __init__)selflog)	__class__ n/home/psgendb/BIRCHDEV/pkg/SPAdes-3.15.4/linux-x86_64/share/spades/spades_pipeline/executors/executor_local.pyr      s    zExecutor.__init__c             C   s<  x4t t|D ]"}|| }tjjrhtj||j}tjj	|rhd|jkrhd|jkrh| j
jd|j  qd|jkr| j
jd|j  |j dkr| j
jd|j   |j| j
 | j| | j| d|jkr| j
jd|j  | j|| tjj|jksd|jkrtjj|jjdd	 kr| j
jd
tjj  P qW d S )NZ_startZ_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
)rangelenoptions_storageargscontinue_modeget_stage_filename
short_name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   s2    






zExecutor.executec             C   s`   t jjrd S xN|jD ]D}tjjt jj|}tjj|rBt	j
| qtjj|rtj| qW d S )N)r   r   no_clear_afterZ	del_afterr   r   join
output_dirisdirshutilrmtreer   remove)r   r!   fpathZ	fpath_absr   r   r	   r   7   s    zExecutor.rm_filesc             C   s4   x.|j D ]$}tjj|stj|jd|   qW d S )Nz# finished abnormally: %s not found!)output_filesr   r   r   supporterrorr   )r   r!   r+   r   r   r	   r   B   s    zExecutor.check_outputc             C   s   t j|| d S )N)commands_parserZwrite_commands_to_sh)r   r   Z
outputfiler   r   r	   dump_commandsG   s    zExecutor.dump_commandsc             C   sF   t j||j}tjjtjj|s4tjtjj| t|dj	  d S )Na)
r   r   r   r   r   existsdirnamemakedirsopenclose)r   r!   r    r   r   r   r	   r   J   s    zExecutor.touch_file)
__name__
__module____qualname__r   r#   r   r   r0   r   __classcell__r   r   )r   r	   r      s   "r   )r   r(   r-   	executorsr/   r   ZExecutorBaser   r   r   r   r	   <module>	   s   