From c967fb6156339ce1555f09986f6f4981992506a4 Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Thu, 20 Sep 2012 14:26:46 -0700 Subject: [PATCH] Also make the library index page conform to htsworkflow ontology. --- .../samples/fixtures/test_samples.json | 244 +++++++++--------- htsworkflow/frontend/samples/tests.py | 43 ++- .../templates/samples/library_index.html | 15 +- 3 files changed, 176 insertions(+), 126 deletions(-) diff --git a/htsworkflow/frontend/samples/fixtures/test_samples.json b/htsworkflow/frontend/samples/fixtures/test_samples.json index 729f067..cdaedb1 100644 --- a/htsworkflow/frontend/samples/fixtures/test_samples.json +++ b/htsworkflow/frontend/samples/fixtures/test_samples.json @@ -1,5 +1,5 @@ -[ - {"pk": 5, "model": "auth.user", +[ + {"pk": 5, "model": "auth.user", "fields": { "username": "test", "first_name": "", @@ -29,11 +29,11 @@ "email": "bob@some.where.else" } }, - {"pk": 153, "model": "experiments.flowcell", + {"pk": 153, "model": "experiments.flowcell", "fields": { - "paired_end": true, - "run_date": "2009-09-11 22:12:13", - "read_length": 75, + "paired_end": true, + "run_date": "2009-09-11 22:12:13", + "read_length": 75, "notes": "", "advanced_run": false, "control_lane": 2, @@ -41,7 +41,7 @@ "sequencer": 2, "flowcell_id": "303TUAAXX" } - }, + }, {"pk": 1193, "model": "experiments.lane", "fields": { "comment": "No change in cluster numbers, despite slight increase in pM", @@ -51,7 +51,7 @@ "lane_number": 1, "pM": "8" } - }, + }, {"pk": 1197, "model": "experiments.lane", "fields": { "comment": "stuff", @@ -62,149 +62,149 @@ "pM": "7", "status": 2 } - }, - {"pk": "10981", "model": "samples.library", + }, + {"pk": "10981", "model": "samples.library", "fields": { - "ten_nM_dilution": false, - "gel_cut_size": 400, - "library_name": "Paired End Multiplexed Sp-BAC", - "creation_date": "2009-07-21", - "cell_line": 1, - "library_species": 2, - "library_type": null, - "made_by": "Igor", + "ten_nM_dilution": false, + "gel_cut_size": 400, + "library_name": "Paired End Multiplexed Sp-BAC", + "creation_date": "2009-07-21", + "cell_line": 1, + "library_species": 2, + "library_type": null, + "made_by": "Igor", "affiliations": [ 2 - ], - "replicate": 1, - "condition": 1, - "hidden": false, - "stopping_point": "Done", - "tags": [], - "made_for": "Andy Cameron", - "amplified_from_sample": null, - "notes": "Combined 10957-10968", - "undiluted_concentration": "5.1", - "successful_pM": null, - "experiment_type": 10, + ], + "replicate": 1, + "condition": 1, + "hidden": false, + "stopping_point": "Done", + "tags": [], + "made_for": "Andy Cameron", + "amplified_from_sample": null, + "notes": "Combined 10957-10968", + "undiluted_concentration": "5.1", + "successful_pM": null, + "experiment_type": 10, "antibody": null } - }, + }, { - "pk": "11016", - "model": "samples.library", + "pk": "11016", + "model": "samples.library", "fields": { - "ten_nM_dilution": false, - "gel_cut_size": 325, - "library_name": "Paired End Pfl #3 MP 7/24/9 a", - "creation_date": "2009-08-06", - "cell_line": 1, - "library_species": 9, - "library_type": 2, - "made_by": "Lorian", + "ten_nM_dilution": false, + "gel_cut_size": 325, + "library_name": "Paired End Pfl #3 MP 7/24/9 a", + "creation_date": "2009-08-06", + "cell_line": 1, + "library_species": 9, + "library_type": 2, + "made_by": "Lorian", "affiliations": [ 41 - ], - "replicate": 1, - "condition": 1, - "hidden": false, - "stopping_point": "1Aa", - "tags": [], - "made_for": "", - "amplified_from_sample": 11006, - "notes": "7/31/2009 16:08:22\tColor: Blue", - "undiluted_concentration": "35.5", - "successful_pM": null, - "experiment_type": 8, + ], + "replicate": 1, + "condition": 1, + "hidden": false, + "stopping_point": "1Aa", + "tags": [], + "made_for": "", + "amplified_from_sample": "11003", + "notes": "7/31/2009 16:08:22\tColor: Blue", + "undiluted_concentration": "35.5", + "successful_pM": null, + "experiment_type": 8, "antibody": null } - }, + }, { - "pk": "11039", - "model": "samples.library", + "pk": "11039", + "model": "samples.library", "fields": { - "ten_nM_dilution": false, - "gel_cut_size": 300, - "library_name": "Paired ends 99 GM12892", - "creation_date": "2009-08-25", - "cell_line": 1, - "library_species": 8, - "library_type": 2, - "made_by": "Brian Williams", + "ten_nM_dilution": false, + "gel_cut_size": 300, + "library_name": "Paired ends 99 GM12892", + "creation_date": "2009-08-25", + "cell_line": 1, + "library_species": 8, + "library_type": 2, + "made_by": "Brian Williams", "affiliations": [ - 4, - 8, + 4, + 8, 12 - ], - "replicate": 1, - "condition": 1, - "hidden": false, - "stopping_point": "1Aa", - "tags": [], - "made_for": "Brian Williams", - "amplified_from_sample": null, - "notes": "fragment size = 300 bp, Amicon filtered\r\nnanodrop: 56.3", - "undiluted_concentration": "28.7", - "successful_pM": null, - "experiment_type": 4, + ], + "replicate": 1, + "condition": 1, + "hidden": false, + "stopping_point": "1Aa", + "tags": [], + "made_for": "Brian Williams", + "amplified_from_sample": null, + "notes": "fragment size = 300 bp, Amicon filtered\r\nnanodrop: 56.3", + "undiluted_concentration": "28.7", + "successful_pM": null, + "experiment_type": 4, "antibody": null } }, { - "pk": "11003", - "model": "samples.library", + "pk": "11003", + "model": "samples.library", "fields": { - "ten_nM_dilution": false, - "gel_cut_size": 325, - "library_name": "Paired End Pfl #3 MP 7/24/9", - "creation_date": "2009-08-05", - "cell_line": 1, - "library_species": 8, - "library_type": 2, - "made_by": "Lorian", + "ten_nM_dilution": false, + "gel_cut_size": 325, + "library_name": "Paired End Pfl #3 MP 7/24/9", + "creation_date": "2009-08-05", + "cell_line": 1, + "library_species": 8, + "library_type": 2, + "made_by": "Lorian", "affiliations": [ 41 - ], - "replicate": 1, - "condition": 1, - "hidden": true, - "stopping_point": "1A", - "tags": [], - "made_for": "", - "amplified_from_sample": null, - "notes": "7/31/2009 16:08:22\tColor: Blue", - "undiluted_concentration": null, - "successful_pM": null, - "experiment_type": 8, + ], + "replicate": 1, + "condition": 1, + "hidden": true, + "stopping_point": "1A", + "tags": [], + "made_for": "", + "amplified_from_sample": null, + "notes": "7/31/2009 16:08:22\tColor: Blue", + "undiluted_concentration": null, + "successful_pM": null, + "experiment_type": 8, "antibody": null } }, { - "pk": "11005", - "model": "samples.library", + "pk": "11005", + "model": "samples.library", "fields": { - "ten_nM_dilution": false, - "gel_cut_size": 325, - "library_name": "null cell line", - "creation_date": "2009-08-05", - "cell_line": null, - "library_species": 8, - "library_type": 2, - "made_by": "Lorian", + "ten_nM_dilution": false, + "gel_cut_size": 325, + "library_name": "null cell line", + "creation_date": "2009-08-05", + "cell_line": null, + "library_species": 8, + "library_type": 2, + "made_by": "Lorian", "affiliations": [ 41 - ], - "replicate": 1, - "condition": 1, - "hidden": true, - "stopping_point": "1A", - "tags": [], - "made_for": "", - "amplified_from_sample": null, - "notes": "7/31/2009 16:08:22\tColor: Blue", - "undiluted_concentration": null, - "successful_pM": null, - "experiment_type": 8, + ], + "replicate": 1, + "condition": 1, + "hidden": true, + "stopping_point": "1A", + "tags": [], + "made_for": "", + "amplified_from_sample": null, + "notes": "7/31/2009 16:08:22\tColor: Blue", + "undiluted_concentration": null, + "successful_pM": null, + "experiment_type": 8, "antibody": null } } diff --git a/htsworkflow/frontend/samples/tests.py b/htsworkflow/frontend/samples/tests.py index 770d90a..daabc11 100644 --- a/htsworkflow/frontend/samples/tests.py +++ b/htsworkflow/frontend/samples/tests.py @@ -52,7 +52,6 @@ class SampleWebTestCase(TestCase): fixtures = ['test_samples.json'] def test_library_info(self): - for lib in Library.objects.all(): lib_dict = library_dict(lib.id) url = '/samples/library/%s/json' % (lib.id,) @@ -171,6 +170,48 @@ class SampleWebTestCase(TestCase): self.assertEqual(fromTypedNode(r['gel_cut']), 400) self.assertEqual(fromTypedNode(r['made_by']), u'Igor') + def test_library_index_rdfa(self): + from htsworkflow.util.rdfhelp import \ + add_default_schemas, get_model, load_string_into_model + + from htsworkflow.util.rdfinfer import Infer + + model = get_model() + add_default_schemas(model) + inference = Infer(model) + + response = self.client.get('/library/') + self.assertEqual(response.status_code, 200) + load_string_into_model(model, 'rdfa', response.content) + + errmsgs = list(inference.run_validation()) + self.assertEqual(len(errmsgs), 2) + # didn't feel like giving the index page a type since all + # its doing is showing a list of things. + for err in errmsgs: + self.assertEqual(err, 'Missing type for: http://localhost/') + + body = """prefix rdf: + prefix libns: + + select ?library ?library_id ?name ?species + where { + ?library a libns:Library . + OPTIONAL { ?library libns:library_id ?library_id . } + OPTIONAL { ?library libns:species ?species . } + OPTIONAL { ?library libns:name ?name . } + }""" + bindings = set(['library', 'library_id', 'name', 'species']) + query = RDF.SPARQLQuery(body) + count = 0 + for r in query.execute(model): + count += 1 + for name, value in r.items(): + self.assertTrue(name in bindings) + self.assertTrue(value is not None) + + self.assertEqual(count, len(Library.objects.filter(hidden=False))) + # The django test runner flushes the database between test suites not cases, # so to be more compatible with running via nose we flush the database tables # of interest before creating our sample data. diff --git a/htsworkflow/frontend/templates/samples/library_index.html b/htsworkflow/frontend/templates/samples/library_index.html index 8f351fe..ccba561 100644 --- a/htsworkflow/frontend/templates/samples/library_index.html +++ b/htsworkflow/frontend/templates/samples/library_index.html @@ -70,11 +70,20 @@ {% for lib in library_list %} - + {{ lib.amplified_from }} {{ lib.library_id }} - {{ lib.species_name }} - {{ lib.library_name }} + + + {{ lib.species_name }} + + + + + {{ lib.library_name }} + + {{ lib.lanes_run.0.0 }} {{ lib.lanes_run.0.1 }} {{ lib.lanes_run.0.2 }} -- 2.30.2