// Import generic module functions
include { saveFiles; getSoftwareName } from './functions'

params.options = [:]

/*
 * Fetch SRA / ENA / GEO run information via the ENA API
 */
process SRA_IDS_TO_RUNINFO {
    tag "$id"
    label 'error_retry'
    publishDir "${params.outdir}",
        mode: params.publish_dir_mode,
        saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), publish_id:'') }

    conda     (params.enable_conda ? "conda-forge::sed=4.7" : null)
    container "biocontainers/biocontainers:v1.2.0_cv1"
    
    input:
    val id
    
    output:
    path "*.tsv", emit: tsv
    
    script:
    """
    echo $id > id.txt
    sra_ids_to_runinfo.py id.txt ${id}.runinfo.tsv
    """
}
