-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathtest_ruleutils.py
41 lines (29 loc) · 1.17 KB
/
test_ruleutils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import os
import unittest
import logging
from linkml_runtime.dumpers import yaml_dumper
from linkml_runtime.linkml_model.meta import SchemaDefinition, ClassDefinition, SlotDefinitionName
from linkml_runtime.loaders.yaml_loader import YAMLLoader
from linkml_runtime.utils.schemaview import SchemaView
from linkml_runtime.utils.ruleutils import subclass_to_rules, get_range_as_disjunction
from tests.test_utils import INPUT_DIR
SCHEMA = os.path.join(INPUT_DIR, 'rules-example.yaml')
yaml_loader = YAMLLoader()
class RuleUtilsTestCase(unittest.TestCase):
def test_disjunction(self):
# no import schema
view = SchemaView(SCHEMA)
analyte = view.induced_slot('analyte', 'Sample')
#print(analyte)
#print(analyte.any_of)
disj = get_range_as_disjunction(analyte)
#print(disj)
self.assertCountEqual(disj, {'MissingValueEnum', 'AnalyteEnum'})
def test_roll_up(self):
# no import schema
view = SchemaView(SCHEMA)
c = view.get_class('ProteinCodingGene')
rules = subclass_to_rules(view, 'ProteinCodingGene', 'SeqFeature')
rule = rules[0]
if __name__ == '__main__':
unittest.main()