Added 'lanes_for' which will show recent flowcell lanes ordered by date,
[htsworkflow.git] / htsworkflow / frontend / experiments / models.py
index a32d0bdb9ee76d1c924a42bf9d41fbd28222228b..9329add350cf36dc14887dc68dd44981bcd8231d 100755 (executable)
@@ -1,8 +1,11 @@
+import logging
+
+from django.core.exceptions import ObjectDoesNotExist
+from django.core import urlresolvers
 from django.db import models
+
 from htsworkflow.frontend.samples.models import *
 from htsworkflow.frontend.settings import options
-from django.core.exceptions import ObjectDoesNotExist
-import logging
 
 class ClusterStation(models.Model):
   name = models.CharField(max_length=50, unique=True)
@@ -22,9 +25,6 @@ try:
 except ValueError,e:
   logging.error("invalid value for frontend.default_pm")
 
-
-  
-
 class FlowCell(models.Model):
   
   flowcell_id = models.CharField(max_length=20, unique=True, db_index=True)
@@ -32,6 +32,7 @@ class FlowCell(models.Model):
   advanced_run = models.BooleanField(default=False)
   paired_end = models.BooleanField(default=False)
   read_length = models.IntegerField(default=32) #Stanford is currenlty 25
+  control_lane = models.IntegerField(choices=[(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8)], null=True)
 
   cluster_station = models.ForeignKey(ClusterStation, default=3)
   sequencer = models.ForeignKey(Sequencer, default=1)
@@ -73,7 +74,21 @@ class FlowCell(models.Model):
 
   class Meta:
     ordering = ["-run_date"]
-  
+
+  def get_admin_url(self):
+    # that's the django way... except it didn't work
+    #return urlresolvers.reverse('admin_experiments_FlowCell_change', args=(self.id,))
+    return '/admin/experiments/flowcell/%s/' % (self.id,)
+
+  def flowcell_type(self):
+    """
+    Convert our boolean 'is paired' flag to a name
+    """
+    if self.paired_end:
+      return u"Paired"
+    else:
+      return u"Single"
+    
 ### -----------------------
 class DataRun(models.Model):
   ConfTemplate = "CONFIG PARAMS WILL BE GENERATED BY THE PIPELINE SCRIPT.\nYOU'LL BE ABLE TO EDIT AFTER IF NEEDED."