Skip to content
Snippets Groups Projects
Commit 45a7d392 authored by Amandine  PERRIN's avatar Amandine PERRIN
Browse files

Try removing first tests of align

parent 5cd2200a
No related branches found
No related tags found
No related merge requests found
Pipeline #39663 failed
......@@ -111,98 +111,98 @@ def setup_teardown_module():
# assert "END" in " ".join(log_content)
def test_main_exist_ok():
"""
Test main all files exist and are ok, no force -> end without error, with warnings on re-use
"""
corepers = os.path.join(TESTPATH, "test_pers0.99FX.lst")
list_genomes = os.path.join("test", "data", "pangenome", "test_files", "list_to_pan.txt")
dname = "TEST4exists"
dbpath = os.path.join("test", "data", "pangenome", "test_files", "example_db")
outdir = os.path.join(GENEPATH, "test_main_exist_ok")
threads = 1
force = False
cmd = "cmd test_main_exist_ok"
# Create output directories and files
aldir = os.path.join(outdir, "Align-" + dname)
listdir = os.path.join(outdir, "List-" + dname)
treedir = os.path.join(outdir, "Phylo-" + dname)
os.makedirs(aldir)
os.makedirs(listdir)
os.makedirs(treedir)
# Create content of listdir
ex_listdir = os.path.join(EXPPATH, "exp_listdir-pers")
genomes = ["GEN2.1017.00001", "GEN4.1111.00001", "GENO.1017.00001", "GENO.1216.00002"]
for gen in genomes:
outgen = os.path.join(listdir, f"{dname}-getEntry_gen_{gen}.txt")
refgen = os.path.join(ex_listdir, f"getEntry_gen_{gen}")
shutil.copyfile(refgen, outgen)
outprt = os.path.join(listdir, f"{dname}-getEntry_prt_{gen}.txt")
refprt = os.path.join(ex_listdir, f"getEntry_prt_{gen}")
shutil.copyfile(refprt, outprt)
# Create content of aldir
ex_aldir = os.path.join(EXPPATH, "exp_aldir-pers")
fams = [1, 4, 6, 8, 10, 11, 13, 14]
for fam in fams:
outgen = os.path.join(aldir, f'{dname}-current.{fam}.gen')
refgen = os.path.join(ex_aldir, f"current.{fam}.gen")
shutil.copyfile(refgen, outgen)
outprt = os.path.join(aldir, f'{dname}-current.{fam}.prt')
refprt = os.path.join(ex_aldir, f"current.{fam}.prt")
shutil.copyfile(refprt, outprt)
outmiss = os.path.join(aldir, f'{dname}-current.{fam}.miss.lst')
refmiss = os.path.join(ex_aldir, f"current.{fam}.miss.lst")
shutil.copyfile(refmiss, outmiss)
outaln = os.path.join(aldir, f'{dname}-mafft-align.{fam}.aln')
refaln = os.path.join(ex_aldir, f"mafft-align.{fam}.aln")
shutil.copyfile(refaln, outaln)
outbtr = os.path.join(aldir, f'{dname}-mafft-prt2nuc.{fam}.aln')
refbtr = os.path.join(ex_aldir, f"mafft-prt2nuc.{fam}.aln")
shutil.copyfile(refbtr, outbtr)
outcat = os.path.join(aldir, dname + "-complete.cat.aln")
refcat = os.path.join(EXPPATH, "exp_pers4genome-complete.cat.aln")
shutil.copyfile(refcat, outcat)
# Create content of treedir
outgrp = os.path.join(treedir, dname + ".grp.aln")
refgrp = os.path.join(EXPPATH, "exp_pers4genomes.grp.aln")
shutil.copyfile(refgrp, outgrp)
# Run align module
al.main(cmd, corepers, list_genomes, dname, dbpath, outdir, threads, force)
# Check logs
logfile = os.path.join(outdir, "PanACoTA-align_TEST4exists.log.details")
with open(logfile, "r") as lc:
log_content = lc.readlines()
assert ("Reading PersGenome and constructing lists of missing genomes in "
"each family") in " ".join(log_content)
for gen in genomes:
assert (f"For genome {gen}, test/data/align/generated_by_func_tests/test_main_exist_ok/"
f"List-TEST4exists/TEST4exists-getEntry_prt_{gen}.txt and test/data/align/"
"generated_by_func_tests/test_main_exist_ok/List-TEST4exists/"
f"TEST4exists-getEntry_gen_{gen}.txt already exist. The program "
"will use them to extract proteins and genes. If you prefer to rewrite "
"them, use option -F ") in " ".join(log_content)
assert ("Starting alignment of all families: protein alignment, back-translation to "
"nucleotides, and add missing genomes in the family") in " ".join(log_content)
for fam in fams:
assert "Checking extractions for family {}".format(fam) in " ".join(log_content)
assert ("Alignment already done for family {}. The program will use it for next "
"steps").format(fam) in " ".join(log_content)
assert ("All extraction files already existing (see detailed log for more "
"information)") in " ".join(log_content)
assert ("All prt and gene files for all families already exist. The program will use them "
"for the next step. If you want to re-extract a given family, remove its prt and "
"gen extraction files. If you want to re-extract all families, use option -F "
"(or --force).") in " ".join(log_content)
assert ("Alignments already concatenated in "
"test/data/align/generated_by_func_tests/test_main_exist_ok/Align-TEST4exists/"
"TEST4exists-complete.cat.aln. Program will "
"use it for next steps. If you want to redo it, remove it before "
"running.") in " ".join(log_content)
assert ("Alignments already grouped by genome in "
"test/data/align/generated_by_func_tests/test_main_exist_ok/Phylo-TEST4exists/"
"TEST4exists.grp.aln. Program will "
"end.") in " ".join(log_content)
assert "END" in " ".join(log_content)
# def test_main_exist_ok():
# """
# Test main all files exist and are ok, no force -> end without error, with warnings on re-use
# """
# corepers = os.path.join(TESTPATH, "test_pers0.99FX.lst")
# list_genomes = os.path.join("test", "data", "pangenome", "test_files", "list_to_pan.txt")
# dname = "TEST4exists"
# dbpath = os.path.join("test", "data", "pangenome", "test_files", "example_db")
# outdir = os.path.join(GENEPATH, "test_main_exist_ok")
# threads = 1
# force = False
# cmd = "cmd test_main_exist_ok"
# # Create output directories and files
# aldir = os.path.join(outdir, "Align-" + dname)
# listdir = os.path.join(outdir, "List-" + dname)
# treedir = os.path.join(outdir, "Phylo-" + dname)
# os.makedirs(aldir)
# os.makedirs(listdir)
# os.makedirs(treedir)
# # Create content of listdir
# ex_listdir = os.path.join(EXPPATH, "exp_listdir-pers")
# genomes = ["GEN2.1017.00001", "GEN4.1111.00001", "GENO.1017.00001", "GENO.1216.00002"]
# for gen in genomes:
# outgen = os.path.join(listdir, f"{dname}-getEntry_gen_{gen}.txt")
# refgen = os.path.join(ex_listdir, f"getEntry_gen_{gen}")
# shutil.copyfile(refgen, outgen)
# outprt = os.path.join(listdir, f"{dname}-getEntry_prt_{gen}.txt")
# refprt = os.path.join(ex_listdir, f"getEntry_prt_{gen}")
# shutil.copyfile(refprt, outprt)
# # Create content of aldir
# ex_aldir = os.path.join(EXPPATH, "exp_aldir-pers")
# fams = [1, 4, 6, 8, 10, 11, 13, 14]
# for fam in fams:
# outgen = os.path.join(aldir, f'{dname}-current.{fam}.gen')
# refgen = os.path.join(ex_aldir, f"current.{fam}.gen")
# shutil.copyfile(refgen, outgen)
# outprt = os.path.join(aldir, f'{dname}-current.{fam}.prt')
# refprt = os.path.join(ex_aldir, f"current.{fam}.prt")
# shutil.copyfile(refprt, outprt)
# outmiss = os.path.join(aldir, f'{dname}-current.{fam}.miss.lst')
# refmiss = os.path.join(ex_aldir, f"current.{fam}.miss.lst")
# shutil.copyfile(refmiss, outmiss)
# outaln = os.path.join(aldir, f'{dname}-mafft-align.{fam}.aln')
# refaln = os.path.join(ex_aldir, f"mafft-align.{fam}.aln")
# shutil.copyfile(refaln, outaln)
# outbtr = os.path.join(aldir, f'{dname}-mafft-prt2nuc.{fam}.aln')
# refbtr = os.path.join(ex_aldir, f"mafft-prt2nuc.{fam}.aln")
# shutil.copyfile(refbtr, outbtr)
# outcat = os.path.join(aldir, dname + "-complete.cat.aln")
# refcat = os.path.join(EXPPATH, "exp_pers4genome-complete.cat.aln")
# shutil.copyfile(refcat, outcat)
# # Create content of treedir
# outgrp = os.path.join(treedir, dname + ".grp.aln")
# refgrp = os.path.join(EXPPATH, "exp_pers4genomes.grp.aln")
# shutil.copyfile(refgrp, outgrp)
# # Run align module
# al.main(cmd, corepers, list_genomes, dname, dbpath, outdir, threads, force)
# # Check logs
# logfile = os.path.join(outdir, "PanACoTA-align_TEST4exists.log.details")
# with open(logfile, "r") as lc:
# log_content = lc.readlines()
# assert ("Reading PersGenome and constructing lists of missing genomes in "
# "each family") in " ".join(log_content)
# for gen in genomes:
# assert (f"For genome {gen}, test/data/align/generated_by_func_tests/test_main_exist_ok/"
# f"List-TEST4exists/TEST4exists-getEntry_prt_{gen}.txt and test/data/align/"
# "generated_by_func_tests/test_main_exist_ok/List-TEST4exists/"
# f"TEST4exists-getEntry_gen_{gen}.txt already exist. The program "
# "will use them to extract proteins and genes. If you prefer to rewrite "
# "them, use option -F ") in " ".join(log_content)
# assert ("Starting alignment of all families: protein alignment, back-translation to "
# "nucleotides, and add missing genomes in the family") in " ".join(log_content)
# for fam in fams:
# assert "Checking extractions for family {}".format(fam) in " ".join(log_content)
# assert ("Alignment already done for family {}. The program will use it for next "
# "steps").format(fam) in " ".join(log_content)
# assert ("All extraction files already existing (see detailed log for more "
# "information)") in " ".join(log_content)
# assert ("All prt and gene files for all families already exist. The program will use them "
# "for the next step. If you want to re-extract a given family, remove its prt and "
# "gen extraction files. If you want to re-extract all families, use option -F "
# "(or --force).") in " ".join(log_content)
# assert ("Alignments already concatenated in "
# "test/data/align/generated_by_func_tests/test_main_exist_ok/Align-TEST4exists/"
# "TEST4exists-complete.cat.aln. Program will "
# "use it for next steps. If you want to redo it, remove it before "
# "running.") in " ".join(log_content)
# assert ("Alignments already grouped by genome in "
# "test/data/align/generated_by_func_tests/test_main_exist_ok/Phylo-TEST4exists/"
# "TEST4exists.grp.aln. Program will "
# "end.") in " ".join(log_content)
# assert "END" in " ".join(log_content)
def test_main_exist_emptygrp(capsys):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment