Skip to content

Commit

Permalink
🚧 try awk as bash command
Browse files Browse the repository at this point in the history
  • Loading branch information
migbro committed Oct 18, 2024
1 parent ac60a67 commit 08b5c2f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
7 changes: 7 additions & 0 deletions scripts/bcftools_amend_header.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# script to use bcftools to amend the header in ploidy-adjusted file
set -xeo pipefail

input_vcf=$1
mod_vcf=$2
awk 'NR == FNR && $line ~ /^##GATKCommandLine.HaplotypeCaller/ {sub(/Caller,/, "Caller_rpt_subset,") newcmd=$line}; NR != FNR; NR != FNR && $line ~ /^##GATKCommandLine.HaplotypeCaller/ {print newcmd}' <(bcftools head $mod_vcf) <(bcftools head $input_vcf) > header_build.txt
25 changes: 13 additions & 12 deletions tools/bcftools_amend_vcf_header.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,27 @@ requirements:
- class: InlineJavascriptRequirement
- class: InitialWorkDirRequirement
listing:
- entryname: "amend_header.sh"
entry: |
#!/usr/bin/env bash
set -xeo pipefail

bcftools head $(inputs.input_vcf.path) | head -n -1 > header_build.txt
bcftools head $(inputs.mod_vcf.path) | grep GATK | sed 's/Caller,/Caller_rpt_subset,/' >> header_build.txt
bcftools head $(inputs.input_vcf.path) | tail -n 1 >> header_build.txt
bcftools reheader --threads $(inputs.threads) -h header_build.txt $(inputs.input_vcf.path) > $(inputs.output_basename).ploidy_mod.g.vcf.gz
- writable: false
entryname: "bcftools_amend_header.sh"
entry:
$include: ../scripts/bcftools_amend_header.sh

baseCommand: []
arguments:
- position: 0
shellQuote: false
valueFrom: >-
/bin/bash amend_header.sh
/bin/bash bcftools_amend_header.sh
- position: 3
shellQuote: false
valueFrom: >-
&& bcftools reheader --threads $(inputs.threads) -h header_build.txt $(inputs.input_vcf.path) > $(inputs.output_basename).ploidy_mod.g.vcf.gz

inputs:
input_vcf: { type: File, secondaryFiles: ['.tbi'], doc: "Reconstituted VCF with modified ploidy region calls" }
mod_vcf: { type: File, secondaryFiles: ['.tbi'], doc: "VCF with modified region cals only. Header will be used to modift input_vcf" }
input_vcf: { type: File, secondaryFiles: ['.tbi'], doc: "Reconstituted VCF with modified ploidy region calls",
inputBinding: { position: 1} }
mod_vcf: { type: File, secondaryFiles: ['.tbi'], doc: "VCF with modified region cals only. Header will be used to modift input_vcf",
inputBinding: {position: 2 } }
threads: { type: 'int?', default: 4 }
output_basename: string
outputs:
Expand Down

0 comments on commit 08b5c2f

Please sign in to comment.