text: user3839: I was trying to run a slurm job script inside nextflow process. Is it possible? For instance, I have a job script 'PRE_PHASING_QC.JOB' and outside nextflow it runs perfectly, I want to integrate it in a nextflow script. May be my example code could be an explanation of what I want.
  prephase='PRE_PHASING_QC.JOB'
  process prephasing {
  input:
  file(prephasing) from prephase
  """
  sbatch "${prephasing}
  """
  }
  
  The error:
  sbatch: error: This does not look like a batch script
  ...
  
  I tried to make my job script executable, put it in bin and then include it in the nextflow process according to @Steve. So, the script runs without any error but got no output. The original job script takes 3 files (bed,bim,fam) as input and produce multiple outputs. I guess that I have to declare outputs inside nextflow process. So far I tried as follows:
  process prephasing {
  publishDir params.out, mode: 'copy'
  output:
  tuple val(chr),val(num),val(steps),path("${chr}${num}.${steps}.{bed,bim,fam,log}") into out1
  script:
  """
  PRE_PHASING_QC.job
  """
  
  It gives:
  Error executing process > 'prephasing'
  Caused by:
  Missing value declared as output parameter: chr
  
  My expected output would be chr{1-22}.step{1-10}.{bed,bim,fam,log}
  #!/bin/bash 
  #SBATCH --job-name=prephase 
  #SBATCH --account=p697_norment 
  #SBATCH --time=1:00:00 
  #SBATCH --ntasks=1 
  #SBATCH --mem-per-cpu=7600M 
  #SBATCH --cpus-per-task=7 
  #SBATCH --array=1-22 
  
  source /cluster/bin/jobsetup 
  
  set -o errexit 
  
  module load plink 
  
  export prefix=chr${SLURM_ARRAY_TASK_ID} 
  export hrc_sites_file=/cluster/projects/p697/projects/moba_qc_imputation/resources/HRC/HRC.r1-1.GRCh37.wgs.mac5.sites.tab.gz 
  export HRC_1000G_check_bim=/cluster/projects/p697/github/norment/moba_qc_imputation/software/HRC-1000G-check-bim.pl
  
  # Step 1a (exclude duplicated), 1b (exclude indels and non-ACTG alleles), 1c (exclude ambiguous SNPs) 
  
  plink --bfile hce-ec-eur-fin-pass-qc --chr ${SLURM_ARRAY_TASK_ID} --out $prefix --make-bed || true
  plink --bfile $prefix --list-duplicate-vars ids-only suppress first --out $prefix.stepla || true 
  plink --bfile $prefix --exclude $prefix.stepla.dupvar --make-bed --out $prefix.stepla || true 
  plink --bfile $prefix.stepla --snps-only just-acgt --make-bed --out $prefix.steplb || true 
  
  awk '{ if (($5=="T" && $6=="A")||($5=="A" && $6=="T")ii($5=="C" && $6=="G")||($5=="G" && $6=="C")) print $2, "ambig" ; else print $2 ;}' $prefix. steplb.bim | grep ambig > $prefix.steplb.snplist.txt || true 
  plink --bfile $prefix.steplb --exclude $prefix.steplb.snplist.txt --make-bed --out $prefix.steplc || true 
  
  # Step 2. Zero out Mendelian errors
  plink --bfile $prefix.steplc --me 1 1 --set-me-missing --make-bed --out $prefix.step2 || true 
  
  # Step 3. Missingness and HWE + Step 4. Compute allele frequencies 
  # NB! --mind 0.02 filter is removed from the next command, to avoid sample QC per chunk, which may leave inconsistent number of individuals avail able per chunk. 
  plink --bfile $prefix.step2 --hwe le-6 --geno 0.02 --make-bed --out $prefix.step3 || true 
  plink --bfile $prefix.step3 --freq --make-bed --out $prefix.step4 || true 
  
  # Step 4-10. Run Oxford perl script and apply first 5 lines of its Run-plink.sh command, followed by '--update-name' command (update marker name s) 
  perl ${HRC-IRC_1000G_check_bim} -b $prefix.step4.bim -f $prefix.step4.frq -r ${hrc_sites_file} -h || true 
  plink --bfile $prefix.step4 --exclude Exclude-$prefix.step4-HRC.txt --make-bed --out $prefix.step5 || true 
  plink --bfile $prefix.step5 --update-chr Chromosome-$prefix.step4-HRC.txt --make-bed --out $prefix.step6 || true 
  plink --bfile $prefix.step6 --update-map Position-$prefix.step4-HRC.txt --make-bed --out $prefix.step7 || true 
  plink --bfile $prefix.step7 --flip Strand-Flip-$prefix.step4-HRC.txt --make-bed --out $prefix.step8 || true 
  plink --bfile $prefix.step8 --a2-allele Force-Allele1-$prefix.step4-HRC.txt --make-bed --out $prefix.step9 || true 
  plink --bfile $prefix.step9 --update-name ID-$prefix.step4-HRC.txt --real-ref-alleles --make-bed --out $prefix.step10 || true
  
  
  user10775: Using Nextflow to submit jobs this way makes little sense, since:
  
  sbatch exits immediately after the script is successfully transferred
  to the Slurm controller and assigned a Slurm job ID. The batch script
  is not necessarily granted resources immediately, it may sit in the
  queue of pending jobs for some time before its required resources
  become available.
  
  Assuming your job script is basically a shell script, make it executable (e.g. chmod +x PRE_PHASING_QC.JOB) and move it into a folder called bin in the root directory of your project repository. Nextflow automatically adds this folder to your $PATH, making scripts in this folder accessible in your pipeline without needing localize them and without needing to specify an absolute path to invoke them. Your code then becomes:
  process prephasing {
  
      """
      PRE_PHASING_QC.JOB [options] <args>
      """
  }
  
  Finally, add process.executor = 'slurm' to your nextflow.config file. You may need to configure some other options, like resource requests, but that should get your script integrated into your pipeline without much refactoring, if any.
  
  
  Contents of PRE_PHASING_QC.sh:
  #!/bin/bash
  
  set -euo pipefail
  
  hrc_sites_file="${1}"
  input_prefix="${2}"
  chrom="chr${3}"
  
  # Step 1a (exclude duplicated), 1b (exclude indels and non-ACTG alleles), 1c (exclude ambiguous SNPs)
  
  plink --bfile "${input_prefix}" --chr "${3}" --out "${chrom}" --make-bed
  plink --bfile "${chrom}" --list-duplicate-vars ids-only suppress first --out "${chrom}.step1a"
  plink --bfile "${chrom}" --exclude "${chrom}.step1a.dupvar" --make-bed --out "${chrom}.step1a"
  plink --bfile "${chrom}.step1a" --snps-only just-acgt --make-bed --out "${chrom}.step1b"
  
  awkcmd='
  ($5 == "T" && $6 == "A") || ($5 == "A" && $6 == "T") ||
  ($5 == "C" && $6 == "G") || ($5 == "G" && $6 == "C")
  {
      print $2, "ambig"
      next
  }
  {
      print $2
  }'
  
  awk "${awkcmd}" "${chrom}.step1b" | grep "ambig" > "${chrom}.step1b.snplist.txt"
  plink --bfile "${chrom}.step1b" --exclude "${chrom}.step1b.snplist.txt" --make-bed --out "${chrom}.step1c"
  
  # Step 2. Zero out Mendelian errors
  plink --bfile "${chrom}.step1c" --me 1 1 --set-me-missing --make-bed --out "${chrom}.step2"
  
  # Step 3. Missingness and HWE + Step 4. Compute allele frequencies
  # NB! --mind 0.02 filter is removed from the next command, to avoid sample QC per chunk, which may leave inconsistent number of individuals avail able per chunk.
  plink --bfile "${chrom}.step2" --hwe 1e-6 --geno 0.02 --make-bed --out "${chrom}.step3"
  plink --bfile "${chrom}.step3" --freq --make-bed --out "${chrom}.step4"
  
  # Step 4-10. Run Oxford perl script and apply first 5 lines of its Run-plink.sh command, followed by '--update-name' command (update marker name s)
  HRC-1000G-check-bim.pl -b "${chrom}.step4.bim" -f "${chrom}.step4.frq" -r "${hrc_sites_file}" -h
  plink --bfile "${chrom}.step4" --exclude "Exclude-${chrom}.step4-HRC.txt" --make-bed --out "${chrom}.step5"
  plink --bfile "${chrom}.step5" --update-chr "Chromosome-${chrom}.step4-HRC.txt" --make-bed --out "${chrom}.step6"
  plink --bfile "${chrom}.step6" --update-map "Position-${chrom}.step4-HRC.txt" --make-bed --out "${chrom}.step7"
  plink --bfile "${chrom}.step7" --flip "Strand-Flip-${chrom}.step4-HRC.txt" --make-bed --out "${chrom}.step8"
  plink --bfile "${chrom}.step8" --a2-allele "Force-Allele1-${chrom}.step4-HRC.txt" --make-bed --out "${chrom}.step9"
  plink --bfile "${chrom}.step9" --update-name "ID-${chrom}.step4-HRC.txt" --real-ref-alleles --make-bed --out "${chrom}.step10"
  
  
  Make PRE_PHASING_QC.sh executable (chmod +x PRE_PHASING_QC.sh), and replace your job script with the following. This file won't be needed by your Nextflow process, but shows you how the above shell script can be invoked:
  #!/bin/bash
  #SBATCH --job-name=prephase
  #SBATCH --account=p697_norment
  #SBATCH --time=1:00:00
  #SBATCH --ntasks=1
  #SBATCH --mem-per-cpu=7600M
  #SBATCH --cpus-per-task=7
  #SBATCH --array=1-22
  
  set -e
  
  . /cluster/bin/jobsetup
  
  export PATH="/cluster/projects/p697/github/norment/moba_qc_imputation/software:${PATH}"
  
  module load plink
  
  cd /path/to/hce-ec-eur-fin-pass-qc
  
  /path/to/PRE_PHASING_QC.sh \
      /cluster/projects/p697/projects/moba_qc_imputation/resources/HRC/HRC.r1-1.GRCh37.wgs.mac5.sites.tab.gz \
      hce-ec-eur-fin-pass-qc \
      "${SLURM_ARRAY_TASK_ID}"
  
  Copy PRE_PHASING_QC.sh and the Oxford Perl script, HRC-1000G-check-bim.pl, into your project's bin/ directory. You may also need to make the Perl script executable. Then your Nextflow process becomes:
  hrc_sites_file = file(params.hrc_sites_file)
  
  Channel
      .fromFilePairs( "${params.input_dir}/*.{bed,bim,fam}", size:3 )
      .set { plink_data }
  
  Channel
      .of(1..22)
      .set { chroms }
  
  
  process prephasing {
  
      input:
      tuple val(prefix), path(bfiles) from plink_data
      each chrom from chroms
      path hrc_sites_file
  
      """
      PRE_PHASING_QC.sh "${hrc_sites_file}" "${prefix}" "${chrom}"
      """
  }
  
  Once the above runs successfully, you can declare your process outputs. Please note that none of the above was tested; hopefully not too many typos, but YMMV.
  
original_text: 3839: <p><a href="https://i.stack.imgur.com/2dD9s.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2dD9s.png" alt="enter image description here" /></a><a href="https://i.stack.imgur.com/A23k1.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/A23k1.jpg" alt="enter image description here" /></a>I was trying to run a slurm job script inside nextflow process. Is it possible? For instance, I have a job script 'PRE_PHASING_QC.JOB' and outside nextflow it runs perfectly, I want to integrate it in a nextflow script. May be my example code could be an explanation of what I want.</p>
  <pre><code>prephase='PRE_PHASING_QC.JOB'
  process prephasing {
  input:
  file(prephasing) from prephase
  &quot;&quot;&quot;
  sbatch &quot;${prephasing}
  &quot;&quot;&quot;
  }
  </code></pre>
  <p>The error:</p>
  <pre><code>sbatch: error: This does not look like a batch script
  ...
  </code></pre>
  <p>I tried to make my job script executable, put it in bin and then include it in the nextflow process according to @Steve. So, the script runs without any error but got no output. The original job script takes 3 files (bed,bim,fam) as input and produce multiple outputs. I guess that I have to declare outputs inside nextflow process. So far I tried as follows:</p>
  <pre><code>process prephasing {
  publishDir params.out, mode: 'copy'
  output:
  tuple val(chr),val(num),val(steps),path(&quot;<span class="math-container">${chr}$</span>{num}.${steps}.{bed,bim,fam,log}&quot;) into out1
  script:
  &quot;&quot;&quot;
  PRE_PHASING_QC.job
  &quot;&quot;&quot;
  </code></pre>
  <p>It gives:</p>
  <pre><code>Error executing process &gt; 'prephasing'
  Caused by:
  Missing value declared as output parameter: chr
  </code></pre>
  <p>My expected output would be chr{1-22}.step{1-10}.{bed,bim,fam,log}</p>
  <pre><code>#!/bin/bash 
  #SBATCH --job-name=prephase 
  #SBATCH --account=p697_norment 
  #SBATCH --time=1:00:00 
  #SBATCH --ntasks=1 
  #SBATCH --mem-per-cpu=7600M 
  #SBATCH --cpus-per-task=7 
  #SBATCH --array=1-22 
  
  source /cluster/bin/jobsetup 
  
  set -o errexit 
  
  module load plink 
  
  export prefix=chr${SLURM_ARRAY_TASK_ID} 
  export hrc_sites_file=/cluster/projects/p697/projects/moba_qc_imputation/resources/HRC/HRC.r1-1.GRCh37.wgs.mac5.sites.tab.gz 
  export HRC_1000G_check_bim=/cluster/projects/p697/github/norment/moba_qc_imputation/software/HRC-1000G-check-bim.pl
  
  # Step 1a (exclude duplicated), 1b (exclude indels and non-ACTG alleles), 1c (exclude ambiguous SNPs) 
  
  plink --bfile hce-ec-eur-fin-pass-qc --chr <span class="math-container">${SLURM_ARRAY_TASK_ID} --out $</span>prefix --make-bed || true
  plink --bfile <span class="math-container">$prefix --list-duplicate-vars ids-only suppress first --out $</span>prefix.stepla || true 
  plink --bfile <span class="math-container">$prefix --exclude $</span>prefix.stepla.dupvar --make-bed --out <span class="math-container">$prefix.stepla || true 
  plink --bfile $</span>prefix.stepla --snps-only just-acgt --make-bed --out $prefix.steplb || true 
  
  awk '{ if ((<span class="math-container">$5=="T" &amp;&amp; $</span>6==&quot;A&quot;)||(<span class="math-container">$5=="A" &amp;&amp; $</span>6==&quot;T&quot;)ii(<span class="math-container">$5=="C" &amp;&amp; $</span>6==&quot;G&quot;)||(<span class="math-container">$5=="G" &amp;&amp; $</span>6==&quot;C&quot;)) print <span class="math-container">$2, "ambig" ; else print $</span>2 ;}' <span class="math-container">$prefix. steplb.bim | grep ambig &gt; $</span>prefix.steplb.snplist.txt || true 
  plink --bfile <span class="math-container">$prefix.steplb --exclude $</span>prefix.steplb.snplist.txt --make-bed --out $prefix.steplc || true 
  
  # Step 2. Zero out Mendelian errors
  plink --bfile <span class="math-container">$prefix.steplc --me 1 1 --set-me-missing --make-bed --out $</span>prefix.step2 || true 
  
  # Step 3. Missingness and HWE + Step 4. Compute allele frequencies 
  # NB! --mind 0.02 filter is removed from the next command, to avoid sample QC per chunk, which may leave inconsistent number of individuals avail able per chunk. 
  plink --bfile <span class="math-container">$prefix.step2 --hwe le-6 --geno 0.02 --make-bed --out $</span>prefix.step3 || true 
  plink --bfile <span class="math-container">$prefix.step3 --freq --make-bed --out $</span>prefix.step4 || true 
  
  # Step 4-10. Run Oxford perl script and apply first 5 lines of its Run-plink.sh command, followed by '--update-name' command (update marker name s) 
  perl <span class="math-container">${HRC-IRC_1000G_check_bim} -b $</span>prefix.step4.bim -f <span class="math-container">$prefix.step4.frq -r $</span>{hrc_sites_file} -h || true 
  plink --bfile <span class="math-container">$prefix.step4 --exclude Exclude-$</span>prefix.step4-HRC.txt --make-bed --out <span class="math-container">$prefix.step5 || true 
  plink --bfile $</span>prefix.step5 --update-chr Chromosome-<span class="math-container">$prefix.step4-HRC.txt --make-bed --out $</span>prefix.step6 || true 
  plink --bfile <span class="math-container">$prefix.step6 --update-map Position-$</span>prefix.step4-HRC.txt --make-bed --out <span class="math-container">$prefix.step7 || true 
  plink --bfile $</span>prefix.step7 --flip Strand-Flip-<span class="math-container">$prefix.step4-HRC.txt --make-bed --out $</span>prefix.step8 || true 
  plink --bfile <span class="math-container">$prefix.step8 --a2-allele Force-Allele1-$</span>prefix.step4-HRC.txt --make-bed --out <span class="math-container">$prefix.step9 || true 
  plink --bfile $</span>prefix.step9 --update-name ID-<span class="math-container">$prefix.step4-HRC.txt --real-ref-alleles --make-bed --out $</span>prefix.step10 || true
  </code></pre>
   10775: <p>Using Nextflow to submit jobs this way makes little sense, since:</p>
  <blockquote>
  <p><a href="https://slurm.schedmd.com/sbatch.html" rel="nofollow noreferrer">sbatch</a> exits immediately after the script is successfully transferred
  to the Slurm controller and assigned a Slurm job ID. The batch script
  is not necessarily granted resources immediately, it may sit in the
  queue of pending jobs for some time before its required resources
  become available.</p>
  </blockquote>
  <p>Assuming your job script is basically a shell script, make it executable (e.g. <code>chmod +x PRE_PHASING_QC.JOB</code>) and move it into a folder called <code>bin</code> in the root directory of your project repository. <a href="https://www.nextflow.io/docs/latest/sharing.html#third-party-scripts" rel="nofollow noreferrer">Nextflow automatically adds this folder to your $PATH</a>, making scripts in this folder accessible in your pipeline without needing localize them and without needing to specify an absolute path to invoke them. Your code then becomes:</p>
  <pre><code>process prephasing {
  
      &quot;&quot;&quot;
      PRE_PHASING_QC.JOB [options] &lt;args&gt;
      &quot;&quot;&quot;
  }
  </code></pre>
  <p>Finally, add <code>process.executor = 'slurm'</code> to your <code>nextflow.config</code> file. You may need to configure some other options, like resource requests, but that should get your script integrated into your pipeline without much refactoring, if any.</p>
  <hr />
  <hr />
  <p>Contents of <code>PRE_PHASING_QC.sh</code>:</p>
  <pre><code>#!/bin/bash
  
  set -euo pipefail
  
  hrc_sites_file=&quot;<span class="math-container">${1}"
  input_prefix="$</span>{2}&quot;
  chrom=&quot;chr${3}&quot;
  
  # Step 1a (exclude duplicated), 1b (exclude indels and non-ACTG alleles), 1c (exclude ambiguous SNPs)
  
  plink --bfile &quot;<span class="math-container">${input_prefix}" --chr "$</span>{3}&quot; --out &quot;<span class="math-container">${chrom}" --make-bed
  plink --bfile "$</span>{chrom}&quot; --list-duplicate-vars ids-only suppress first --out &quot;<span class="math-container">${chrom}.step1a"
  plink --bfile "$</span>{chrom}&quot; --exclude &quot;<span class="math-container">${chrom}.step1a.dupvar" --make-bed --out "$</span>{chrom}.step1a&quot;
  plink --bfile &quot;<span class="math-container">${chrom}.step1a" --snps-only just-acgt --make-bed --out "$</span>{chrom}.step1b&quot;
  
  awkcmd='
  (<span class="math-container">$5 == "T" &amp;&amp; $</span>6 == &quot;A&quot;) || (<span class="math-container">$5 == "A" &amp;&amp; $</span>6 == &quot;T&quot;) ||
  (<span class="math-container">$5 == "C" &amp;&amp; $</span>6 == &quot;G&quot;) || (<span class="math-container">$5 == "G" &amp;&amp; $</span>6 == &quot;C&quot;)
  {
      print <span class="math-container">$2, "ambig"
      next
  }
  {
      print $</span>2
  }'
  
  awk &quot;<span class="math-container">${awkcmd}" "$</span>{chrom}.step1b&quot; | grep &quot;ambig&quot; &gt; &quot;<span class="math-container">${chrom}.step1b.snplist.txt"
  plink --bfile "$</span>{chrom}.step1b&quot; --exclude &quot;<span class="math-container">${chrom}.step1b.snplist.txt" --make-bed --out "$</span>{chrom}.step1c&quot;
  
  # Step 2. Zero out Mendelian errors
  plink --bfile &quot;<span class="math-container">${chrom}.step1c" --me 1 1 --set-me-missing --make-bed --out "$</span>{chrom}.step2&quot;
  
  # Step 3. Missingness and HWE + Step 4. Compute allele frequencies
  # NB! --mind 0.02 filter is removed from the next command, to avoid sample QC per chunk, which may leave inconsistent number of individuals avail able per chunk.
  plink --bfile &quot;<span class="math-container">${chrom}.step2" --hwe 1e-6 --geno 0.02 --make-bed --out "$</span>{chrom}.step3&quot;
  plink --bfile &quot;<span class="math-container">${chrom}.step3" --freq --make-bed --out "$</span>{chrom}.step4&quot;
  
  # Step 4-10. Run Oxford perl script and apply first 5 lines of its Run-plink.sh command, followed by '--update-name' command (update marker name s)
  HRC-1000G-check-bim.pl -b &quot;<span class="math-container">${chrom}.step4.bim" -f "$</span>{chrom}.step4.frq&quot; -r &quot;<span class="math-container">${hrc_sites_file}" -h
  plink --bfile "$</span>{chrom}.step4&quot; --exclude &quot;Exclude-<span class="math-container">${chrom}.step4-HRC.txt" --make-bed --out "$</span>{chrom}.step5&quot;
  plink --bfile &quot;<span class="math-container">${chrom}.step5" --update-chr "Chromosome-$</span>{chrom}.step4-HRC.txt&quot; --make-bed --out &quot;<span class="math-container">${chrom}.step6"
  plink --bfile "$</span>{chrom}.step6&quot; --update-map &quot;Position-<span class="math-container">${chrom}.step4-HRC.txt" --make-bed --out "$</span>{chrom}.step7&quot;
  plink --bfile &quot;<span class="math-container">${chrom}.step7" --flip "Strand-Flip-$</span>{chrom}.step4-HRC.txt&quot; --make-bed --out &quot;<span class="math-container">${chrom}.step8"
  plink --bfile "$</span>{chrom}.step8&quot; --a2-allele &quot;Force-Allele1-<span class="math-container">${chrom}.step4-HRC.txt" --make-bed --out "$</span>{chrom}.step9&quot;
  plink --bfile &quot;<span class="math-container">${chrom}.step9" --update-name "ID-$</span>{chrom}.step4-HRC.txt&quot; --real-ref-alleles --make-bed --out &quot;${chrom}.step10&quot;
  
  </code></pre>
  <p>Make <code>PRE_PHASING_QC.sh</code> executable (<code>chmod +x PRE_PHASING_QC.sh</code>), and replace your job script with the following. This file won't be needed by your Nextflow process, but shows you how the above shell script can be invoked:</p>
  <pre><code>#!/bin/bash
  #SBATCH --job-name=prephase
  #SBATCH --account=p697_norment
  #SBATCH --time=1:00:00
  #SBATCH --ntasks=1
  #SBATCH --mem-per-cpu=7600M
  #SBATCH --cpus-per-task=7
  #SBATCH --array=1-22
  
  set -e
  
  . /cluster/bin/jobsetup
  
  export PATH=&quot;/cluster/projects/p697/github/norment/moba_qc_imputation/software:${PATH}&quot;
  
  module load plink
  
  cd /path/to/hce-ec-eur-fin-pass-qc
  
  /path/to/PRE_PHASING_QC.sh \
      /cluster/projects/p697/projects/moba_qc_imputation/resources/HRC/HRC.r1-1.GRCh37.wgs.mac5.sites.tab.gz \
      hce-ec-eur-fin-pass-qc \
      &quot;${SLURM_ARRAY_TASK_ID}&quot;
  </code></pre>
  <p>Copy <code>PRE_PHASING_QC.sh</code> and the Oxford Perl script, <code>HRC-1000G-check-bim.pl</code>, into your project's <code>bin/</code> directory. You may also need to make the Perl script executable. Then your Nextflow process becomes:</p>
  <pre><code>hrc_sites_file = file(params.hrc_sites_file)
  
  Channel
      .fromFilePairs( &quot;${params.input_dir}/*.{bed,bim,fam}&quot;, size:3 )
      .set { plink_data }
  
  Channel
      .of(1..22)
      .set { chroms }
  
  
  process prephasing {
  
      input:
      tuple val(prefix), path(bfiles) from plink_data
      each chrom from chroms
      path hrc_sites_file
  
      &quot;&quot;&quot;
      PRE_PHASING_QC.sh &quot;<span class="math-container">${hrc_sites_file}" "$</span>{prefix}&quot; &quot;${chrom}&quot;
      &quot;&quot;&quot;
  }
  </code></pre>
  <p>Once the above runs successfully, you can declare your process outputs. Please note that none of the above was tested; hopefully not too many typos, but YMMV.</p>
  