Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExpansionHunter extract sex from a ped file. #281

Merged
merged 14 commits into from
Jan 11, 2022
Merged
17 changes: 16 additions & 1 deletion wdl/ExpansionHunter.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ workflow ExpansionHunter {
File reference_fasta
File? reference_fasta_index
File variant_catalog
String? individual_id
VJalili marked this conversation as resolved.
Show resolved Hide resolved
File? ped_filename
VJalili marked this conversation as resolved.
Show resolved Hide resolved
File? output_prefix
String expansion_hunter_docker
RuntimeAttr? runtime_attr
Expand Down Expand Up @@ -52,6 +54,8 @@ workflow ExpansionHunter {
reference_fasta = reference_fasta,
reference_fasta_index = reference_fasta_index_,
variant_catalog = variant_catalog,
individual_id = individual_id,
ped_filename = ped_filename,
output_prefix = output_prefix_,
expansion_hunter_docker = expansion_hunter_docker,
runtime_attr_override = runtime_attr,
Expand All @@ -72,6 +76,8 @@ task RunExpansionHunter {
File reference_fasta
File reference_fasta_index
File variant_catalog
String? individual_id
File? ped_filename
VJalili marked this conversation as resolved.
Show resolved Hide resolved
String output_prefix
String expansion_hunter_docker
RuntimeAttr? runtime_attr_override
Expand All @@ -87,13 +93,22 @@ task RunExpansionHunter {
command <<<
set -euxo pipefail

sex=""
if [ ! -z "~{ped_filename}" -a "~{ped_filename}" != " " ]; then
if [ -e "~{ped_filename}" ]; then
VJalili marked this conversation as resolved.
Show resolved Hide resolved
sex=$(awk -F '\t' '{if ($2 == "~{individual_id}") {if ($5 == "1") {print "--sex male"; exit 0} else if ($5 == "2") {print "--sex female"; exit 0} else {exit 1}}}' < ~{ped_filename} )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would actually try to emit a helpful error message if the sex is undefined. I think it would be best to define sex="NA" if the ped file is provided. Then use print "NA"; exit 0 instead of exit 1 in the last if clause. Then check the value of sex below - if it's NA then warn that either the sample id was not found or the sex is undefined and fail.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check if the updated condition would be equally good.

fi
fi
echo $sex

ExpansionHunter \
--reads ~{bam_or_cram} \
--reference ~{reference_fasta} \
--variant-catalog ~{variant_catalog} \
--output-prefix ~{output_prefix} \
--cache-mates \
--record-timing
--record-timing \
$sex
>>>

RuntimeAttr runtime_attr_str_profile_default = object {
Expand Down
9 changes: 9 additions & 0 deletions wdl/ExpansionHunterScatter.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ workflow ExpansionHunterScatter {
Array[File] bams_or_crams
Array[File]? bams_or_crams_indexes
Array[String]? sample_ids
File? ped_filename
VJalili marked this conversation as resolved.
Show resolved Hide resolved
File reference_fasta
File? reference_fasta_index
File variant_catalog
Expand Down Expand Up @@ -37,13 +38,21 @@ workflow ExpansionHunterScatter {
else
basename(bam_or_cram_, ".cram")

String individual_id =
VJalili marked this conversation as resolved.
Show resolved Hide resolved
if defined(sample_ids) then
select_first([sample_ids])[i]
else
output_prefix

call ExpansionHunter.ExpansionHunter as expanionHunter {
input:
bam_or_cram=bam_or_cram_,
bam_or_cram_index=bam_or_cram_index_,
reference_fasta=reference_fasta,
reference_fasta_index=reference_fasta_index_,
variant_catalog=variant_catalog,
individual_id=individual_id,
ped_filename=ped_filename,
output_prefix=output_prefix,
expansion_hunter_docker=expansion_hunter_docker,
runtime_attr=runtime_attr
Expand Down