Skip to content

Commit

Permalink
Merge pull request #163 from FrickTobias/variants
Browse files Browse the repository at this point in the history
Changed VCF file naming
  • Loading branch information
FrickTobias authored Nov 29, 2019
2 parents 7f6cfc3 + ad9b0c6 commit 338bbd6
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 28 deletions.
32 changes: 16 additions & 16 deletions src/blr/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -178,19 +178,19 @@ rule bam_to_fastq:
" -2 {output.r2_fastq} 2>> {log}"


if config["reference_variants"]:
rule link:
output: "reference.vcf"
shell:
"ln -s {config[reference_variants]} {output}"
else:
rule call_variants_freebayes:
output:
vcf = "reference.vcf"
input:
bam = "mapped.sorted.tag.mkdup.bcmerge.mol.filt.bam"
log: "call_variants_freebayes.log"
shell:
"freebayes"
" -f {config[genome_reference]}"
" {input.bam} 1> {output.vcf} 2> {log}"
rule symlink_reference_variants:
output: "variants.reference.vcf"
shell:
"ln -s {config[reference_variants]} {output}"


rule call_variants_freebayes:
output:
vcf = "variants.called.vcf"
input:
bam = "mapped.sorted.tag.mkdup.bcmerge.mol.filt.bam"
log: "call_variants_freebayes.log"
shell:
"freebayes"
" -f {config[genome_reference]}"
" {input.bam} 1> {output.vcf} 2> {log}"
8 changes: 5 additions & 3 deletions src/blr/rules/phasing.smk
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@

variants = "variants.reference.vcf" if config["reference_variants"] else "variants.called.vcf"

rule hapcut2_extracthairs:
output:
unlinked = "mapped.sorted.tag.mkdup.bcmerge.mol.filt.unlinked.txt"
input:
bam = "mapped.sorted.tag.mkdup.bcmerge.mol.filt.bam",
vcf = "reference.vcf"
vcf = variants
log: "hapcut2_extracthairs.log"
shell:
"extractHAIRS"
Expand All @@ -19,7 +21,7 @@ rule hapcut2_linkfragments:
linked = "mapped.sorted.tag.mkdup.bcmerge.mol.filt.linked.txt"
input:
bam = "mapped.sorted.tag.mkdup.bcmerge.mol.filt.bam",
vcf = "reference.vcf",
vcf = variants,
unlinked = "mapped.sorted.tag.mkdup.bcmerge.mol.filt.unlinked.txt"
log: "hapcut2_linkfragments.log"
shell:
Expand All @@ -36,7 +38,7 @@ rule hapcut2_phasing:
phased_vcf = "mapped.sorted.tag.mkdup.bcmerge.mol.filt.phase.phased.VCF"
input:
linked = "mapped.sorted.tag.mkdup.bcmerge.mol.filt.linked.txt",
vcf = "reference.vcf"
vcf = variants
log: "hapcut2_phasing.log"
shell:
"hapcut2"
Expand Down
26 changes: 17 additions & 9 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,25 @@ def test_final_compressed_reads_exist(tmpdir):
assert Path(workdir / filename).exists()


@pytest.mark.parametrize("reference_variants", [REFERENCE_VARIANTS, "null"])
def test_reference_variants(tmpdir, reference_variants):
def test_link_reference_variants(tmpdir):
workdir = tmpdir / "analysis"
init(workdir, TESTDATA_READS)
change_config(
workdir / DEFAULT_CONFIG,
[("genome_reference", REFERENCE_GENOME), ("reference_variants", reference_variants)]
[("genome_reference", REFERENCE_GENOME), ("reference_variants", REFERENCE_VARIANTS)]
)
target = "reference.vcf"
run(workdir=workdir, targets=["reference.vcf"])
if reference_variants != "null":
assert Path(workdir / target).is_symlink()
else:
assert Path(workdir / target).is_file()
target = "variants.reference.vcf"
run(workdir=workdir, targets=[target])
assert Path(workdir / target).is_symlink()


def test_call_variants(tmpdir):
workdir = tmpdir / "analysis"
init(workdir, TESTDATA_READS)
change_config(
workdir / DEFAULT_CONFIG,
[("genome_reference", REFERENCE_GENOME), ("reference_variants", "null")]
)
target = "variants.called.vcf"
run(workdir=workdir, targets=[target])
assert Path(workdir / target).is_file()

0 comments on commit 338bbd6

Please sign in to comment.