Start supporting multiple libraries per lane, as needed for the HiSeq
authorDiane Trout <diane@caltech.edu>
Tue, 28 Jun 2011 00:18:16 +0000 (17:18 -0700)
committerDiane Trout <diane@caltech.edu>
Tue, 28 Jun 2011 00:18:16 +0000 (17:18 -0700)
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
htsworkflow/frontend/experiments/fixtures/test_flowcells.json
htsworkflow/frontend/experiments/models.py
htsworkflow/frontend/experiments/views.py
htsworkflow/frontend/samples/tests.py
htsworkflow/frontend/templates/experiments/flowcell_detail.html
htsworkflow/frontend/urls.py

index 4181e5c91aef2aa0d2a7af9b2d0bddcc37ad65e6..fa0f15d0141a4473fc02098049d47bea1c3f2900 100644 (file)
@@ -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',)
index 46c8e1d6131f2462150f624a7a254b65d39a6c34..1afd74e1f9299e836c81d175f29a3e679c173662 100644 (file)
        "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, 
index f6bac3f3fc23135db33b37d9564e6ca2bed46fbb..3e8cc867af70da49d3ba85d6b2431536563ebf31 100755 (executable)
@@ -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):
index a1775d4cb489dd18926e0e1e56e655a3edb88c2a..08ce6f0e93d0255b72fac17b9ddb39655d081d57 100755 (executable)
@@ -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',
index b6e8f9893f12b8d7f33d4a9c23822cf56fdfb22c..93f46d017041642a733edc15d2c0324534f7d62f 100644 (file)
@@ -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,
index 6e112f850ed9dfa7e5073149ffce00e2c3ba6fae..865fc97a05fd16725e1556df6e1747eb38fe686a 100644 (file)
@@ -38,7 +38,7 @@
        </tr>
       </thead>
       <tbody>
-      {% for lane in flowcell.lane_set.all %}
+      {% for lane in lanes %}
         <tr rel="libns:has_lane" resource="{{lane.get_absolute_url}}" >
           <td><a href="{{lane.get_absolute_url}}"> 
               <span property="libns:lane_number">{{lane.lane_number}}</span></a></td>
index 9495ad98c08103b22a05046d8c9a7de58f362d4d..23423dbd5c64bd654985fedf452d8b966f09fe4a 100644 (file)
@@ -26,9 +26,9 @@ urlpatterns = patterns('',
     # Experiments:
     (r'^experiments/', include('htsworkflow.frontend.experiments.urls')),
     # Flowcell:
-    (r'^flowcell/(?P<flowcell_id>\w+)/(?P<lane_number>\w+)/',
+    (r'^lane/(?P<lane_pk>\w+)',
      'htsworkflow.frontend.experiments.views.flowcell_lane_detail'),
-    (r'^flowcell/(?P<flowcell_id>\w+)/$',
+    (r'^flowcell/(?P<flowcell_id>\w+)/((?P<lane_number>\w+)/)?$',
      'htsworkflow.frontend.experiments.views.flowcell_detail'),
     # AnalysTrack:
     #(r'^analysis/', include('htsworkflow.frontend.analysis.urls')),