Skip to content

Commit

Permalink
Fix integration test to avoid garbage (#1212)
Browse files Browse the repository at this point in the history
  • Loading branch information
AliaksandrDziarkach authored Aug 4, 2023
1 parent 03b0041 commit 2da94fa
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 42 deletions.
22 changes: 8 additions & 14 deletions api/tests/integration/tests/bingo/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,13 @@ def searchSim(bingo, q, minSim, maxSim, metric=None):


indigo = Indigo()

if dir_exists(joinPathPy("out/basic", __file__)):
rmdir(joinPathPy("out/basic", __file__))
makedirs(joinPathPy("out/basic", __file__))
db_dir = joinPathPy("out/basic", __file__)
if dir_exists(db_dir):
rmdir(db_dir)
makedirs(db_dir)

print("*** Creating temporary database ****")
bingo = Bingo.createDatabaseFile(
indigo, joinPathPy("out", "basic"), "molecule", ""
)
bingo = Bingo.createDatabaseFile(indigo, db_dir, "molecule", "")
print(bingo.version())
m = indigo.loadMolecule("C1CCCCC1")
bingo.insert(m)
Expand All @@ -79,7 +77,7 @@ def searchSim(bingo, q, minSim, maxSim, metric=None):
bingo.close()

print("*** Loading existing database ****")
bingo = Bingo.loadDatabaseFile(indigo, joinPathPy("out", "basic"), "")
bingo = Bingo.loadDatabaseFile(indigo, db_dir, "")
m = indigo.loadMolecule("C1CCCCC1")
searchSim(bingo, m, 0.9, 1, "tanimoto")
searchSim(bingo, m, 0.9, 1, "tversky")
Expand Down Expand Up @@ -115,9 +113,7 @@ def searchSim(bingo, q, minSim, maxSim, metric=None):


print("*** Simple exact search ****")
bingo = Bingo.createDatabaseFile(
indigo, joinPathPy("out", "basic"), "molecule"
)
bingo = Bingo.createDatabaseFile(indigo, db_dir, "molecule")
mol1 = indigo.loadMolecule(
"ICCCCOC(=O)C1=CC([N+]([O-])=O)=C([N+]([O-])=O)C=C1"
)
Expand All @@ -129,9 +125,7 @@ def searchSim(bingo, q, minSim, maxSim, metric=None):
bingo.close()

print("*** Simple enumerate id ****")
bingo = Bingo.createDatabaseFile(
indigo, joinPathPy("out/basic", __file__), "molecule"
)
bingo = Bingo.createDatabaseFile(indigo, db_dir, "molecule")
mol = indigo.loadMolecule("CCCC")
bingo.insert(mol)
bingo.insert(mol)
Expand Down
2 changes: 1 addition & 1 deletion api/tests/integration/tests/bingo/bingo_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
)

bingo = Bingo.createDatabaseFile(
indigo, joinPathPy("tempdb", __file__), "molecule", ""
indigo, joinPathPy("out/tempdb", __file__), "molecule", ""
)

print("*** Insert molecules ***")
Expand Down
2 changes: 1 addition & 1 deletion api/tests/integration/tests/bingo/ext_fp.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def searchSimExt(bingo, q, minSim, maxSim, ext_fp, metric=None):
indigo = Indigo()

bingo = Bingo.createDatabaseFile(
indigo, joinPathPy("extfp", __file__), "molecule", ""
indigo, joinPathPy("out/extfp", __file__), "molecule", ""
)
print(bingo.version())
m = indigo.loadMolecule("C1CCCCC1")
Expand Down
2 changes: 1 addition & 1 deletion api/tests/integration/tests/bingo/gross_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

indigo = Indigo()
bingo = Bingo.createDatabaseFile(
indigo, joinPathPy("db_gross_mol", __file__), "molecule", ""
indigo, joinPathPy("out/db_gross_mol", __file__), "molecule", ""
)

