From c2fec15c8a1d4bc0814a299a1fb08ac00451173d Mon Sep 17 00:00:00 2001 From: pdimens Date: Tue, 7 May 2024 11:13:02 -0400 Subject: [PATCH] simplify the split code with bcftools --- src/harpy/rules/phase.smk | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/harpy/rules/phase.smk b/src/harpy/rules/phase.smk index 9bc141e8d..cb478324d 100644 --- a/src/harpy/rules/phase.smk +++ b/src/harpy/rules/phase.smk @@ -70,8 +70,7 @@ rule split_by_samplehet: "Extracting heterozygous variants: {wildcards.sample}" shell: """ - bcftools view -s {wildcards.sample} {input.vcf} | - awk '/^#/;/CHROM/ {{OFS="\\t"}}; !/^#/ && $10~/^0\\/1/' > {output} + bcftools view -s {wildcards.sample} -Ou {input.vcf} | bcftools view -i 'GT="het"' > {output} """ rule split_by_sample: @@ -88,8 +87,7 @@ rule split_by_sample: "Extracting variants: {wildcards.sample}" shell: """ - bcftools view -s {wildcards.sample} {input.vcf} | - awk '/^#/;/CHROM/ {{OFS="\\t"}}; !/^#/ && $10~/^0\\/0/ {{$10="0|0:"substr($10,5);print $0}}; !/^#/ && $10~/^0\\/1/; !/^#/ && $10~/^1\\/1/ {{$10="1|1:"substr($10,5);print $0}}; !/^#/ {{print $0}}' > {output} + bcftools view -s {wildcards.sample} -Ou {input.vcf} | bcftools view -i 'GT="hom"' > {output} """ rule index_alignment: