Skip to content

Commit

Permalink
simplify the split code with bcftools
Browse files Browse the repository at this point in the history
  • Loading branch information
pdimens committed May 7, 2024
1 parent c6118c5 commit c2fec15
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/harpy/rules/phase.smk
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit c2fec15

Please sign in to comment.