From 41d5abe81b2a9e46389c39b459fd1d1e646ef8bd Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Fri, 29 Jul 2011 12:33:05 -0700 Subject: [PATCH] Construct unit tests for inventory/hard disk long term storage component. This involved RDFing a couple of the templates to make it easier to make sure the right types of information were on the web pages. I also added a new namespace http://jumpgate.caltech.edu/wiki/InventoryOntology# There was also a missing in one of the templates that I fixed. --- .../inventory/fixtures/test_harddisks.json | 338 ++++++++++++++++++ .../inventory/fixtures/test_user.json | 99 +++++ htsworkflow/frontend/inventory/tests.py | 92 +++++ htsworkflow/frontend/templates/base.html | 1 + .../inventory/inventory_itemtype_index.html | 19 +- .../inventory/inventory_summary.html | 18 +- htsworkflow/util/rdfhelp.py | 8 + 7 files changed, 557 insertions(+), 18 deletions(-) create mode 100644 htsworkflow/frontend/inventory/fixtures/test_harddisks.json create mode 100644 htsworkflow/frontend/inventory/fixtures/test_user.json create mode 100644 htsworkflow/frontend/inventory/tests.py diff --git a/htsworkflow/frontend/inventory/fixtures/test_harddisks.json b/htsworkflow/frontend/inventory/fixtures/test_harddisks.json new file mode 100644 index 0000000..feb2090 --- /dev/null +++ b/htsworkflow/frontend/inventory/fixtures/test_harddisks.json @@ -0,0 +1,338 @@ +[ + { + "pk": 1, + "model": "inventory.vendor", + "fields": { + "url": "http://www.newegg.com/", + "name": "newegg.com" + } + }, + { + "pk": 1, + "model": "inventory.location", + "fields": { + "uuid": "e344a4a2522211de99b00015172ce556", + "notes": "", + "location_description": "Office 1", + "name": "Dev Office" + } + }, + { + "pk": 1, + "model": "inventory.iteminfo", + "fields": { + "model_id": "WD10EADS-00L5B1", + "vendor": 1, + "lot_number": "", + "url": "http://www.newegg.com/Product/Product.aspx?Item=N82E16822136317&Tpk=WD10EADS", + "warranty_months": 24, + "notes": "", + "part_number": "", + "purchase_date": "2009-05-19", + "qty_purchased": 17 + } + }, + { + "pk": 1, + "model": "inventory.itemtype", + "fields": { + "name": "Hard Drive", + "description": null + } + }, + { + "pk": 1, + "model": "inventory.itemstatus", + "fields": { + "notes": "", + "name": "Used" + } + }, + { + "pk": 2, + "model": "inventory.itemstatus", + "fields": { + "notes": "", + "name": "Unused" + } + }, + { + "pk": 1, + "model": "inventory.item", + "fields": { + "status": null, + "modified_date": "2009-08-10 16:58:44", + "uuid": "8a90b6ce522311de99b00015172ce556", + "barcode_id": "WCAU49183397", + "notes": "", + "item_info": 1, + "force_use_uuid": false, + "item_type": 1, + "location": 1, + "creation_date": "2009-06-05 15:52:26" + } + }, + { + "pk": 2, + "model": "inventory.item", + "fields": { + "status": null, + "modified_date": "2009-06-16 11:38:24", + "uuid": "b0792d425aa411de99b00015172ce556", + "barcode_id": "WCAU49042470", + "notes": "", + "item_info": 1, + "force_use_uuid": false, + "item_type": 1, + "location": 1, + "creation_date": "2009-06-16 11:37:04" + } + }, + { + "pk": 1, + "model": "inventory.printertemplate", + "fields": { + "default": false, + "item_type": 1, + "printer": 2, + "template": "^FX=========================\r\n^FX 3\"x3\" Label\r\n^FX=========================\r\n^XA\r\n\r\n\r\n^FX======== Left Side ===========\r\n\r\n^FX------------\r\n^FX ^LH changes the 0,0 point of all subsequent location references\r\n^FX------------\r\n\r\n^LH0,50\r\n\r\n^FX ---Header---\r\n\r\n^FO25,0\r\n^CF0,50\r\n^FB250,2,,C\r\n^FD{{ item.barcode_id }}^FS\r\n\r\n^FX ---Column 1: Flowcells---\r\n\r\n^FX-----------------\r\n^FX FB command for automatic text formatting:\r\n^FX ^FB[dot width of area], [max # of lines], [change line spacing], [justification: L, C, R, J], [hanging indent]\r\n^FX-----------------\r\n\r\n^CF0,30,30\r\n^FO75,125\r\n^FB275,19,,L\r\n^FD{% for flowcell in flowcell_id_list %}{{ flowcell }}{% if not forloop.last %}\\&{% endif %}{% endfor %}^FS\r\n^FX ---Date---\r\n\r\n^FO0,725\r\n^CF0,35\r\n^FB300,2,,C\r\n^FD{{ oldest_rundate|date:\"YMd\" }} - {{ latest_rundate|date:\"YMd\" }}^FS\r\n\r\n^FX ---Barcode---\r\n\r\n^FO135,795\r\n^BXN,3,200^FDinvb|{{ item.barcode_id }}^FS\r\n\r\n^FX======== Right Side ===========\r\n\r\n^LH300,60\r\n\r\n^FX ---Header---\r\n\r\n^FO0,0\r\n^CF0,50\r\n^FB600,2,,C\r\n^FD{{ barcode_id }}^FS\r\n\r\n^FX ---Dividing line---\r\n\r\n^FX---------------\r\n^FX GB command:\r\n^FX ^GB[box width], [box height], [border thickness], [color: B, W], [corner rounding: 0-8]^FS\r\n^FX---------------\r\n\r\n^FO0,100\r\n^GB0,600,10^FS\r\n\r\n^FX ---Column 2: Libraries 1-20---\r\n\r\n^CF0,30,30\r\n^FO75,100\r\n^FB100,20,,L\r\n^FD{% for lib_id in library_id_list_1_to_20 %}{{ lib_id }}{% if not forloop.last %}\\&{% endif %}{% endfor %}^FS\r\n\r\n^FX ---Column 3: Libraries 21-40---\r\n\r\n^CF0,30,30\r\n^FO200,100\r\n^FB100,20,,L\r\n^FD{% for lib_id in library_id_list_21_to_40 %}{{ lib_id }}{% if not forloop.last %}\\&{% endif %}{% endfor %}^FS\r\n\r\n^FX ---Column 4: Libraries 41-60---\r\n\r\n^CF0,30,30\r\n^FO325,100\r\n^FB100,20,,L\r\n^FD{% for lib_id in library_id_list_41_to_60 %}{{ lib_id }}{% if not forloop.last %}\\&{% endif %}{% endfor %}^FS\r\n\r\n^FX ---Column 5: Libraries 61-80---\r\n\r\n^CF0,30,30\r\n^FO450,100\r\n^FB100,20,,L\r\n^FD{% for lib_id in library_id_list_61_to_80 %}{{ lib_id }}{% if not forloop.last %}\\&{% endif %}{% endfor %}^FS\r\n\r\n^FX ---Date---\r\n\r\n^FO0,715\r\n^CF0,35\r\n^FB600,2,,C\r\n^FDRun Dates: {{ oldest_rundate|date:\"YMd\" }}-{{ latest_rundate|date:\"YMd\" }}^FS\r\n\r\n^FX ---Barcode---\r\n\r\n^FO255,785\r\n^BXN,3,200^FDinvb|{{ item.barcode_id }}^FS\r\n\r\n^LH0,0\r\n^FX ---End---\r\n^XZ\r\n" + } + }, + { + "pk": 2, + "model": "inventory.printertemplate", + "fields": { + "default": true, + "item_type": 2, + "printer": 1, + "template": "^FX=========================\r\n^FX Harddrive Location Tracking Label\r\n^FX 300x375 dots\r\n^FX=========================\r\n\r\n^XA\r\n^LH 0,25\r\n\r\n^FO0,0\r\n^CF0,35\r\n^FB375,1,,C\r\n^FD{{ item.item_type.name }}:^FS\r\n\r\n^FX -------Text contains HD serial #-------------\r\n^FO15,75\r\n^CF0,42\r\n^FB325,3,,C\r\n^FD{% if use_uuid %}{{ item.uuid }}{% else %}{{ item.barcode_id }}{% endif %}^FS\r\n\r\n^FX -------Barcode contains HD serial #-----------\r\n^FO150,200\r\n^BXN,3,200\r\n^FD{% if use_uuid %}invu|{{ item.uuid }}{% else %}invb|{{ item.barcode_id }}{% endif %}^FS\r\n\r\n^XZ\r\n" + } + }, + { + "pk": 3, + "model": "inventory.printertemplate", + "fields": { + "default": false, + "item_type": 6, + "printer": 1, + "template": "^XA\r\n\r\n^FX ---SIDE LABEL---\r\n^LH 190,40\r\n^CF 0,30\r\n\r\n^FX------Sideways ID------\r\n^FO 0,25\r\n^TB R,100,40\r\n^FD{{ library.id }}^FS\r\n^FX------Sideways Line------\r\n^FO 50,0\r\n^GB 5,200,5^FS\r\n\r\n^FX-------Name----------\r\n^FO 65,20\r\n^FB 325,4\r\n^FD{{ library.library_name }}^FS\r\n\r\n^FX ---TOP LABEL---\r\n^LH 12,28\r\n^CF 0,30\r\n\r\n^FX----ID #----\r\n^FO 5,25\r\n^FB 145,1,,C\r\n^FD{{ library.id }}^FS\r\n\r\n^FX----Name----\r\n^CF 0,16\r\n^FO 13,47\r\n^TB N,130,30\r\n^FD{{ library.library_name }}^FS\r\n\r\n^FX--------Barcode--------\r\n^FO 50,80\r\n^BXN ,3,200\r\n^FDl|0000000{{ library.id }}|woldlab^FS\r\n\r\n{% if not library.hidden %}\r\n^FX-----Border-------\r\n^FO 0,0\r\n^GC 150,10\r\n^FX ---End---\r\n{% endif %}\r\n^XZ\r\n" + } + }, + { + "pk": 1, + "model": "inventory.longtermstorage", + "fields": { + "libraries": [ + "10001", + "10002", + "10003" + ], + "modified_date": "2009-06-01 00:00:00", + "storage_devices": [ + 1 + ], + "flowcell": 1, + "creation_date": "2009-06-01 00:00:00" + } + }, + { + "pk": 2, + "model": "inventory.longtermstorage", + "fields": { + "libraries": [ + "10001", + "10002", + "10003" + ], + "modified_date": "2009-06-01 00:00:00", + "storage_devices": [ + 1 + ], + "flowcell": 2, + "creation_date": "2009-06-01 00:00:00" + } + }, + {"pk": 1, "model": "experiments.flowcell", + "fields": { + "paired_end": true, + "run_date": "2009-09-11 22:12:13", + "read_length": 75, + "notes": "", + "advanced_run": false, + "control_lane": 2, + "flowcell_id": "11ONEAAXX" + } + }, + {"pk": 2, "model": "experiments.flowcell", + "fields": { + "paired_end": false, + "run_date": "2010-09-11 22:12:13", + "read_length": 75, + "notes": "", + "advanced_run": false, + "control_lane": 2, + "flowcell_id": "22TWOAAXX" + } + }, + {"pk": "10001", "model": "samples.library", + "fields": { + "ten_nM_dilution": false, + "gel_cut_size": 400, + "library_name": "10001", + "creation_date": "2009-07-21", + "cell_line": 1, + "library_species": 2, + "library_type": null, + "made_by": "Igor", + "affiliations": [ + 1 + ], + "replicate": 1, + "condition": 1, + "hidden": false, + "stopping_point": "Done", + "tags": [], + "made_for": "Test", + "amplified_from_sample": null, + "notes": "", + "undiluted_concentration": "1", + "successful_pM": null, + "experiment_type": 10, + "antibody": null + } + }, + {"pk": "10002", "model": "samples.library", + "fields": { + "ten_nM_dilution": false, + "gel_cut_size": 400, + "library_name": "10002", + "creation_date": "2009-07-21", + "cell_line": 1, + "library_species": 2, + "library_type": null, + "made_by": "Igor", + "affiliations": [ + 1 + ], + "replicate": 1, + "condition": 1, + "hidden": false, + "stopping_point": "Done", + "tags": [], + "made_for": "Test", + "amplified_from_sample": null, + "notes": "", + "undiluted_concentration": "1", + "successful_pM": null, + "experiment_type": 10, + "antibody": null + } + }, + {"pk": "10003", "model": "samples.library", + "fields": { + "ten_nM_dilution": false, + "gel_cut_size": 400, + "library_name": "10003", + "creation_date": "2009-07-21", + "cell_line": 1, + "library_species": 2, + "library_type": null, + "made_by": "Igor", + "affiliations": [ + 1 + ], + "replicate": 1, + "condition": 1, + "hidden": false, + "stopping_point": "Done", + "tags": [], + "made_for": "Test", + "amplified_from_sample": null, + "notes": "", + "undiluted_concentration": "1", + "successful_pM": null, + "experiment_type": 10, + "antibody": null + } + }, + {"pk": 1, "model": "experiments.lane", + "fields": { + "comment": "10001 lane 1", + "library": "10001", + "cluster_estimate": 100000, + "flowcell": 1, + "lane_number": 1, + "pM": "8" + } + }, + {"pk": 2, "model": "experiments.lane", + "fields": { + "comment": "10002 lane 2", + "library": "10002", + "cluster_estimate": 100000, + "flowcell": 1, + "lane_number": 2, + "pM": "8" + } + }, + {"pk": 3, "model": "experiments.lane", + "fields": { + "comment": "10003 lane 3", + "library": "10003", + "cluster_estimate": 100000, + "flowcell": 1, + "lane_number": 3, + "pM": "8" + } + }, + {"pk": 4, "model": "experiments.lane", + "fields": { + "comment": "10004 lane 4", + "library": "10001", + "cluster_estimate": 100000, + "flowcell": 2, + "lane_number": 4, + "pM": "8" + } + }, + {"pk": 5, "model": "experiments.lane", + "fields": { + "comment": "10001 lane 1", + "library": "10001", + "cluster_estimate": 100000, + "flowcell": 2, + "lane_number": 1, + "pM": "8" + } + }, + {"pk": 6, "model": "experiments.lane", + "fields": { + "comment": "10001 lane 1", + "library": "10003", + "cluster_estimate": 100000, + "flowcell": 2, + "lane_number": 2, + "pM": "8" + } + }, + {"pk": 7, "model": "experiments.lane", + "fields": { + "comment": "10003 lane 8", + "library": "10003", + "cluster_estimate": 100000, + "flowcell": 2, + "lane_number": 8, + "pM": "8" + } + }, + {"pk": 8, "model": "experiments.lane", + "fields": { + "comment": "10002 lane 8", + "library": "10001", + "cluster_estimate": 100000, + "flowcell": 2, + "lane_number": 8, + "pM": "8" + } + } +] \ No newline at end of file diff --git a/htsworkflow/frontend/inventory/fixtures/test_user.json b/htsworkflow/frontend/inventory/fixtures/test_user.json new file mode 100644 index 0000000..c4a9b59 --- /dev/null +++ b/htsworkflow/frontend/inventory/fixtures/test_user.json @@ -0,0 +1,99 @@ +[ + {"pk": 5, "model": "auth.user", + "fields": { + "username": "test", + "first_name": "", + "last_name": "", + "is_active": true, + "is_superuser": false, + "is_staff": false, + "last_login": "2009-01-01 00:00:01", + "groups": [], + "user_permissions": [], + "password": "sha1$foo$5e4eefec1144a04becfb7da79244f07c487fc345", + "email": "", + "date_joined": "2009-01-01 00:01:01" + } + }, + {"pk": 5, "model": "samples.htsuser", + "fields" : {} + }, + {"pk": 6, "model": "auth.user", + "fields": { + "username": "admintest", + "first_name": "", + "last_name": "", + "is_active": true, + "is_superuser": false, + "is_staff": true, + "last_login": "2009-01-01 00:00:01", + "groups": [], + "user_permissions": [], + "password": "sha1$foo$5e4eefec1144a04becfb7da79244f07c487fc345", + "email": "", + "date_joined": "2009-01-01 00:01:01" + } + }, + {"pk": 6, "model": "samples.htsuser", + "fields" : {} + }, + {"pk": 7, "model": "auth.user", + "fields": { + "username": "supertest", + "first_name": "", + "last_name": "", + "is_active": true, + "is_superuser": true, + "is_staff": true, + "last_login": "2009-01-01 00:00:01", + "groups": [], + "user_permissions": [], + "password": "sha1$foo$5e4eefec1144a04becfb7da79244f07c487fc345", + "email": "", + "date_joined": "2009-01-01 00:01:01" + } + }, + {"pk": 7, "model": "samples.htsuser", + "fields" : {} + }, + {"pk": 1, "model": "samples.affiliation", + "fields": { + "users": [5], + "contact": "group 1", + "name": "affiliation 1", + "email": "pk1@example.com" + } + }, + {"pk": 2, "model": "samples.affiliation", + "fields": { + "users": [6], + "contact": "group 2", + "name": "affiliation 2", + "email": "pk2@example.com" + } + }, + {"pk": 3, "model": "samples.affiliation", + "fields": { + "users": [], + "contact": "group 3", + "name": "affiliation 3", + "email": "pk3@example.com" + } + }, + {"pk": 4, "model": "samples.affiliation", + "fields": { + "users": [], + "contact": "group 4", + "name": "affiliation 4", + "email": "pk1@example.com" + } + }, + {"pk": 5, "model": "samples.affiliation", + "fields": { + "users": [], + "contact": "group 5", + "name": "affiliation 5", + "email": "pk5@example.com" + } + } +] diff --git a/htsworkflow/frontend/inventory/tests.py b/htsworkflow/frontend/inventory/tests.py new file mode 100644 index 0000000..01b9b21 --- /dev/null +++ b/htsworkflow/frontend/inventory/tests.py @@ -0,0 +1,92 @@ +import RDF +import unittest + +from django.test import TestCase +from django.contrib.auth.models import User +from django.core import urlresolvers + +from htsworkflow.frontend.inventory.models import Item, Vendor +from htsworkflow.util.rdfhelp import get_model, load_string_into_model, get_serializer, inventoryOntology, libraryOntology, fromTypedNode + +def localhostNode(url): + return RDF.Node(RDF.Uri('http://localhost%s' % (url,))) + +class InventoryTestCase(TestCase): + fixtures = ['test_user', 'test_harddisks'] + + def test_fixture(self): + # make sure that some of our test data is was loaded + # since there was no error message when I typoed the test fixture + hd1 = Item.objects.get(pk=1) + self.failUnlessEqual(hd1.uuid, '8a90b6ce522311de99b00015172ce556') + + user = User.objects.get(pk=5) + self.failUnlessEqual(user.username, 'test') + + def test_item(self): + url = '/inventory/8a90b6ce522311de99b00015172ce556/' + self.client.login(username='test', password='BJOKL5kAj6aFZ6A5') + response = self.client.get(url) + self.failUnlessEqual(response.status_code, 200) + + model = get_model() + load_string_into_model(model, 'rdfa', response.content, url) + + itemNode = RDF.Node(RDF.Uri(url)) + item_type = fromTypedNode(model.get_target(itemNode, inventoryOntology['item_type'])) + self.failUnlessEqual(item_type, u'Hard Drive') + + def test_itemindex(self): + url = '/inventory/it/Hard Drive/' + indexNode = localhostNode(url) + diskNode = localhostNode('/inventory/8a90b6ce522311de99b00015172ce556/') + self.client.login(username='test', password='BJOKL5kAj6aFZ6A5') + + flowcells = self.get_flowcells_from_content(url, indexNode, diskNode) + self.failUnlessEqual(len(flowcells), 2) + self.failUnless('http://localhost/flowcell/11ONEAAXX/' in flowcells) + self.failUnless('http://localhost/flowcell/22TWOAAXX/' in flowcells) + + def test_add_disk(self): + url = '/inventory/it/Hard Drive/' + #url_disk = '/inventory/8a90b6ce522311de99b00015172ce556/' + url_disk = '/inventory/b0792d425aa411de99b00015172ce556/' + indexNode = localhostNode(url) + diskNode = localhostNode(url_disk) + self.client.login(username='test', password='BJOKL5kAj6aFZ6A5') + + flowcells = self.get_flowcells_from_content(url, indexNode, diskNode) + self.failUnlessEqual(len(flowcells), 0) + + # step two link the flowcell + flowcell = '22TWOAAXX' + serial = 'WCAU49042470' + link_url = urlresolvers.reverse( + 'htsworkflow.frontend.inventory.views.link_flowcell_and_device', + args=(flowcell, serial)) + link_response = self.client.get(link_url) + self.failUnlessEqual(link_response.status_code, 200) + + flowcells = self.get_flowcells_from_content(url, indexNode, diskNode) + self.failUnlessEqual(len(flowcells), 1) + self.failUnlessEqual('http://localhost/flowcell/%s/' % (flowcell), + flowcells[0]) + + + def get_flowcells_from_content(self, url, rootNode, diskNode): + model = get_model() + + response = self.client.get(url) + self.failUnlessEqual(response.status_code, 200) + + load_string_into_model(model, 'rdfa', response.content, rootNode.uri) + targets = model.get_targets(diskNode, libraryOntology['flowcell_id']) + flowcells = [ str(x.uri) for x in targets] + return flowcells + +def suite(): + return unittest.makeSuite(InventoryTestCase, 'test') + +if __name__ == "__main__": + unittest.main(defaultTest="suite") + diff --git a/htsworkflow/frontend/templates/base.html b/htsworkflow/frontend/templates/base.html index 479f470..a2e3919 100644 --- a/htsworkflow/frontend/templates/base.html +++ b/htsworkflow/frontend/templates/base.html @@ -7,6 +7,7 @@ xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsd="http://www.w3.org/2001/XMLSchema#" xmlns:libns="http://jumpgate.caltech.edu/wiki/LibraryOntology#" + xmlns:invns="http://jumpgate.caltech.edu/wiki/InventoryOntology#" xml:lang="en" > diff --git a/htsworkflow/frontend/templates/inventory/inventory_itemtype_index.html b/htsworkflow/frontend/templates/inventory/inventory_itemtype_index.html index 1a49af4..d3a0038 100644 --- a/htsworkflow/frontend/templates/inventory/inventory_itemtype_index.html +++ b/htsworkflow/frontend/templates/inventory/inventory_itemtype_index.html @@ -30,7 +30,7 @@ {% for spec in item_changelist.filter_specs %} {% admin_list_filter cl spec %} {% endfor %} - + {% endif %} {% endblock %} {% block summary_stats %} @@ -48,16 +48,16 @@ {% for item in item_changelist.get_query_set %} - - {{ item.uuid }} - {{ item.barcode_id }} - {{ item.location }} - {{ item.item_type }} + + {{ item.uuid }} + {{ item.barcode_id }} + {{ item.location }} + {{ item.item_type }} - {{ item.creation_date }} - + {{ item.creation_date }} + {% for content in item.longtermstorage_set.all %} - {{ content.flowcell }} + {{ content.flowcell }} {% endfor %} @@ -65,5 +65,6 @@ {% endblock %} + {% endblock %} diff --git a/htsworkflow/frontend/templates/inventory/inventory_summary.html b/htsworkflow/frontend/templates/inventory/inventory_summary.html index 19f7da1..4c56f09 100644 --- a/htsworkflow/frontend/templates/inventory/inventory_summary.html +++ b/htsworkflow/frontend/templates/inventory/inventory_summary.html @@ -5,25 +5,25 @@

