obi test: minor changes
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
#cython: language_level=3
|
||||
|
||||
from obitools3.apps.progress cimport ProgressBar # TODO I absolutely don't understand why it doesn't work without that line
|
||||
from obitools3.dms.view.view import View, Line_selection
|
||||
from obitools3.dms.view.typed_view.view_NUC_SEQS import View_NUC_SEQS
|
||||
@ -5,15 +7,19 @@ from obitools3.dms.dms import DMS
|
||||
from obitools3.dms.column import Column
|
||||
from obitools3.dms.taxo.taxo import OBI_Taxonomy
|
||||
from obitools3.utils cimport str2bytes
|
||||
|
||||
from obitools3.dms.capi.obitypes cimport OBI_INT, \
|
||||
OBI_FLOAT, \
|
||||
OBI_BOOL, \
|
||||
OBI_CHAR, \
|
||||
OBI_STR, \
|
||||
OBI_SEQ
|
||||
import shutil
|
||||
import string
|
||||
import random
|
||||
|
||||
|
||||
|
||||
|
||||
VIEW_TYPES = ["", "NUC_SEQS_VIEW"]
|
||||
#COL_TYPES = ["OBI_BOOL", "OBI_CHAR", "OBI_FLOAT", "OBI_INT", "OBI_SEQ", "OBI_STR"]
|
||||
COL_TYPES = [1, 2, 3, 4, 6, 7]
|
||||
COL_TYPES = [OBI_INT, OBI_FLOAT, OBI_BOOL, OBI_CHAR, OBI_STR, OBI_SEQ]
|
||||
NUC_SEQUENCE_COLUMN = "NUC_SEQ"
|
||||
ID_COLUMN = "ID"
|
||||
DEFINITION_COLUMN = "DEFINITION"
|
||||
@ -31,11 +37,10 @@ MAX_INT = 2147483647 # used to generate random float values
|
||||
__title__="Tests if the obitools are working properly"
|
||||
|
||||
|
||||
default_config = {
|
||||
default_config = {
|
||||
}
|
||||
|
||||
|
||||
|
||||
def test_taxo(config, infos):
|
||||
tax1 = OBI_Taxonomy.open(infos['dms'], config['obi']['taxo'], taxdump=True)
|
||||
tax1.write(TAXTEST)
|
||||
@ -229,7 +234,7 @@ def create_random_column(config, infos) :
|
||||
comments=random_str_with_max_len(COL_COMMENTS_MAX_LEN),
|
||||
alias=alias
|
||||
)
|
||||
|
||||
|
||||
if alias != '' :
|
||||
assert infos['view'][alias] == column
|
||||
else :
|
||||
@ -284,18 +289,18 @@ def random_new_view(config, infos, first=False):
|
||||
v_to_clone.close()
|
||||
if first :
|
||||
fill_view(config, infos)
|
||||
|
||||
|
||||
|
||||
|
||||
def create_test_obidms(config, infos):
|
||||
infos['dms'] = DMS.new(config['obi']['defaultdms'])
|
||||
|
||||
|
||||
|
||||
|
||||
def ini_dms_and_first_view(config, infos):
|
||||
create_test_obidms(config, infos)
|
||||
random_new_view(config, infos, first=True)
|
||||
infos['view_names'] = []
|
||||
|
||||
|
||||
|
||||
|
||||
def addOptions(parser):
|
||||
|
||||
# TODO put this common group somewhere else but I don't know where
|
||||
@ -309,11 +314,12 @@ def addOptions(parser):
|
||||
help="Name of the default DMS for reading and writing data. "
|
||||
"Default: /tmp/test_dms")
|
||||
|
||||
group.add_argument('--taxo','-t',
|
||||
group.add_argument('--taxo','-t', # TODO I don't understand why the option is not registered if it is not set
|
||||
action="store", dest="obi:taxo",
|
||||
metavar='<TAXDUMP PATH>',
|
||||
default='', # TODO not None because if it's None, the option is not entered in the option dictionary.
|
||||
type=str,
|
||||
help="Path to a taxdump to test the taxonomy.") # TODO
|
||||
help="Path to a taxdump to test the taxonomy.")
|
||||
|
||||
|
||||
group=parser.add_argument_group('obi test specific options')
|
||||
@ -408,7 +414,7 @@ def run(config):
|
||||
|
||||
ini_dms_and_first_view(config, infos)
|
||||
print_test(config, repr(infos['view']))
|
||||
|
||||
|
||||
i = 0
|
||||
for t in range(config['test']['nbtests']):
|
||||
random_test(config, infos)
|
||||
@ -419,12 +425,13 @@ def run(config):
|
||||
|
||||
#print(infos)
|
||||
|
||||
test_taxo(config, infos)
|
||||
if config['obi']['taxo'] != '' :
|
||||
test_taxo(config, infos)
|
||||
|
||||
infos['view'].close()
|
||||
infos['dms'].close()
|
||||
shutil.rmtree(config['obi']['defaultdms']+'.obidms', ignore_errors=True)
|
||||
|
||||
print("Done.")
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user