Skip to content

Commit

Permalink
Merge pull request #14 from kids-first/bug/mb-fix-hard-filter
Browse files Browse the repository at this point in the history
🐛 fix hard filter
  • Loading branch information
migbro authored May 20, 2024
2 parents c380c66 + 9b27571 commit f777ca0
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 37 deletions.
2 changes: 1 addition & 1 deletion docs/dockers_consensus.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
TOOL|DOCKER
-|-
bcftools_annotate.cwl|pgc-images.sbgenomics.com/d3b-bixu/vcfutils:latest
bcftools_filter_vcf.cwl|pgc-images.sbgenomics.com/d3b-bixu/bvcftools:latest
bcftools_filter_vcf.cwl|pgc-images.sbgenomics.com/d3b-bixu/bcftools:1.20
bcftools_strip_ann.cwl|pgc-images.sbgenomics.com/d3b-bixu/vcfutils:latest
echtvar_anno.cwl|pgc-images.sbgenomics.com/d3b-bixu/echtvar:0.2.0
generic_rename_outputs.cwl|None
Expand Down
2 changes: 1 addition & 1 deletion docs/dockers_somatic.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
TOOL|DOCKER
-|-
add_strelka2_fields.cwl|pgc-images.sbgenomics.com/d3b-bixu/add-strelka2-fields:1.0.0
bcftools_filter_vcf.cwl|pgc-images.sbgenomics.com/d3b-bixu/bvcftools:latest
bcftools_filter_vcf.cwl|pgc-images.sbgenomics.com/d3b-bixu/bcftools:1.20
bcftools_strip_ann.cwl|pgc-images.sbgenomics.com/d3b-bixu/vcfutils:latest
echtvar_anno.cwl|pgc-images.sbgenomics.com/d3b-bixu/echtvar:0.2.0
gatk_variant_filter.cwl|pgc-images.sbgenomics.com/d3b-bixu/gatk:4.1.1.0
Expand Down
71 changes: 40 additions & 31 deletions tools/bcftools_filter_vcf.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,55 @@ doc: "More generic tool to take in an include expression and optionally an exclu
requirements:
- class: ShellCommandRequirement
- class: DockerRequirement
dockerPull: 'pgc-images.sbgenomics.com/d3b-bixu/bvcftools:latest'
dockerPull: 'pgc-images.sbgenomics.com/d3b-bixu/bcftools:1.20'
- class: ResourceRequirement
ramMin: 1000
coresMin: 1
ramMin: 16000
coresMin: 8
- class: InlineJavascriptRequirement
baseCommand: [bash -c 'set -eo pipefail &&]
- class: InitialWorkDirRequirement
listing:
- entryname: "run_filter.sh"
entry: |
#!/usr/bin/env bash
set -xeo pipefail

command=cat
if [[ $(inputs.sample_name) != null ]]
then
command="bcftools view --threads $(inputs.threads) -s $(inputs.sample_name)"
fi
$command $(inputs.input_vcf.path) \
| bcftools view \
--threads $(inputs.threads) \
-O $(inputs.output_type) \
-o $(inputs.output_basename).bcf_filtered.$(inputs.output_type == "v" ? "vcf" : inputs.output_type == "z" ? "vcf.gz" : inputs.output_type == "b" ? "bcf.gz" : "bcf") \
$(inputs.exclude_expression == null ? "" : "--exclude " + "'" + inputs.exclude_expression + "'") \
$(inputs.include_expression == null ? "" : "--include " + "'" + inputs.include_expression + "'") \
$(inputs.filter_expression == null ? "" : "-f " + inputs.filter_expression)
if [[ $(inputs.output_type) == z ]]
then
tabix $(inputs.output_basename).bcf_filtered.vcf.gz
fi

baseCommand: []
arguments:
- position: 1
- position: 0
shellQuote: false
valueFrom: >-
${
var out_base = inputs.output_basename;
if (out_base == null){
out_base = inputs.input_vcf.nameroot + ".bcf_filtered"
}
var cmd = "bcftools view ";
if (inputs.include_expression != null){
cmd += "--include \"" + inputs.include_expression + "\" " + inputs.input_vcf.path;
if (inputs.exclude_expression != null){
cmd += " | bcftools view --exclude \"" + inputs.exclude_expression + "\"' -O z > " + out_base + ".vcf.gz;";
} else {
cmd += " -O z > " + out_base + ".vcf.gz;";
}
} else if (inputs.include_expression == null && inputs.exclude_expression != null){
cmd += "--exclude \"" + inputs.exclude_expression + "\" " + inputs.input_vcf.path + " -O z > " + out_base + ".vcf.gz;";
} else if (inputs.include_expression == null && inputs.exclude_expression == null){
cmd = "cp " + inputs.input_vcf.path + " ./" + out_base + ".vcf.gz;";
}
cmd += "tabix " + out_base + ".vcf.gz;'"
return cmd;
}
/bin/bash run_filter.sh

inputs:
input_vcf: File
include_expression: ['null', string]
exclude_expression: ['null', string]
output_basename: ['null', string]
include_expression: { type: 'string?', doc: "See bcftools docs for valid expression. Can't be used at the same time as exclude_expression. Use double quotes when a string needs to be quoted"}
threads: { type: 'int?', default: 4 }
exclude_expression: { type: 'string?', doc: "See bcftools docs for valid expression. Can't be used at the same time as include_expression. Use double quotes when a string needs to be quoted"}
filter_expression: { type: 'string?', doc: "Add values from FILTER field to subset on"}
output_type: { type: [ 'null', {type: enum, name: output_type, symbols: [ "u", "b", "v", "z"]}]}
sample_name: { type: 'string?', doc: "csv string of samples if user wishes to apply filtering to and output specific samples"}
output_basename: string
outputs:
filtered_vcf:
type: File
outputBinding:
glob: '*.vcf.gz'
secondaryFiles: [.tbi]
glob: "*.{v,b}cf{,.gz}"
secondaryFiles: ['.tbi?']
5 changes: 3 additions & 2 deletions tools/kf_mskcc_vcf2maf.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ arguments:
- position: 1
shellQuote: false
valueFrom: >-
$(inputs.input_vcf.path) > input_file.vcf
> input_file.vcf
&& perl vcf2maf.pl
--input-vcf input_file.vcf
--output-maf $(inputs.output_basename).$(inputs.tool_name).vep.maf

inputs:
reference: { type: 'File', secondaryFiles: [.fai], doc: "Fasta genome assembly with index",
inputBinding: {position: 2, prefix: "--ref-fasta"} }
input_vcf: { type: 'File', secondaryFiles: [.tbi], doc: "VEP annotated vcf file." }
input_vcf: { type: File, doc: "VEP annotated vcf file.",
inputBinding: { position: 0 } }
output_basename: string
tumor_id: { type: string, inputBinding: {position: 3, prefix: "--tumor-id"} }
normal_id: { type: string, inputBinding: {position: 4, prefix: "--normal-id"} }
Expand Down
2 changes: 1 addition & 1 deletion workflows/kfdrc-germline-snv-annot-workflow.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,6 @@ sbg:license: Apache License 2.0
sbg:publisher: KFDRC

"sbg:links":
- id: 'https://github.com/kids-first/kids-first/kf-annotation-tools/releases/tag/v1.1.0'
- id: 'https://github.com/kids-first/kids-first/kf-annotation-tools/releases/tag/v1.2.2'
label: github-release

2 changes: 1 addition & 1 deletion workflows/kfdrc-somatic-snv-annot-workflow.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -352,5 +352,5 @@ $namespaces:
"sbg:license": Apache License 2.0
"sbg:publisher": KFDRC
"sbg:links":
- id: 'https://github.com/kids-first/kf-annotation-tools/releases/tag/v1.2.1'
- id: 'https://github.com/kids-first/kf-annotation-tools/releases/tag/v1.2.2'
label: github-release

0 comments on commit f777ca0

Please sign in to comment.