from django.db import models
from htswfrontend import settings
+from htswfrontend.htsw_reports.libinfopar import *
class Primer(models.Model):
primer_name = models.CharField(max_length=100, db_index=True)
class Meta:
verbose_name_plural = "libraries"
- ordering = ["-library_id"]
+ ordering = ["-creation_date"] #["-library_id"]
def antibody_name(self):
return self.antibody.nickname
+ def org(self):
+ return self.library_species.common_name
+
def affiliation(self):
affs = self.affiliations.all().order_by('name')
tstr = ''
ar.append(t.__str__())
return '%s' % (", ".join(ar))
+
+ def aligned_reads(self):
+ res = getLibReads(self.library_id)
+ rc = "%1.2f" % (res[1]/1000000.0)
+ # Color Scheme: green is more than 10M, 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 = '#ff3300' # Red
+ rc_thr = [10000000,5000000,3000000]
+ if self.experiment_type == 'RNA-seq':
+ rc_thr = [20000000,10000000,6000000]
+
+ if res[1] > rc_thr[0]:
+ bgcolor = '#66ff66' # Green
+ else:
+ if res[1] > rc_thr[1]:
+ bgcolor ='#00ccff' # Blue
+ else:
+ if res[1] > rc_thr[2]:
+ bgcolor ='#ffcc33' # Orange
+ tstr = '<div style="background-color:'+bgcolor+';color:black">'
+ tstr += res[0].__str__()+' Lanes, '+rc+' M Reads'
+ tstr += '</div>'
+ else: tstr = 'not processed yet'
+ return tstr
+ aligned_reads.allow_tags = True
+
class Admin:
date_hierarchy = "creation_date"
save_as = True
save_on_top = True
##search_fields = ['library_id','library_name','affiliations__name','affiliations__contact','made_by','made_for','antibody__antigene','antibody__catalog','antibody__antibodies','antibody__source','cell_line__cellline_name','library_species__scientific_name','library_species__common_name','library_species__use_genome_build']
search_fields = ['library_id','library_name','cell_line__cellline_name','library_species__scientific_name','library_species__common_name','library_species__use_genome_build']
- list_display = ('affiliation','library_id', 'library_name','experiment_type','replicate','antibody_name','cell_line','made_by','creation_date')
+ list_display = ('affiliation','library_id','aligned_reads','library_name','experiment_type','org','replicate','antibody_name','cell_line','made_by','creation_date')
list_display_links = ('library_id', 'library_name')
list_filter = ('experiment_type','affiliations','library_species','made_for', 'made_by','replicate')
fields = (