I used RDF for some test cases
from django.test import TestCase
from django.utils.encoding import smart_text, smart_bytes
from django.test import TestCase
from django.utils.encoding import smart_text, smart_bytes
+from rdflib import ConjunctiveGraph, Graph
+from rdflib.namespace import RDF
+
from .models import SequencingRun, Sequencer, FlowCell, FileType
from samples.models import HTSUser
from .experiments import flowcell_information, lanes_for
from .models import SequencingRun, Sequencer, FlowCell, FileType
from samples.models import HTSUser
from .experiments import flowcell_information, lanes_for
LibraryFactory, LibraryTypeFactory, MultiplexIndexFactory
from htsworkflow.auth import apidata
from htsworkflow.util.ethelp import validate_xhtml
LibraryFactory, LibraryTypeFactory, MultiplexIndexFactory
from htsworkflow.auth import apidata
from htsworkflow.util.ethelp import validate_xhtml
+from htsworkflow.util.rdfhelp import add_default_schemas
+from htsworkflow.util.rdfinfer import Infer
from htsworkflow.pipelines.test.simulate_runfolder import TESTDATA_DIR
from htsworkflow.pipelines.test.simulate_runfolder import TESTDATA_DIR
self.assertEqual(mimetype, response['content-type'])
def test_flowcell_rdf(self):
self.assertEqual(mimetype, response['content-type'])
def test_flowcell_rdf(self):
- import RDF
- from htsworkflow.util.rdfhelp import get_model, \
- fromTypedNode, \
- load_string_into_model, \
- rdfNS, \
- libraryOntology, \
- dump_model
-
- model = get_model()
expected = {'1': ['12151'],
'2': ['12152'],
expected = {'1': ['12151'],
'2': ['12152'],
if status is not None: self.assertTrue(status)
ns = urljoin('http://localhost', url)
if status is not None: self.assertTrue(status)
ns = urljoin('http://localhost', url)
- load_string_into_model(model, 'rdfa', smart_text(response.content), ns=ns)
+ model.parse(data=smart_text(response.content), format='rdfa', publicID=ns)
body = """prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix libns: <http://jumpgate.caltech.edu/wiki/LibraryOntology#>
body = """prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix libns: <http://jumpgate.caltech.edu/wiki/LibraryOntology#>
libns:library ?library .
?library libns:library_id ?library_id .
}"""
libns:library ?library .
?library libns:library_id ?library_id .
}"""
- query = RDF.SPARQLQuery(body)
- for r in query.execute(model):
+ for r in model.query(body):
- self.assertEqual(fromTypedNode(r['flowcell_id']), 'FC12150')
- lane_id = fromTypedNode(r['lane_id'])
- library_id = fromTypedNode(r['library_id'])
+ self.assertEqual(r['flowcell_id'].toPython(), 'FC12150')
+ lane_id = r['lane_id'].toPython()
+ library_id = r['library_id'].toPython()
self.assertTrue(library_id in expected[lane_id])
self.assertEqual(count, 8)
self.assertTrue(library_id in expected[lane_id])
self.assertEqual(count, 8)
self.assertEqual(model[0].text, 'HiSeq 1')
def test_flowcell_with_rdf_validation(self):
self.assertEqual(model[0].text, 'HiSeq 1')
def test_flowcell_with_rdf_validation(self):
- from htsworkflow.util.rdfhelp import add_default_schemas, \
- dump_model, \
- get_model, \
- load_string_into_model
- from htsworkflow.util.rdfinfer import Infer
+ model = ConjunctiveGraph()
add_default_schemas(model)
inference = Infer(model)
add_default_schemas(model)
inference = Infer(model)
if status is not None:
self.assertTrue(status)
if status is not None:
self.assertTrue(status)
- load_string_into_model(model, 'rdfa', smart_text(response.content))
+ model.parse(data=smart_text(response.content), format='rdfa')
errmsgs = list(inference.run_validation())
self.assertEqual(len(errmsgs), 0)
def test_lane_with_rdf_validation(self):
errmsgs = list(inference.run_validation())
self.assertEqual(len(errmsgs), 0)
def test_lane_with_rdf_validation(self):
- from htsworkflow.util.rdfhelp import add_default_schemas, \
- get_model, \
- load_string_into_model
- from htsworkflow.util.rdfinfer import Infer
-
- model = get_model()
+ model = ConjunctiveGraph()
add_default_schemas(model)
inference = Infer(model)
add_default_schemas(model)
inference = Infer(model)
if status is not None:
self.assertTrue(status)
if status is not None:
self.assertTrue(status)
- load_string_into_model(model, 'rdfa', smart_text(response.content))
-
+ model.parse(data=smart_text(response.content), format='rdfa')
errmsgs = list(inference.run_validation())
self.assertEqual(len(errmsgs), 0)
errmsgs = list(inference.run_validation())
self.assertEqual(len(errmsgs), 0)