update command testing

This commit is contained in:
samsledje
2022-06-23 12:40:27 -04:00
parent bf688400f1
commit bec4b6fd0e
4 changed files with 40 additions and 27 deletions

View File

@@ -39,7 +39,7 @@ Evaluate a trained model
.. code-block:: bash
dscript eval --model [model file] --test [test data] --embedding [embedding file] --outfile [result file]
dscript evaluate --model [model file] --test [test data] --embedding [embedding file] --outfile [result file]
Prediction

View File

@@ -42,7 +42,7 @@ def main():
modules = {
"train": train,
"embed": embed,
"eval": evaluate,
"evaluate": evaluate,
"predict": predict,
}

View File

@@ -0,0 +1,38 @@
import os
import shutil
import subprocess as sp
class TestCommands:
@classmethod
def setup_class(cls):
os.makedirs("./tmp-dscript-testing/", exist_ok=True)
@classmethod
def teardown_class(cls):
shutil.rmtree("./tmp-dscript-testing/")
def _run_command(self, cmd):
proc = sp.Popen(cmd.split())
proc.wait()
assert not proc.returncode
def test_embed(self):
cmd = "dscript embed --seqs dscript/tests/test.fasta --outfile tmp-dscript-testing/test_embed.h5 --device 0"
self._run_command(cmd)
def test_train_with_topsy_turvy(self):
cmd = "dscript train --topsy-turvy --train dscript/tests/test.csv --test dscript/tests/test.csv --embedding tmp-dscript-testing/test_embed.h5 --outfile tmp-dscript-testing/test_tt-train.log --save-prefix tmp-dscript-testing/test_train --device 0"
self._run_command(cmd)
def test_train_without_topsy_turvy(self):
cmd = "dscript train --train dscript/tests/test.csv --test dscript/tests/test.csv --embedding tmp-dscript-testing/test_embed.h5 --outfile tmp-dscript-testing/test_tt-train.log --save-prefix tmp-dscript-testing/test_train --device 0"
self._run_command(cmd)
def test_evaluate(self):
cmd = "dscript evaluate --test dscript/tests/test.csv --embedding tmp-dscript-testing/test_embed.h5 --model tmp-dscript-testing/test_train_final.sav --outfile tmp-dscript-testing/test_evaluate --device 0"
self._run_command(cmd)
def test_predict(self):
cmd = "dscript predict --seqs dscript/tests/test.fasta --pairs dscript/tests/test.csv --model tmp-dscript-testing/test_train_final.sav --outfile tmp-dscript-testing/test_predict --thresh 0.05 --device 0"
self._run_command(cmd)

View File

@@ -1,25 +0,0 @@
import os
import shutil
import subprocess as sp
def test_with_topsy_turvy():
os.makedirs("./tmp-dscript-testing/", exist_ok=True)
cmd = "dscript train --topsy-turvy --train dscript/tests/test.csv --test dscript/tests/test.csv --embedding dscript/tests/test.h5 --outfile tmp-dscript-testing/test_tt-train --save-prefix tmp-dscript-testing/test_tt-train --device 0"
proc = sp.Popen(cmd.split())
proc.wait()
assert not proc.returncode
shutil.rmtree("./tmp-dscript-testing/")
def test_without_topsy_turvy():
os.makedirs("./tmp-dscript-testing/", exist_ok=True)
cmd = "dscript train --train dscript/tests/test.csv --test dscript/tests/test.csv --embedding dscript/tests/test.h5 --outfile tmp-dscript-testing/test_tt-train --save-prefix tmp-dscript-testing/test_tt-train --device 0"
proc = sp.Popen(cmd.split())
proc.wait()
assert not proc.returncode
shutil.rmtree("./tmp-dscript-testing/")