import shutil
import sys
import tempfile
+from urlparse import urljoin
from django.conf import settings
from django.core import mail
failed_fc_span = flowcell_spans[0]
failed_fc_a = failed_fc_span.getparent()
# make sure some of our RDF made it.
- self.assertEqual(failed_fc_a.get('rel'), 'libns:flowcell')
+ self.assertEqual(failed_fc_a.get('typeof'), 'libns:IlluminaFlowcell')
self.assertEqual(failed_fc_a.get('href'), '/flowcell/30012AAXX/')
fc_response = self.client.get(failed_fc_a.get('href'))
self.assertEqual(fc_response.status_code, 200)
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: ['11034'],
+ 2: ['11036'],
+ 3: ['12044','11045'],
+ 4: ['11047','13044'],
+ 5: ['11055'],
+ 6: ['11067'],
+ 7: ['11069'],
+ 8: ['11070']}
+ url = '/flowcell/42JU1AAXX/'
+ response = self.client.get(url)
+ self.assertEqual(response.status_code, 200)
+ ns = urljoin('http://localhost', url)
+ load_string_into_model(model, 'rdfa', response.content, ns=ns)
+ body = """prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+ prefix libns: <http://jumpgate.caltech.edu/wiki/LibraryOntology#>
+
+ select ?flowcell ?flowcell_id ?lane_id ?library_id
+ where {
+ ?flowcell a libns:IlluminaFlowcell ;
+ libns:flowcell_id ?flowcell_id ;
+ libns:has_lane ?lane .
+ ?lane libns:lane_number ?lane_id ;
+ libns:library ?library .
+ ?library libns:library_id ?library_id .
+ }"""
+ query = RDF.SPARQLQuery(body)
+ count = 0
+ for r in query.execute(model):
+ count += 1
+ self.assertEqual(fromTypedNode(r['flowcell_id']), u'42JU1AAXX')
+ lane_id = fromTypedNode(r['lane_id'])
+ library_id = fromTypedNode(r['library_id'])
+ self.assertTrue(library_id in expected[lane_id])
+ self.assertEqual(count, 10)
+
+
class TestFileType(TestCase):
def test_file_type_unicode(self):
file_type_objects = models.FileType.objects
"Illumina Genome Analyzer IIx")
self.assertEqual(fc.sequencer.instrument_name,
"ILLUMINA-EC5D15")
+ # well actually we let the browser tack on the host name
+ url = fc.get_absolute_url()
+ self.assertEqual(url, '/flowcell/FC12150/')
def test_rdf(self):
response = self.client.get('/flowcell/FC12150/', apidata)
tree = fromstring(response.content)
- divs = tree.xpath('//div[@rel="libns:sequenced_by"]',
- namespaces=NSMAP)
- self.assertEqual(len(divs), 1)
- self.assertEqual(divs[0].attrib['rel'], 'libns:sequenced_by')
- self.assertEqual(divs[0].attrib['resource'], '/sequencer/2')
-
- name = divs[0].xpath('./span[@property="libns:sequencer_name"]')
+ seq_by = tree.xpath('//div[@rel="libns:sequenced_by"]',
+ namespaces=NSMAP)
+ self.assertEqual(len(seq_by), 1)
+ self.assertEqual(seq_by[0].attrib['rel'], 'libns:sequenced_by')
+ seq = seq_by[0].getchildren()
+ self.assertEqual(len(seq), 1)
+ self.assertEqual(seq[0].attrib['about'], '/sequencer/2')
+ self.assertEqual(seq[0].attrib['typeof'], 'libns:Sequencer')
+
+ name = seq[0].xpath('./span[@property="libns:sequencer_name"]')
self.assertEqual(len(name), 1)
self.assertEqual(name[0].text, 'Tardigrade')
- instrument = divs[0].xpath(
+ instrument = seq[0].xpath(
'./span[@property="libns:sequencer_instrument"]')
self.assertEqual(len(instrument), 1)
self.assertEqual(instrument[0].text, 'ILLUMINA-EC5D15')
- model = divs[0].xpath(
+ model = seq[0].xpath(
'./span[@property="libns:sequencer_model"]')
self.assertEqual(len(model), 1)
self.assertEqual(model[0].text, 'Illumina Genome Analyzer IIx')