Skip to content

Commit

Permalink
Fix strain and variantcalling testing
Browse files Browse the repository at this point in the history
  • Loading branch information
aghozlane committed Sep 2, 2024
1 parent 6ff0703 commit 01195fc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
4 changes: 0 additions & 4 deletions meteor/tests/test_strain.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ def test_filter_coverage(
strain_builder.meteor.ref_dir / "database" / "mock.bed",
strain_builder.meteor.ref_dir / "fasta" / "mock.fasta.gz",
)
filtered_cov.to_csv("/pasteur/zeus/projets/p01/BioIT/amine/filtered.tsv", sep="\t")
expected_output = pd.read_table(datadir / "expected_output" / "filtered_cov.tsv")
expected_output.to_csv(
"/pasteur/zeus/projets/p01/BioIT/amine/expected.tsv", sep="\t"
)
assert filtered_cov.reset_index(drop=True).equals(expected_output)


Expand Down
16 changes: 4 additions & 12 deletions meteor/tests/test_variantcalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
import json
from pysam import AlignmentFile, FastaFile
import pandas as pd
import shutil

# from subprocess import run
from pandas.testing import assert_frame_equal
from hashlib import md5

Expand All @@ -32,6 +29,7 @@ def fixture_vc_builder(datadir: Path, tmp_path: Path) -> VariantCalling:
meteor.ref_name = "test"
meteor.threads = 1
meteor.tmp_dir = tmp_path
meteor.DEFAULT_GAP_CHAR = "?"
ref_json_file = datadir / "eva71" / "eva71_reference.json"
ref_json = {}
with ref_json_file.open("rt", encoding="UTF-8") as ref:
Expand Down Expand Up @@ -103,7 +101,8 @@ def test_create_consensus(
) -> None:
vc_builder.matrix_file = datadir / "eva71_bench" / "eva71_bench.tsv.xz"
reference_file = datadir / "eva71" / "fasta" / "eva71.fasta.gz"
consensus_file = tmp_path / "consensus.fasta.xz"
# consensus_file = tmp_path / "consensus.fasta.xz"
consensus_file = Path("/pasteur/appa/homes/aghozlan/consensus2.fasta.xz")
bed_file = datadir / "eva71" / "database" / "eva71.bed"
vcf_file = datadir / "eva71_bench" / "eva71_bench.vcf.gz"
low_cov_sites = pd.read_table(
Expand All @@ -119,15 +118,8 @@ def test_create_consensus(
bed_file,
)
assert consensus_file.exists()

# print(consensus_file)
with consensus_file.open("rb") as consensus:
if md5(consensus.read()).hexdigest() == "916fe0018af1eebc59592a75c770570b":
output_path = "/pasteur/appa/homes/aghozlan/consensus1.fasta.xz"
else:
output_path = "/pasteur/appa/homes/aghozlan/consensus2.fasta.xz"
with open(output_path, "wb") as output:
shutil.copyfileobj(consensus, output)
assert md5(consensus.read()).hexdigest() == "916fe0018af1eebc59592a75c770570b"


def test_execute(vc_builder: VariantCalling) -> None:
Expand Down

0 comments on commit 01195fc

Please sign in to comment.