From e7a7c24e642d7b7ce59d99af3f13f93e6256e13e Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Mon, 27 Jun 2011 17:18:16 -0700 Subject: [PATCH] Start supporting multiple libraries per lane, as needed for the HiSeq This commit alters the admin page to allow entering multiple libraries per lane, and updates the new flowcell and flowcell lane views to work with having multiple lane objects with the same lane number. I'll still need to update the configuration generation and archiving result files. --- htsworkflow/frontend/experiments/admin.py | 1 - .../experiments/fixtures/test_flowcells.json | 11 +++++++ htsworkflow/frontend/experiments/models.py | 13 +++++++-- htsworkflow/frontend/experiments/views.py | 29 ++++++++++++------- htsworkflow/frontend/samples/tests.py | 2 +- .../experiments/flowcell_detail.html | 2 +- htsworkflow/frontend/urls.py | 4 +-- 7 files changed, 44 insertions(+), 18 deletions(-) diff --git a/htsworkflow/frontend/experiments/admin.py b/htsworkflow/frontend/experiments/admin.py index 4181e5c..fa0f15d 100644 --- a/htsworkflow/frontend/experiments/admin.py +++ b/htsworkflow/frontend/experiments/admin.py @@ -59,7 +59,6 @@ class LaneInline(admin.StackedInline): Controls display of Lanes on the Flowcell form. """ model = Lane - max_num = 8 extra = 8 form = LaneForm raw_id_fields = ('library',) diff --git a/htsworkflow/frontend/experiments/fixtures/test_flowcells.json b/htsworkflow/frontend/experiments/fixtures/test_flowcells.json index 46c8e1d..1afd74e 100644 --- a/htsworkflow/frontend/experiments/fixtures/test_flowcells.json +++ b/htsworkflow/frontend/experiments/fixtures/test_flowcells.json @@ -125,6 +125,17 @@ "pM": "8" } }, + {"pk": 1192, "model": "experiments.lane", + "fields": { + "comment": "Other library", + "library": "11070", + "cluster_estimate": 132000, + "flowcell": 153, + "lane_number": 1, + "pM": "7" + } + }, + {"pk": "10981", "model": "samples.library", "fields": { "ten_nM_dilution": false, diff --git a/htsworkflow/frontend/experiments/models.py b/htsworkflow/frontend/experiments/models.py index f6bac3f..3e8cc86 100755 --- a/htsworkflow/frontend/experiments/models.py +++ b/htsworkflow/frontend/experiments/models.py @@ -172,9 +172,15 @@ LANE_STATUS_CODES = [(0, 'Failed'), LANE_STATUS_MAP = dict((int(k),v) for k,v in LANE_STATUS_CODES ) LANE_STATUS_MAP[None] = "Unknown" +def is_valid_lane(value): + if value >= 1 and value <= 8: + return True + else: + return False + class Lane(models.Model): flowcell = models.ForeignKey(FlowCell) - lane_number = models.IntegerField(choices=[(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8)]) + lane_number = models.IntegerField(validators=[is_valid_lane]) library = models.ForeignKey(Library) pM = models.DecimalField(max_digits=5, decimal_places=2,blank=False, null=False,default=default_pM) cluster_estimate = models.IntegerField(blank=True, null=True) @@ -183,10 +189,11 @@ class Lane(models.Model): @models.permalink def get_absolute_url(self): - flowcell_id, status = parse_flowcell_id(self.flowcell.flowcell_id) return ('htsworkflow.frontend.experiments.views.flowcell_lane_detail', - [str(flowcell_id), str(self.lane_number)]) + [str(self.id)]) + def __unicode__(self): + return self.flowcell.flowcell_id + ':' + unicode(self.lane_number) ### ----------------------- class DataRun(models.Model): diff --git a/htsworkflow/frontend/experiments/views.py b/htsworkflow/frontend/experiments/views.py index a1775d4..08ce6f0 100755 --- a/htsworkflow/frontend/experiments/views.py +++ b/htsworkflow/frontend/experiments/views.py @@ -13,7 +13,11 @@ from django.shortcuts import render_to_response, get_object_or_404 from django.template import RequestContext from django.template.loader import get_template -from htsworkflow.frontend.experiments.models import DataRun, DataFile, FlowCell +from htsworkflow.frontend.experiments.models import \ + DataRun, \ + DataFile, \ + FlowCell, \ + Lane from htsworkflow.frontend.experiments.experiments import \ estimateFlowcellDuration, \ estimateFlowcellTimeRemaining, \ @@ -129,30 +133,35 @@ def finishedEmail(request, pk): return HttpResponse("I've got nothing.") -def flowcell_detail(request, flowcell_id): +def flowcell_detail(request, flowcell_id, lane_number=None): fc = get_object_or_404(FlowCell, flowcell_id__startswith=flowcell_id) fc.update_data_runs() + + if lane_number is not None: + lanes = fc.lane_set.filter(lane_number=lane_number) + else: + lanes = fc.lane_set.all() + context = RequestContext(request, - {'flowcell': fc}) + {'flowcell': fc, + 'lanes': lanes}) return render_to_response('experiments/flowcell_detail.html', context) -def flowcell_lane_detail(request, flowcell_id, lane_number): - fc = get_object_or_404(FlowCell, flowcell_id__startswith=flowcell_id) - lane = get_object_or_404(fc.lane_set, lane_number=lane_number) - - fc.update_data_runs() +def flowcell_lane_detail(request, lane_pk): + lane = get_object_or_404(Lane, id=lane_pk) + lane.flowcell.update_data_runs() dataruns = [] - for run in fc.datarun_set.all(): + for run in lane.flowcell.datarun_set.all(): dataruns.append((run, lane.lane_number, run.lane_files()[lane.lane_number])) context = RequestContext(request, {'lib': lane.library, 'lane': lane, - 'flowcell': fc, + 'flowcell': lane.flowcell, 'filtered_dataruns': dataruns}) return render_to_response('experiments/flowcell_lane_detail.html', diff --git a/htsworkflow/frontend/samples/tests.py b/htsworkflow/frontend/samples/tests.py index b6e8f98..93f46d0 100644 --- a/htsworkflow/frontend/samples/tests.py +++ b/htsworkflow/frontend/samples/tests.py @@ -191,7 +191,7 @@ class TestRDFaLibrary(TestCase): self.check_literal_object(model, ['Drosophila melanogaster'], p=libNS['species']) self.check_uri_object(model, - [u'http://localhost/flowcell/303TUAAXX/1/'], + [u'http://localhost/lane/1193'], p=libNS['has_lane']) self.check_literal_object(model, diff --git a/htsworkflow/frontend/templates/experiments/flowcell_detail.html b/htsworkflow/frontend/templates/experiments/flowcell_detail.html index 6e112f8..865fc97 100644 --- a/htsworkflow/frontend/templates/experiments/flowcell_detail.html +++ b/htsworkflow/frontend/templates/experiments/flowcell_detail.html @@ -38,7 +38,7 @@ - {% for lane in flowcell.lane_set.all %} + {% for lane in lanes %} {{lane.lane_number}} diff --git a/htsworkflow/frontend/urls.py b/htsworkflow/frontend/urls.py index 9495ad9..23423db 100644 --- a/htsworkflow/frontend/urls.py +++ b/htsworkflow/frontend/urls.py @@ -26,9 +26,9 @@ urlpatterns = patterns('', # Experiments: (r'^experiments/', include('htsworkflow.frontend.experiments.urls')), # Flowcell: - (r'^flowcell/(?P\w+)/(?P\w+)/', + (r'^lane/(?P\w+)', 'htsworkflow.frontend.experiments.views.flowcell_lane_detail'), - (r'^flowcell/(?P\w+)/$', + (r'^flowcell/(?P\w+)/((?P\w+)/)?$', 'htsworkflow.frontend.experiments.views.flowcell_detail'), # AnalysTrack: #(r'^analysis/', include('htsworkflow.frontend.analysis.urls')), -- 2.30.2