Item Summary:

Print

- UUID: {{item.uuid}}
- Barcode ID: {{ item.barcode_id }}
- Type: {{ item.item_type.name }}
+ UUID: {{item.uuid}}
+ Barcode ID: {{ item.barcode_id }}
+ Type: {{ item.item_type.name }}

- Location: {{ item.location.name }}
- Status: {% if item.status %}{{ item.status.name }}{% else %}N/A{% endif %}
+ Location: {{ item.location.name }}
+ Status: {% if item.status %}{{ item.status.name }}{% else %}N/A{% endif %}

{% if item.item_info.model_id %} - Model ID: {{ item.item_info.model_id }}
+ Model ID: {{ item.item_info.model_id }}
{% endif %} {% if item.item_info.part_number %} - Part Number: {{ item.item_info.part_number }}
+ Part Number: {{ item.item_info.part_number }}
{% endif %} {% if item.item_info.lot_number %} - Lot Number: {{ item.item_info.lot_number }}
+ Lot Number: {{ item.item_info.lot_number }}
{% endif %}
{% if item.item_info.url %} - Item Website: Link
+ Item Website: Link
{% endif %} Vendor: {% if item.item_info.vendor.url %}{% endif %}{{ item.item_info.vendor.name }}{% if item.item_info.vendor.url %}{% endif %}
Purchase Date:{% if item.item_info.purchase_date %}{{ item.item_info.purchase_date }}{% else %}N/A{% endif %}
diff --git a/htsworkflow/util/rdfhelp.py b/htsworkflow/util/rdfhelp.py index 4a40f0b..9fcd331 100644 --- a/htsworkflow/util/rdfhelp.py +++ b/htsworkflow/util/rdfhelp.py @@ -19,6 +19,7 @@ xsdNS = RDF.NS("http://www.w3.org/2001/XMLSchema#") submissionOntology = RDF.NS("http://jumpgate.caltech.edu/wiki/UcscSubmissionOntology#") dafTermOntology = RDF.NS("http://jumpgate.caltech.edu/wiki/UcscDaf#") libraryOntology = RDF.NS("http://jumpgate.caltech.edu/wiki/LibraryOntology#") +inventoryOntology = RDF.NS("http://jumpgate.caltech.edu/wiki/InventoryOntology#") submissionLog = RDF.NS("http://jumpgate.caltech.edu/wiki/SubmissionsLog/") def sparql_query(model, query_filename): @@ -120,6 +121,13 @@ def load_into_model(model, parser_name, filename, ns=None): raise IOError("Can't find {0}".format(filename)) data = open(filename, 'r').read() + load_string_into_model(model, parser_name, data, ns) + + +def load_string_into_model(model, parser_name, data, ns=None): + if ns is None: + ns = "http://localhost/" + rdf_parser = RDF.Parser(name=parser_name) rdf_parser.parse_string_into_model(model, data, ns) -- 2.30.2