Skip to content

Commit

Permalink
Merge pull request #18 from TRON-Bioinformatics/bugfix-empty-vcf
Browse files Browse the repository at this point in the history
Bugfix: phasing on empty VCF
  • Loading branch information
priesgo authored Mar 17, 2022
2 parents 2656e96 + 21d74cc commit c24700f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
3 changes: 2 additions & 1 deletion bin/phasing.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def run(self):
variants_buffer.append(variant)

# writes last variant
variants_buffer.append(previous_variant)
if previous_variant:
variants_buffer.append(previous_variant)

# sorts the variants by position before writing them all
for variant in sorted(variants_buffer, key=lambda v: v.POS):
Expand Down
14 changes: 14 additions & 0 deletions bin/test_phasing.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ def test_phasing(self):
self.assertTrue(os.path.exists(output_vcf))
self._assert_vcf(output_vcf, 60)

def test_phasing_empty_vcf(self):
os.makedirs("./output/phasing", exist_ok=True)
output_vcf = "./output/phasing/test_data.merged.vcf.gz"
if os.path.exists(output_vcf):
os.remove(output_vcf)
ClonalHaploidPhaser(
input_vcf="./test_data/test_data.empty.vcf",
output_vcf=output_vcf,
input_gtf="./reference/Sars_cov_2.ASM985889v3.101.gff3",
input_fasta="./reference/Sars_cov_2.ASM985889v3.dna.toplevel.fa"
).run()
self.assertTrue(os.path.exists(output_vcf))
self._assert_vcf(output_vcf, 0)

def _assert_vcf(self, vcf, expected_count_variants):
vcf_reader = VCF(vcf)
count_variants = 0
Expand Down
2 changes: 1 addition & 1 deletion nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ process.shell = ['/bin/bash', '-euo', 'pipefail']
cleanup = true
conda.createTimeout = '1 h'

VERSION = '0.9.1'
VERSION = '0.9.2'

manifest {
name = 'TRON-Bioinformatics/covigator-ngs-pipeline'
Expand Down

0 comments on commit c24700f

Please sign in to comment.