Closed Vini2 closed 20 hours ago
I'm also happy to do this issue @Vini2 !
Hi @YapengLang! Feel free to tackle this issue. Thanks!
hi @Vini2 ,
I tried to write tests for invoking MetaCoAG on spades and megahit, but I met some warnings I didn't understand very well.
I followed the instructions provided in this issue. When I ran pytest for test_cli_metacoag.py
, two warning messages were raised from my tests for MetaCoAG on megahit, after the tests on spades finished. But such warnings disappeared if I ran two test functions one by one. The following is how to reproduce:
import pathlib
import pytest
from click.testing import CliRunner
from gbintk.cli import metacoag
DATADIR = pathlib.Path(__file__).parent / "data"
@pytest.fixture(scope="session")
def tmp_dir(tmpdir_factory):
return tmpdir_factory.mktemp("tmp")
@pytest.fixture(autouse=True)
def workingdir(tmp_dir, monkeypatch):
"""set the working directory for all tests"""
monkeypatch.chdir(tmp_dir)
@pytest.fixture(scope="session")
def runner():
"""exportrc works correctly."""
return CliRunner()
def test_metacoag_spades_run(runner, tmp_dir):
outpath = tmp_dir
graph = DATADIR / "5G_metaSPAdes" / "assembly_graph_with_scaffolds.gfa"
contigs = DATADIR / "5G_metaSPAdes" / "contigs.fasta"
paths = DATADIR / "5G_metaSPAdes" / "contigs.paths"
abundance = DATADIR / "5G_metaSPAdes" / "coverm_mean_coverage.tsv"
args = f"--assembler spades --graph {graph} --contigs {contigs} --paths {paths} --abundance {abundance} --output {outpath}".split()
r = runner.invoke(metacoag, args, catch_exceptions=False)
assert r.exit_code == 0, r.output
def test_metacoag_megahit_run(runner, tmp_dir):
outpath = tmp_dir
graph = DATADIR / "5G_MEGAHIT" / "final.gfa"
contigs = DATADIR / "5G_MEGAHIT" / "final.contigs.fa"
abundance = DATADIR / "5G_MEGAHIT" / "abundance.tsv"
args = f"--assembler megahit --graph {graph} --contigs {contigs} --abundance {abundance} --output {outpath}".split()
r = runner.invoke(metacoag, args, catch_exceptions=False)
assert r.exit_code == 0, r.output
traceback:
tests/test_cli_metacoag.py::test_metacoag_megahit_run
/Users/yapenglang/miniconda3/envs/gbintk/lib/python3.12/site-packages/metacoag/metacoag_utils/matching_utils.py:192: RuntimeWarning: Couldn't reach some vertices at src/paths/unweighted.c:444
shortest_paths = assembly_graph.get_shortest_paths(
tests/test_cli_metacoag.py::test_metacoag_megahit_run
/Users/yapenglang/miniconda3/envs/gbintk/lib/python3.12/site-packages/metacoag/metacoag_utils/matching_utils.py:286: RuntimeWarning: Couldn't reach some vertices at src/paths/unweighted.c:444
shortest_paths = assembly_graph.get_shortest_paths(
I tried to set the scope of fixture tmp_dir
as scope="function"
, but problem not solved.
Thank you for any suggestions!
Hi @YapengLang!
This warning should not be an issue. It's popping up because some of the vertices are not reachable because they have no connections. Feel free to ignore them.
Add tests for MetaCoAG in
gbintk
.MetaCoAG on spades
File name:
test_cli_metacoag.py
Function name:test_metacoag_spades_run
Inputs: file names in the
tests/data/5G_metaSPAdes
directory.assembly_graph_with_scaffolds.gfa
contigs.fasta
contigs.paths
coverm_mean_coverage.tsv
tmp_dir
How to invoke:
MetaCoAG on megahit
File name:
test_cli_metacoag.py
Function name:test_metacoag_megahit_run
Inputs: file names in the
tests/data/5G_MEGAHIT
directory.final.gfa
final.contigs.fa
abundance.tsv
tmp_dir
How to invoke:
MetaCoAG on flye
File name:
test_cli_metacoag.py
Function name:test_metacoag_flye_run
Inputs: file names in the
tests/data/1Y3B_Flye
directory.assembly_graph.gfa
assembly.fasta
assembly_info.txt
abundance.tsv
tmp_dir
How to invoke: