
    5i6                     \    d dl mZmZmZmZmZmZ ddlZddlZddl	m
Z
 	 	 	 	 	 	 ddZddZy)	   )get_template_dirget_source_file_nameget_resources_subpathis_importer_jobget_regional_optionsget_resources_dir_name    N)TOOLKIT_VERSIONc                    | g } t        t        j                  j                  t	        t                     d      d      5 }t        j                  |      }ddd       | d   z   |d<   t               |d   d<   t        |      }||dk(  rd}||d	<   ||d
<   ||d<   t        |||||      |d<   t        |d   d<   t        j                  j                  d      
t               sd|d   d<   |S # 1 sw Y   xY w)ai  
    :param custom_inputs: Custom inputs that will be used in the created Nextflow pipeline.
    :type custom_inputs: list
    :param resources_dir: Directory with all resources needed for the Nextflow pipeline. Usually directory with user's Nextflow files.
    :type resources_dir: str or Path
    :param region: The name of the region in which the applet will be built.
    :type region: str
    :param profile: Custom Nextflow profile. More profiles can be provided by using comma separated string (without whitespaces).
    :type profile: str
    :param cache_docker: Perform pipeline analysis and cache the detected docker images on the platform
    :type cache_docker: boolean
    :param nextflow_pipeline_params: Custom Nextflow pipeline parameters
    :type nextflow_pipeline_params: string
    Creates Nextflow dxapp.json from the Nextflow dxapp.json template
    Nz
dxapp.jsonr	inputSpecrunSpecfile zNextflow pipelinenametitlesummaryregionalOptionsdetailsdxpyBuildVersion	DX_JOB_IDlocal
repository)openospathjoinstrr   jsonloadr   r   r   r
   environgetr   )	custom_inputsresources_dirregionprofilecache_dockernextflow_pipeline_paramsfdxappr   s	            /home/marpiech/ifpan-abm-pgxpred/analysis/marpiech-gwas-test/venv/lib/python3.12/site-packages/dxpy/nextflow/nextflow_templates.pyget_nextflow_dxappr,   
   s   0 	bggll3/12LA3	G 1		!&{);;E+35E)V "-0D|trz"E&ME'NE)3FM7T`bz{E
 ,;E)'(	zz~~k"*/2C)0i&L% s    C--C6c                    | g } t        t        j                  j                  t	        t                     t                     d      5 }|j                         }ddd       d}d}| D ]Y  }d|d   z  }|j                  d      dk(  rd|d   z  }|d	j                  |d         z  }|d
j                  |d   |d   |      z   }[ |rdj                  |      nd}	j                  d|      }|j                  d|	      }|j                  d|      }|j                  dt              }|j                  dt        |            }|S # 1 sw Y   xY w)a  
    :param custom_inputs: Custom inputs (as configured in nextflow_schema.json) that will be used in created runtime configuration and runtime params argument
    :type custom_inputs: list
    :param profile: Custom Nextflow profile to be used when running a Nextflow pipeline, for more information visit https://www.nextflow.io/docs/latest/config.html#config-profiles
    :type profile: string
    :param resources_dir: Directory with all source files needed to build an applet. Can be an absolute or a relative path.
    :type resources_dir: str or Path
    :returns: String containing the whole source file of an applet.
    :rtype: string

    Creates Nextflow source file from the Nextflow source file template
    Nr   r   z${%s}r   classr   zrdx://${DX_WORKSPACE_ID}:/$(echo ${%s} | jq .[$dnanexus_link] -r | xargs -I {} dx describe {} --json | jq -r .name)z--except {} za
        if [ -n "${}" ]; then
            applet_runtime_inputs+=(--{} "{}")
        fi
        z-profile {}z@@APPLET_RUNTIME_PARAMS@@z@@PROFILE_ARG@@z@@EXCLUDE_INPUT_DOWNLOAD@@z@@DXPY_BUILD_VERSION@@z@@RESOURCES_SUBPATH@@)r   r   r   r   r   r   r   readr"   formatreplacer
   r   )
r#   r&   r$   r)   srcexclude_input_downloadapplet_runtime_paramsivalueprofile_args
             r+   get_nextflow_srcr8   9   sh    	bggll3/124H4JKS	Q UVffh   01V9%55>V# IfIE"n&;&;AfI&FF" !6 9 F1V9ai/	!00 4;-&&w/K
++13H
IC
++'
5C
++24J
KC
++.
@C
++-/>@C J7 s   EE
)Nr   zaws:us-east-1r   Fr   )NNN)nextflow_utilsr   r   r   r   r   r   r   r   dxpyr
   r,   r8        r+   <module>r=      s9   \ \  	   !#,^*r<   