for idx, mol in enumerate(
Expand Down
2 changes: 1 addition & 1 deletion api/tests/integration/tests/bingo/molecules.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def searchExact(bingo, q, options=""):

indigo = Indigo()
bingo = Bingo.createDatabaseFile(
indigo, joinPathPy("db_molecule", __file__), "molecule", ""
indigo, joinPathPy("out/db_molecule", __file__), "molecule", ""
)

index = 0
Expand Down
9 changes: 5 additions & 4 deletions api/tests/integration/tests/bingo/part_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,12 @@ def makeSearchExact(db, pid, query, options, output=None):
outPrint("PID {0}) Total count {1}".format(pid, cnt), pid, output)


db_dir = joinPathPy("out/mol_part_db", __file__)


def partCreate():
bingo = Bingo.createDatabaseFile(
indigo, joinPathPy("mol_part_db", __file__), "molecule", "mt_size:2000"
indigo, db_dir, "molecule", "mt_size:2000"
)

insertSmi(bingo, dataPath("molecules/basic/sample_100000.smi"))
Expand All @@ -75,9 +78,7 @@ def partCreate():


def partTest(size, searchType="sub"):
bingo = Bingo.loadDatabaseFile(
indigo, joinPathPy("mol_part_db", __file__), ""
)
bingo = Bingo.loadDatabaseFile(indigo, db_dir, "")
index = 0

for m in indigo.iterateSDFile(
Expand Down
2 changes: 1 addition & 1 deletion api/tests/integration/tests/bingo/reactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def searchExact(bingo, q, options=""):

indigo = Indigo()
bingo = Bingo.createDatabaseFile(
indigo, joinPathPy("db_reaction", __file__), "reaction", ""
indigo, joinPathPy("out/db_reaction", __file__), "reaction", ""
)

index = 0
Expand Down
27 changes: 10 additions & 17 deletions api/tests/integration/tests/bingo/threads_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
)
from env_indigo import * # noqa

db_dir1 = joinPathPy("out/mol_test_db1", __file__)
db_dir2 = joinPathPy("out/mol_test_db2", __file__)


def outPrint(s, pid, output):
# output = None
Expand Down Expand Up @@ -90,12 +93,8 @@ def makeSearchExact(db, pid, query, options, output=None):


def consTest():
bingo1 = Bingo.createDatabaseFile(
indigo, joinPathPy("mol_test_db1", __file__), "molecule", ""
)
bingo2 = Bingo.createDatabaseFile(
indigo, joinPathPy("mol_test_db2", __file__), "molecule", ""
)
bingo1 = Bingo.createDatabaseFile(indigo, db_dir1, "molecule", "")
bingo2 = Bingo.createDatabaseFile(indigo, db_dir2, "molecule", "")

insertProc(bingo1, 0, "sample_2000_2.smi")
insertProc(bingo1, 0, "sample_2000_2.smi")
Expand Down Expand Up @@ -134,9 +133,7 @@ def insertThr(db, pid, samples, output=None):


def paralSameTest():
bingo1 = Bingo.createDatabaseFile(
indigo, joinPathPy("mol_test_db1", __file__), "molecule", ""
)
bingo1 = Bingo.createDatabaseFile(indigo, db_dir1, "molecule", "")

thrs = []

Expand Down Expand Up @@ -173,13 +170,13 @@ def paralSameTest():
def paralBigTest():
bingo1 = Bingo.createDatabaseFile(
indigo,
joinPathPy("mol_test_db1", __file__),
db_dir1,
"molecule",
"read_only:false",
)
bingo2 = Bingo.createDatabaseFile(
indigo,
joinPathPy("mol_test_db2", __file__),
db_dir2,
"molecule",
"read_only:false",
)
Expand Down Expand Up @@ -328,12 +325,8 @@ def paralBigTest():
def difIndigoTest():
indigo1 = Indigo()
indigo2 = Indigo()
bingo1 = Bingo.createDatabaseFile(
indigo1, joinPathPy("mol_test_db1", __file__), "molecule", ""
)
bingo2 = Bingo.createDatabaseFile(
indigo2, joinPathPy("mol_test_db2", __file__), "molecule", ""
)
bingo1 = Bingo.createDatabaseFile(indigo1, db_dir1, "molecule", "")
bingo2 = Bingo.createDatabaseFile(indigo2, db_dir2, "molecule", "")

t1 = threading.Thread(target=insertThr, args=(bingo1, [2, 3]))
t2 = threading.Thread(target=insertThr, args=(bingo2, [1, 4, 5]))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
mol = indigo.loadQueryMoleculeFromFile(file)

indigo.setOption("render-output-format", "svg")
renderer.renderToFile(mol, joinPathPy(out_dir + filename + "_q.svg", __file__))
renderer.renderToFile(
mol, joinPathPy(out_dir + "/" + filename + "_q.svg", __file__)
)
print(checkImageSimilarity("%s" % (filename + "_q.svg")))

indigo.setOption("render-output-format", "png")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
from env_indigo import *

indigo = Indigo()
bingo = Bingo.createDatabaseFile(indigo, "get_indigo_object_bug", "molecule")
bingo = Bingo.createDatabaseFile(
indigo, joiinPathPy("out/get_indigo_object_bug", __file__), "molecule"
)
for item in ("C1=CC=CC=C1", "C1=CN=CC=C1"):
bingo.insert(indigo.loadMolecule(item))
result = bingo.searchSim(
Expand Down

0 comments on commit 2da94fa

Please sign in to comment.