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)
+
+ def __unicode__(self):
+ return unicode(self.name)
+
+class Sequencer(models.Model):
+ name = models.CharField(max_length=50, unique=True)
+
+ def __unicode__(self):
+ return unicode(self.name)
+
+default_pM = 5
+try:
+ default_pM = int(options.get('frontend', 'default_pm'))
+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)
run_date = models.DateTimeField()
advanced_run = models.BooleanField(default=False)
+ paired_end = models.BooleanField(default=False)
read_length = models.IntegerField(default=32) #Stanford is currenlty 25
lane_1_library = models.ForeignKey(Library, related_name="lane_1_library")
lane_7_library = models.ForeignKey(Library, related_name="lane_7_library")
lane_8_library = models.ForeignKey(Library, related_name="lane_8_library")
- lane_1_pM = models.DecimalField(max_digits=5, decimal_places=2,blank=False, null=False,default=2.5)
- lane_2_pM = models.DecimalField(max_digits=5, decimal_places=2,blank=False, null=False,default=2.5)
- lane_3_pM = models.DecimalField(max_digits=5, decimal_places=2,blank=False, null=False,default=2.5)
- lane_4_pM = models.DecimalField(max_digits=5, decimal_places=2,blank=False, null=False,default=2.5)
- lane_5_pM = models.DecimalField(max_digits=5, decimal_places=2,blank=False, null=False,default=2.5)
- lane_6_pM = models.DecimalField(max_digits=5, decimal_places=2,blank=False, null=False,default=2.5)
- lane_7_pM = models.DecimalField(max_digits=5, decimal_places=2,blank=False, null=False,default=2.5)
- lane_8_pM = models.DecimalField(max_digits=5, decimal_places=2,blank=False, null=False,default=2.5)
+ lane_1_pM = models.DecimalField(max_digits=5, decimal_places=2,blank=False, null=False,default=default_pM)
+ lane_2_pM = models.DecimalField(max_digits=5, decimal_places=2,blank=False, null=False,default=default_pM)
+ lane_3_pM = models.DecimalField(max_digits=5, decimal_places=2,blank=False, null=False,default=default_pM)
+ lane_4_pM = models.DecimalField(max_digits=5, decimal_places=2,blank=False, null=False,default=default_pM)
+ lane_5_pM = models.DecimalField(max_digits=5, decimal_places=2,blank=False, null=False,default=default_pM)
+ lane_6_pM = models.DecimalField(max_digits=5, decimal_places=2,blank=False, null=False,default=default_pM)
+ lane_7_pM = models.DecimalField(max_digits=5, decimal_places=2,blank=False, null=False,default=default_pM)
+ lane_8_pM = models.DecimalField(max_digits=5, decimal_places=2,blank=False, null=False,default=default_pM)
lane_1_cluster_estimate = models.IntegerField(blank=True, null=True)
lane_2_cluster_estimate = models.IntegerField(blank=True, null=True)
# lane_7_primer = models.ForeignKey(Primer,blank=True,null=True,related_name="lane_7_primer")
# lane_8_primer = models.ForeignKey(Primer,blank=True,null=True,related_name="lane_8_primer")
- #Machine Names
- CLUSTER_MAC = (
- ('M304','Cardinal'),
- ('R349','R349'),
- ('Tinkerbell','Tinkerbell'),
- ('BitBit','BitBit'),
- )
-
- SEQ_MAC = (
- ('EAS149','Stanford'),
- ('EAS46','EAS46'),
- ('EAS45','Paris'),
- ('Britney','Britney'),
- )
-
- cluster_mac_id = models.CharField(max_length=50, choices=CLUSTER_MAC, default='BitBit')
- seq_mac_id = models.CharField(max_length=50, choices=SEQ_MAC, verbose_name = 'Sequencer', default='Britney')
+ cluster_station = models.ForeignKey(ClusterStation, default=3)
+ sequencer = models.ForeignKey(Sequencer, default=1)
notes = models.TextField(blank=True)
return unicode(self.flowcell_id)
def Create_LOG(self):
- str = '' #<span style="color:red;font-size:80%;margin-right:3px">New!</span>'
+ str = ''
str +='<a target=_balnk href="/experiments/'+self.flowcell_id+'" title="Create XLS like sheet for this Flowcell ..." ">Create LOG</a>'
+ try:
+ t = DataRun.objects.get(fcid=self.id)
+ str +='<br/><a target=_self href="/admin/experiments/datarun/?q='+self.flowcell_id+'" title="Check Data Runs ..." ">DataRun ..</a>'
+ except ObjectDoesNotExist:
+ str += '<br/><span style="color:red">not sequenced</span>'
return str
Create_LOG.allow_tags = True
def Lanes(self):
- return '<div><span style="margin-right:10px">1)%s</span><span style="margin-right:10px">2)%s</span><span style="margin-right:10px">3)%s</span><span style="margin-right:10px">4)%s</span><span style="margin-right:10px">5)%s</span><span style="margin-right:10px">6)%s</span><span style="margin-right:10px">7)%s</span><span style="margin-right:10px">8)%s</span></div>' % (self.lane_1_library,self.lane_2_library,self.lane_3_library,self.lane_4_library,self.lane_5_library,self.lane_6_library,self.lane_7_library,self.lane_8_library)
+ library_url = '/admin/samples/library/%s'
+ html = ['<table>']
+ for i in range(1,9):
+ cluster_estimate = getattr(self, 'lane_%d_cluster_estimate' % (i,))
+ if cluster_estimate is not None:
+ cluster_estimate = "%s k" % ((int(cluster_estimate)/1000), )
+ else:
+ cluster_estimate = 'None'
+ library_id = getattr(self, 'lane_%d_library_id' % (i,))
+ library = getattr(self, 'lane_%d_library' % i)
+ element = '<tr><td>%d</td><td><a href="%s">%s</a></td><td>%s</td></tr>'
+ expanded_library_url = library_url %(library_id,)
+ html.append(element % (i, expanded_library_url, library, cluster_estimate))
+ html.append('</table>')
+ return "\n".join(html)
Lanes.allow_tags = True
-
-
+ class Meta:
+ ordering = ["-run_date"]
+
### -----------------------
class DataRun(models.Model):
ConfTemplate = "CONFIG PARAMS WILL BE GENERATED BY THE PIPELINE SCRIPT.\nYOU'LL BE ABLE TO EDIT AFTER IF NEEDED."
str += ' style="color:green">'
str += '<b>'+self.RUN_STATUS_CHOICES[self.run_status][1]+'</b>'
str += '<br/><br/>' #<span style="color:red;font-size:80%;">New!</span>'
- str +='<br/><a target=_balnk href="http://m304-apple-server.stanford.edu/'+self.fcid.flowcell_id+'_QC/'+self.fcid.flowcell_id+'_'+self.run_folder+'_QC_Summary.html" title="View QC Summaries of this run ..." ">View QC Page</a>'
+ str +='<br/><a target=_balnk href="'+settings.TASKS_PROJS_SERVER+'/Flowcells/'+self.fcid.flowcell_id+'/'+self.fcid.flowcell_id+'_QC_Summary.html" title="View QC Summaries of this run ..." ">View QC Page</a>'
else:
str += '>'+self.RUN_STATUS_CHOICES[self.run_status][1]
return str
Flowcell_Info.allow_tags = True
+
+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)])
+ 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)
+ comment = models.TextField(null=True, blank=True)