Skip to content

Commit

Permalink
updated unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kbessonov1984 committed Dec 23, 2023
1 parent ad6aada commit 1400ab4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
11 changes: 6 additions & 5 deletions mob_suite/tests/test_mobrecon.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
LOG_FORMAT = '%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]'
logging.basicConfig(format=LOG_FORMAT, level=logging.DEBUG)

if not os.path.exists(os.path.join(TEST_ROOT,"run_test")):
os.mkdir(os.path.join(TEST_ROOT,"run_test"))
def check_if_output_dir_exists_and_create():
if not os.path.exists(os.path.join(TEST_ROOT,"run_test")):
os.mkdir(os.path.join(TEST_ROOT,"run_test"))


def test_mob_recon_with_mob_typer_report():
if os.path.exists("run_test") == False:
os.mkdir("run_test")
check_if_output_dir_exists_and_create()
#IncFIB,IncFII multi-plasmids
args = [
"--infile", os.path.dirname(__file__) + "/TestData/Pseudomonas/test_contigs.fasta",
Expand All @@ -28,7 +28,7 @@ def test_mob_recon_with_mob_typer_report():
assert sum(1 for line in open(mobtyper_results_file)) == 2 , "Results file is empty, something went wrong"

def test_mob_recon_no_plasmid_biomarkers():

check_if_output_dir_exists_and_create()
args = [
"--infile", ROOT_MODULE + "/example/assembly_no_biomarkers.fasta",
"--outdir", TEST_ROOT + "/run_test/mob_recon_no_plasmid_markers",
Expand All @@ -41,6 +41,7 @@ def test_mob_recon_no_plasmid_biomarkers():
assert os.path.exists(os.path.join(TEST_ROOT,"run_test/mob_recon_no_plasmid_markers/biomarker_report.txt")) == False

def test_mob_recon_typical_run():
check_if_output_dir_exists_and_create()
args = [
"--infile", ROOT_MODULE + "/example/SRR3703080_illumina_unicycler.fasta",
"--outdir", TEST_ROOT+"/run_test/mob_recon_SRR3703080",
Expand Down
6 changes: 4 additions & 2 deletions mob_suite/tests/test_mobtyper.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
logger=logging.getLogger(__name__)
logger.setLevel(logging.INFO)

def check_if_output_dir_exists_and_create():
if not os.path.exists(os.path.join(TEST_ROOT,"run_test")):
os.mkdir(os.path.join(TEST_ROOT,"run_test"))

def test_mean_and_multireplicon_frame():
logger.info("Testing MOB-typer")
if os.path.exists("run_test") == False:
os.mkdir("run_test")
check_if_output_dir_exists_and_create()
args = [
"--infile", os.path.dirname(__file__) + "/TestData/pCAV1453-208.fasta",
"--out_file", TEST_ROOT + "/run_test/mobtyper_pCAV1453-208_results.txt",
Expand Down
7 changes: 5 additions & 2 deletions mob_suite/tests/test_mobtyper_vs_biomarker_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@
def clean_missing_dashes(L):
return [i for i in L if i != '-']

def check_if_output_dir_exists_and_create():
if not os.path.exists(os.path.join(TEST_ROOT,"run_test")):
os.mkdir(os.path.join(TEST_ROOT,"run_test"))


def test_mean_and_multireplicon_frame(mode = None):
if os.path.exists("run_test") == False:
os.mkdir("run_test")
check_if_output_dir_exists_and_create()

if mode == None:
return 0
Expand Down

0 comments on commit 1400ab4

Please sign in to comment.