minor changes
authorRami Rauch <rrauch@stanford.edu>
Thu, 5 Mar 2009 19:22:14 +0000 (19:22 +0000)
committerRami Rauch <rrauch@stanford.edu>
Thu, 5 Mar 2009 19:22:14 +0000 (19:22 +0000)
htswfrontend/htswfrontend/fctracker/models.py

index 95b4a84f3c4a7f6ec0cfb305c17a867562b46e63..2b9aaebb7c106432b97a49027be19db452fca90a 100644 (file)
@@ -34,9 +34,9 @@ class Antibody(models.Model):
     verbose_name_plural = "antibodies"
     ordering = ["antigene"]
   class Admin:
-      search_fields = ['antigene','nickname','catalog','antibodies','source','biology','notes']
       list_display = ('antigene','nickname','antibodies','catalog','source','biology','notes')
       list_filter = ('antibodies','source')
+      search_fields = ['antigene','nickname','catalog','antibodies','source','biology','notes']
       fields = (
         (None, {
             'fields': (('antigene','nickname','antibodies'),('catalog','source'),('biology'),('notes'))
@@ -52,7 +52,7 @@ class Cellline(models.Model):
 
   class Meta:
     ordering = ["cellline_name"]
-
+    
   class Admin:
       list_display = ('cellline_name','nickname','notes')
       search_fields = ['cellline_name','nickname','notes']
@@ -123,7 +123,7 @@ class Affiliation(models.Model):
       )
 
 class Tag(models.Model):
-  tag_name = models.CharField(max_length=100, unique=True,db_index=True,core=True,blank=False,null=False)
+  tag_name = models.CharField(max_length=100,unique=True, db_index=True,core=True,blank=False,null=False)
   TAG_CONTEXT = (
       #('Antibody','Antibody'),
       #('Cellline', 'Cellline'),
@@ -157,7 +157,7 @@ class Library(models.Model):
   # New field Aug/25/08. SQL: alter table fctracker_library add column "lib_affiliation" varchar(256)  NULL;
   affiliations = models.ManyToManyField(Affiliation,related_name='library_affiliations',null=True,filter_interface=models.HORIZONTAL)
   # New field Nov/14/08
-  tags = models.ManyToManyField(Tag,related_name='library_tags',blank=True,null=True,filter_interface=models.HORIZONTAL)
+  tags = models.ManyToManyField(Tag,related_name='library_tags',null=True,blank=True,filter_interface=models.HORIZONTAL)
   # New field Aug/19/08
   # SQL to add column: alter table fctracker_library add column "replicate" smallint unsigned NULL;
   REPLICATE_NUM = ((1,1),(2,2),(3,3),(4,4))
@@ -242,30 +242,35 @@ class Library(models.Model):
   def aligned_reads(self):
     res = getLibReads(self.library_id)
 
-    # Check data sanlty
+    # Check data sanlty                                                                                                                                    
     if res[2] != 'OK':
       return '<div style="border:solid red 2px">'+res[2]+'</div>'
 
     rc = "%1.2f" % (res[1]/1000000.0)
     # Color Scheme: green is more than 12M, blue is more than 5M, orange is more than 3M and red is less. For RNAseq, all those thresholds should be doubled
-    if res[0] > 0:
-      bgcolor = '#FFCDD0'  # Red, the color for minimum read count
-      rc_thr = [12000000,5000000,3000000]
-      if self.experiment_type == 'RNA-seq':
-        rc_thr = [20000000,10000000,6000000]
 
+    bgcolor = '#FFCDD0'  # Red, the color for minimum read count
+    rc_thr = [12000000,5000000,3000000]
+    if self.experiment_type == 'RNA-seq':
+      rc_thr = [20000000,10000000,6000000]
+
+    if self.libtags().find('Bad library')!=-1:
+      bgcolor = '#cccccc'
+    else:
       if res[1] > rc_thr[0]:
-        bgcolor = '#66ff66'  # Green
+        bgcolor = '#66ff66'  # Green                                                                                                                                                                                                      
       else:
         if res[1] > rc_thr[1]:
-          bgcolor ='#00ccff'  # Blue
+          bgcolor ='#00ccff'  # Blue                                                                                                                                                                                                  
         else:
-           if res[1] > rc_thr[2]: 
+           if res[1] > rc_thr[2]:
              bgcolor ='#ffcc33'  # Orange
-      tstr = '<div style="background-color:'+bgcolor+';color:black">'
-      tstr += res[0].__str__()+' Lanes, '+rc+' M'
-      tstr += '</div>'
-    else: tstr = 'not processed yet' 
+
+    tstr = '<div style="background-color:'+bgcolor+';color:black">'
+    if res[0] > 0:  tstr += res[0].__str__()+' Lanes, '+rc+' M'
+    else: tstr += 'not processed yet'
+    tstr += '</div>'
     return tstr
   aligned_reads.allow_tags = True