1 from htswfrontend.exp_track.models import *
2 from django.http import HttpResponse
3 from django.core.exceptions import ObjectDoesNotExist
4 from django.shortcuts import render_to_response, get_object_or_404
6 arMonth = {"01":"Jan","02":"Feb","03":"Mar","04":"Apr","05":"May","06":"Jun","07":"Jul","08":"Aug","09":"Sep","10":"Oct","11":"Nov","12":"Dec"}
7 def getBgColor(reads_cnt,exp_type):
8 # 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 are ~ double
9 bgcolor = '#ffcdd0' # Red is the color for minimum read counts
10 rc_thr = [12000000,5000000,3000000] # Default for ChIP-Seq and Methyl-Seq
11 if exp_type == 'RNA-seq':
12 rc_thr = [20000000,10000000,6000000]
14 if reads_cnt > rc_thr[0]:
15 bgcolor = '#66ff66' # Green
17 if reads_cnt > rc_thr[1]:
18 bgcolor ='#00ccff' # Blue
20 if reads_cnt > rc_thr[2]:
21 bgcolor ='#ffcc33' # Orange
22 #tstr = '<div style="background-color:'+bgcolor+';color:black">'
23 #tstr += res[0].__str__()+' Lanes, '+rc+' M Reads'
28 def q_report1(request):
29 if not request.user.is_authenticated():
30 str = '<span style="margin-right:20px"><a target=_self href="/admin" target=_self style="font-size:140%">Please log in first</a></span>'
31 return render_to_response('htsw_reports/report.html',{'main':str})
35 if request.has_key('aflid'):
36 AFL_Id = request['aflid']
38 AFL = Affiliation.objects.get(id=AFL_Id).name
39 AFL_CNT = Affiliation.objects.get(id=AFL_Id).contact
40 except ObjectDoesNotExist:
41 return HttpResponse("ERROR: Affiliation Record Not Found for: '"+AFL_Id+"'")
46 AFL_Id = Affiliation.objects.get(name=AFL,contact=AFL_CNT).id.__str__()
47 except ObjectDoesNotExist:
48 return HttpResponse("ERROR: Affiliation Record Not Found for: '"+AFL+"'")
50 if request.user.username == 'caltech':
51 if AFL.find('ENCODE') < 0: return HttpResponse('Record Not Found <div style="margin-right:20px"><a target=_self href="/admin" target=_self>HOME</a></div>')
53 ### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Q REPORT PART ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
54 start_date = datetime(2009,01,01).date().__str__()
55 end_date = datetime(2011,01,01)
58 if request.has_key('start_date'):
59 start_date = request['start_date']
61 if request.has_key('end_date'):
62 end_date = request['end_date']
63 else: #end_date = today
64 end_date = end_date.now().date().__str__()
65 end_date_text = ' (Today)'
68 if start_date and end_date:
69 start_date = datetime(int(start_date.split('-')[0]),int(start_date.split('-')[1]),int(start_date.split('-')[2]),0,0,0)
70 end_date = datetime(int(end_date.split('-')[0]),int(end_date.split('-')[1]),int(end_date.split('-')[2]),0,0,0)
71 DRuns = DataRun.objects.filter(run_start_time__range=(start_date, end_date))
74 QReportText += '<div><span style="margin-right:20px"><a target=_self href="/admin" target=_self style="font-size:140%">HOME</a></span><h2>Time Report Generator for ChIP-Seq</h2></div>'
75 QReportText += '<form action="" method="get" id="qreport_form">'
77 QReportText += EXP+' <select onchange="window.location=\'/htsw_reports/q_report?start_date='+start_date.date().__str__()+'&end_date='+end_date.date().__str__()+'&aflid=\'+this.options[selectedIndex].value; return false;">'
79 if request.user.username == 'caltech':
80 Affil_List = Affiliation.objects.filter(name__contains='ENCODE').distinct()
82 Affil_List = Affiliation.objects.distinct()
85 QReportText += '<option value='+af.id.__str__()
86 if AFL_Id == af.id.__str__():
87 QReportText += ' selected'
88 QReportText += '>'+af.name+' '+af.contact+'</option>'
89 QReportText += '</select>'
90 QReportText += ' Start Date: '
91 QReportText += '<input type="text" maxlength="10" value="'+start_date.date().__str__()+'" size="10" name="start_date" />' # class="vDateField" />' # id="id_run_start_time_date"/>'
92 QReportText += ' End Date: <input type="text" maxlength="10" value="'+end_date.date().__str__()+'" size="10" name="end_date" />'
93 #QReportText += '<span><a href="javascript:DateTimeShortcuts.handleCalendarQuickLink(0, 0);">Today</a> | <a href="javascript:DateTimeShortcuts.openCalendar(0);" id="calendarlink0">'
94 #QReportText += '<img src="http://myerslab.stanford.edu/media/img/admin/icon_calendar.gif" alt="Calendar"/></a></span>'
95 #QReportText += 'End Date: <input type="text" maxlength="10" value="" size="10" name="end_date" class="vDateField required" id="end_date"/><span><a href="javascript:DateTimeShortcuts.handleCalendarQuickLink(0, 0);">Today</a> | <a href="javascript:DateTimeShortcuts.openCalendar(0);" id="calendarlink0"><img src="http://myerslab.stanford.edu/media/img/admin/icon_calendar.gif" alt="Calendar"/></a></span>'
96 QReportText += '<span style="margin-left:10px"><input type="submit" value="Run Report" name="runreport" /></span></p>'
98 QReportText +='<div style="border:solid #cccccc 1px;padding:2px;background-color:#FFFFCC;margin-top:5px">'
99 s_year = start_date.date().__str__().split("-")[0]
100 s_month = start_date.date().__str__().split("-")[1]
101 s_day = start_date.date().__str__().split("-")[2]
102 e_year = end_date.date().__str__().split("-")[0]
103 e_month = end_date.date().__str__().split("-")[1]
104 e_day = end_date.date().__str__().split("-")[2]
105 QReportText += '<h2>For <u>'+AFL+'</u> <u>'+AFL_CNT+'</u>'+' between <u>'+s_year+'-'+arMonth[s_month]+'-'+s_day+'</u> and <u>'+e_year+'-'+arMonth[e_month]+'-'+e_day+end_date_text+'</u></h2>'
106 QReportText +='<div style="float:left">'
107 FCText = '<h4>The following Flowcells were sequenced:</h4>'
108 FCText += '<table border=1><tr><th>Flowcell Id</th><th>Ran On</th></tr>'
113 libidlist.append(DR.fcid.lane_1_library.library_id)
114 #if LIB_LANE_COUNT.has_key(DR.fcid.lane_1_library.library_id): LIB_LANE_COUNT[DR.fcid.lane_1_library.library_id] += 1
115 #else: LIB_LANE_COUNT[DR.fcid.lane_1_library.library_id] = 1
116 libidlist.append(DR.fcid.lane_2_library.library_id)
117 #if LIB_LANE_COUNT.has_key(DR.fcid.lane_2_library.library_id): LIB_LANE_COUNT[DR.fcid.lane_2_library.library_id] += 1
118 #else: LIB_LANE_COUNT[DR.fcid.lane_2_library.library_id] = 1
119 libidlist.append(DR.fcid.lane_3_library.library_id)
120 #if LIB_LANE_COUNT.has_key(DR.fcid.lane_3_library.library_id): LIB_LANE_COUNT[DR.fcid.lane_3_library.library_id] += 1
121 #else: LIB_LANE_COUNT[DR.fcid.lane_3_library.library_id] = 1
122 libidlist.append(DR.fcid.lane_4_library.library_id)
123 #if LIB_LANE_COUNT.has_key(DR.fcid.lane_4_library.library_id): LIB_LANE_COUNT[DR.fcid.lane_4_library.library_id] += 1
124 #else: LIB_LANE_COUNT[DR.fcid.lane_4_library.library_id] = 1
125 libidlist.append(DR.fcid.lane_5_library.library_id)
126 #if LIB_LANE_COUNT.has_key(DR.fcid.lane_5_library.library_id): LIB_LANE_COUNT[DR.fcid.lane_5_library.library_id] += 1
127 #else: LIB_LANE_COUNT[DR.fcid.lane_5_library.library_id] = 1
128 libidlist.append(DR.fcid.lane_6_library.library_id)
129 #if LIB_LANE_COUNT.has_key(DR.fcid.lane_6_library.library_id): LIB_LANE_COUNT[DR.fcid.lane_6_library.library_id] += 1
130 #else: LIB_LANE_COUNT[DR.fcid.lane_6_library.library_id] = 1
131 libidlist.append(DR.fcid.lane_7_library.library_id)
132 #if LIB_LANE_COUNT.has_key(DR.fcid.lane_7_library.library_id): LIB_LANE_COUNT[DR.fcid.lane_7_library.library_id] += 1
133 #else: LIB_LANE_COUNT[DR.fcid.lane_7_library.library_id] = 1
134 libidlist.append(DR.fcid.lane_8_library.library_id)
135 #if LIB_LANE_COUNT.has_key(DR.fcid.lane_8_library.library_id): LIB_LANE_COUNT[DR.fcid.lane_8_library.library_id] += 1
136 #else: LIB_LANE_COUNT[DR.fcid.lane_8_library.library_id] = 1
138 if LIB_LANE_COUNT.has_key(eval('DR.fcid.lane_'+i.__str__()+'_library.library_id')): LIB_LANE_COUNT[eval('DR.fcid.lane_'+i.__str__()+'_library.library_id')] += 1
139 else: LIB_LANE_COUNT[eval('DR.fcid.lane_'+i.__str__()+'_library.library_id')] = 1
140 if LIB_FC_SUMMARY.has_key(eval('DR.fcid.lane_'+i.__str__()+'_library.library_id')): LIB_FC_SUMMARY[eval('DR.fcid.lane_'+i.__str__()+'_library.library_id')] += '<br/>'+DR.fcid.flowcell_id+' (lane '+i.__str__()+')'
141 else: LIB_FC_SUMMARY[eval('DR.fcid.lane_'+i.__str__()+'_library.library_id')] = DR.fcid.flowcell_id+' (lane '+i.__str__()+')'
143 FCText += '<tr><td>'+DR.fcid.flowcell_id+'</td><td>'+DR.run_start_time.__str__()+'</td></tr>'
147 ## RelevantLibs = Library.objects.filter(experiment_type=EXP,affiliations__name=AFL,affiliations__contact=AFL_CNT,library_id__in=libidlist).order_by('antibody','cell_line')
149 if EXP == 'ChIP-seq':
150 RelevantLibs = Library.objects.filter(experiment_type__in=[EXP,'INPUT_RXLCh'],affiliations__name=AFL,affiliations__contact=AFL_CNT,library_id__in=libidlist).order_by('antibody','cell_line')
152 RelevantLibs = Library.objects.filter(experiment_type=EXP,affiliations__name=AFL,affiliations__contact=AFL_CNT,library_id__in=libidlist).order_by('antibody','cell_line')
156 QReportText +='<div style="float:left">'
157 QReportText += '<h4>'
159 QReportText += 'The following <u>'+len(RelevantLibs).__str__()+'</u> '
162 QReportText += EXP+' Libraries were sequenced:</h4>'
163 QReportText += '<div style="width:200px;background-color:#cccccc;font-size:90%">(bad libraries marked in grey)</div>'
164 QReportText += '<table border=1><tr><th>Library Id</th><th>Antibody</th><th>Cell line</th><th>Condition</th><th>Replicate</th><th>Lanes ran (during this period)</th></tr>'
165 for rlib in RelevantLibs:
167 if rlib.libtags().find('Bad library')!=-1: bgColor='#cccccc'
168 QReportText += '<tr style="background-color:'+bgColor+'"><td><a title="View Library Record" target=_self href=/admin/fctracker/library/?q='+rlib.library_id+'>'+rlib.library_id+'</a></td>'
169 if rlib.antibody is not None: QReportText += '<td>'+rlib.antibody.nickname+'</td>'
171 if rlib.experiment_type == 'INPUT_RXLCh': QReportText += '<td>[INPUT_RXLCh]</td>'
172 else: QReportText += '<td>none</td>'
174 QReportText += '<td>'+rlib.cell_line.nickname+'</td>'
175 QReportText += '<td>'+rlib.condition.nickname+'</td>'
176 QReportText += '<td>Rep'+rlib.replicate.__str__()+'</td>'
177 QReportText += '<td><a title="View Data Runs Record" target=_self href=/admin/exp_track/datarun/?q='+rlib.library_id+'&run_start_time__gte='+start_date.date().__str__()+'&run_start_time__lte='+end_date.date().__str__()+'>'+LIB_LANE_COUNT[rlib.library_id].__str__()+' lanes</a>'
178 QReportText += '<span style="margin-left:40px;cursor:pointer;color:#5B80B2" onClick="el=document.getElementById(\'d_'+rlib.library_id+'\');if(el){el.style.display=(el.style.display==\'none\'?\'block\':\'none\');}">details..</span><div id=d_'+rlib.library_id+' style="display:none;border:solid 1px #cccccc;padding:3px;width:150px;max-hight:200px;overflow:auto">'+LIB_FC_SUMMARY[rlib.library_id]+'</div>'
179 QReportText += '</td>'
180 QReportText += '</tr>'
182 QReportText += '</table>'
183 QReportText +='</div>'
184 QReportText +='<div style="float:left;margin-left:100px">'+FCText+'</div>'
186 QReportText += '</div>'
188 return render_to_response('htsw_reports/report.html',{'main': QReportText})
189 ###~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ END OF Q REPORT ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
191 TFall = Library.objects.values('antibody').order_by('antibody').distinct()
192 CLLall = Library.objects.values('cell_line').order_by('cell_line').distinct()
194 TFs = TFall.filter(experiment_type=EXP,affiliations__name=AFL,affiliations__contact=AFL_CNT,library_id__in=libidlist)
195 CLLs = CLLall.filter(experiment_type=EXP,affiliations__name=AFL,affiliations__contact=AFL_CNT)
197 # Check Replicate numbers
199 RepRecs = Library.objects.filter(experiment_type=EXP,affiliations__name=AFL,affiliations__contact=AFL_CNT).order_by('-replicate')
200 if len(RepRecs) > 0: Reps = RepRecs[0].replicate
204 str += '<span style="margin-right:20px"><a target=_self href="/admin" target=_self style="font-size:140%">HOME</a></span>'
205 ##str += '<span style="margin-right:20px">Max Replicates: '+MaxRep.replicate.__str__()+'</span>'
206 str += '<span>Select another <b>'+EXP+'</b> Report:</span> <select onchange="window.location=\'/htsw_reports/report?aflid=\'+this.options[selectedIndex].value; return false;">'
207 for af in Affiliation.objects.distinct():
208 str += '<option value='+af.id.__str__()
209 if AFL_Id == af.id.__str__():
211 str += '>'+af.name+' '+af.contact+'</option>'
214 str += '<span style="margin-left:20px;padding:1px;border:solid #cccccc 1px">color scheme: <span style="margin-left:5px;background-color:#66ff66"> > 12 M</span><span style="margin-left:5px;background-color:#00ccff"> > 5 M</span><span style="margin-left:5px;background-color:#ffcc33"> > 3 M</span><span style="margin-left:5px;background-color:#ffcdd0"> < 3 M</span></span>'
216 str += '<span style="margin-left:20px">'
217 str += '<u>Switch to:</u> '+AFL+' '+AFL_CNT+' <a target=_self href="/htsw_reports/report_RM?exp=RNA-seq&aflid='+AFL_Id+'"><b>RNA-Seq</b> Report</a>'
219 str += '<a target=_self href="/htsw_reports/report_RM?exp=Methyl-seq&aflid='+AFL_Id+'"><b>Methyl-Seq</b> Report</a>'
220 str += '<span style="margin-left:20px">(db: '+settings.DB_NAME+')</span>'
226 str += '<table border=1 style="margin-top:5px">'
227 str += '<tr><th style="text-align:right">PROJECT</th><th colspan='+(Reps*len(CLLs)).__str__()+' style="text-align:center">'+AFL+' '+AFL_CNT+' <span style="font-size:140%">'+EXP+'</span></th></tr>'
228 str += '<tr><th style="text-align:right">CELL LINE</th>'
230 str += '<th colspan='+Reps.__str__()+' style="text-align:center;background-color:'+bgc+'">'+Cellline.objects.get(id=H['cell_line']).cellline_name+'</th>'
234 str += '</tr><tr><th style="text-align:left">TF</th>'
238 for r in range(1,Reps+1):
239 str += '<th style="text-align:center;background-color:'+bgc+'">Rep. '+r.__str__()+'</th>'
244 str += '<tr><td align=right><a title="View Libraries Records" target=_self href=/admin/fctracker/library/?affiliations__id__exact='+AFL_Id+'&experiment_type__exact=INPUT_RXLCh>Total Chromatin</a></td>'
248 for r in range(1,Reps+1):
249 repReads = Library.objects.filter(experiment_type='INPUT_RXLCh',affiliations__name=AFL,affiliations__contact=AFL_CNT,cell_line=H['cell_line'].__str__(),replicate=r,library_id__in=libidlist)
251 ### TO DO: Replace the above query with: Get DataRuns by StartRunDate BETWEEN FROM_DATE and TO_DATE, Get DataRun.Flowcell.Library records.
253 str += "<td align=center style='background-color:"+bgc+"'>"
254 if len(repReads) == 0:
255 str += 'No Libraries'
259 rres = R1.aligned_m_reads()
262 str += '<div style="border:solid red 2px">'+rres[2]
266 str += "<div style='background-color:"+getBgColor(cnt,EXP)+";font-size:140%'>"
267 str += "%1.2f" % (cnt/1000000.0)+" M"
268 else: str += "<div style='background-color:#ffcdd0;width:100%;font-size:140%'>0 Reads"
269 str += "<div style='font-size:70%'><a title='View Library Record' target=_self style='font-weight:bold;color:black' href=/admin/fctracker/library/?q="+R1.library_id+">"+R1.library_id+" ("+rres[0].__str__()+" lanes)</a>, "+R1.condition.nickname
270 if R1.libtags().find('Data submitted to DCC') != -1:
271 str += "<div style='border:solid #666666 1px;'>data submitted</div>"
284 str += '<td><a title="View Libraries Records" target=_self href=/admin/fctracker/library/?affiliations__id__exact='+AFL_Id+'&antibody__id__exact='+T['antibody'].__str__()+'>'+Antibody.objects.get(id=T['antibody']).nickname+'</a></td>'
285 except Antibody.DoesNotExist:
286 str += '<td>n/a</td>'
291 for r in range(1,Reps+1):
292 repReads = Library.objects.filter(experiment_type=EXP,affiliations__name=AFL,affiliations__contact=AFL_CNT,cell_line=H['cell_line'].__str__(),antibody=T['antibody'].__str__(),replicate=r,library_id__in=libidlist)
293 str += "<td align=center style='background-color:"+bgc+"'>"
294 if len(repReads) == 0:
295 str += 'No Libraries'
299 rres = R1.aligned_m_reads()
302 str += '<div style="border:solid red 2px">'+rres[2]
306 str += "<div style='background-color:"+getBgColor(cnt,EXP)+";font-size:140%;margin:2px'>"
307 str += "%1.2f" % (cnt/1000000.0)+" M"
308 else: str += "<div style='background-color:#ffcdd0;width:100%;font-size:140%'>0 Reads"
309 str += "<div style='font-size:70%'><a title='View Library Record' target=_self style='font-weight:bold;color:black' href=/admin/fctracker/library/?q="+R1.library_id+">"+R1.library_id+" ("+rres[0].__str__()+" lanes)</a>, "+R1.condition.nickname
310 if R1.libtags().find('Data submitted to DCC') != -1:
311 str += "<div style='border:solid #666666 1px;'>data submitted</div>"
321 return render_to_response('htsw_reports/report.html',{'main': str})
324 def report_RM(request): #for RNA-Seq and Methyl-Seq
325 if not request.user.is_authenticated():
326 str= '<span style="margin-right:20px"><a target=_self href="/admin" target=_self style="font-size:140%">Please log in first</a></span>'
327 return render_to_response('htsw_reports/report.html',{'main':str})
331 if request.has_key('exp'):
332 EXP = request['exp'] # Methyl-seq
334 if request.has_key('aflid'):
335 AFL_Id = request['aflid']
337 AFL = Affiliation.objects.get(id=AFL_Id).name
338 AFL_CNT = Affiliation.objects.get(id=AFL_Id).contact
339 except ObjectDoesNotExist:
340 return HttpResponse("ERROR: Affiliation Record Not Found for: '"+AFL_Id+"'")
345 AFL_Id = Affiliation.objects.get(name=AFL,contact=AFL_CNT).id.__str__()
346 except ObjectDoesNotExist:
347 return HttpResponse("ERROR: Affiliation Record Not Found for: '"+AFL+"'")
349 CLLall = Library.objects.values('cell_line').order_by('cell_line').distinct()
350 CLLs = CLLall.filter(experiment_type=EXP,affiliations__name=AFL,affiliations__contact=AFL_CNT)
353 # Check Replicate numbers
355 RepRecs = Library.objects.filter(experiment_type=EXP,affiliations__name=AFL,affiliations__contact=AFL_CNT).order_by('-replicate')
356 if len(RepRecs) > 0: Reps = RepRecs[0].replicate
359 str += '<span style="margin-right:20px"><a target=_self href="/admin" target=_self" style="font-size:140%">HOME</a></span>'
360 str += '<span>Select another <b>'+EXP+'</b> Report:</span> <select onchange="window.location=\'/htsw_reports/report_RM?exp='+EXP+'&aflid=\'+this.options[selectedIndex].value; return false;">'
361 for af in Affiliation.objects.distinct():
362 str += '<option value='+af.id.__str__()
363 if AFL_Id == af.id.__str__():
365 str += '>'+af.name+' '+af.contact+'</option>'
369 str += '<span style="margin-left:20px;padding:1px;border:solid #cccccc 1px">color scheme: <span style="margin-left:5px;background-color:#66ff66"> > 20 M</span><span style="margin-left:5px;background-color:#00ccff"> > 10 M</span><span style="margin-left:5px;background-color:#ffcc33"> > 6 M</span><span style="margin-left:5px;background-color:#ffcdd0"> < 6 M</span></span>'
370 str += '<span style="margin-left:20px">'
371 str += '<u>Switch to:</u> '+AFL+' '+AFL_CNT+' <a target=_self href="/htsw_reports/report?exp=RNA-seq&aflid='+AFL_Id+'"><b>ChIP-Seq</b> Report</a>'
373 str += '<a target=_self href="/htsw_reports/report_RM?exp=Methyl-seq&aflid='+AFL_Id+'"><b>Methyl-Seq</b> Report</a>'
375 str += '<span style="margin-left:20px;padding:1px;border:solid #cccccc 1px">color scheme: <span style="margin-left:5px;background-color:#66ff66"> > 12 M</span><span style="margin-left:5px;background-color:#00ccff"> > 5 M</span><span style="margin-left:5px;background-color:#ffcc33"> > 3 M</span><span style="margin-left:5px;background-color:#ffcdd0"> < 3 M</span></span>'
376 str += '<span style="margin-left:20px">'
377 str += '<u>Switch to:</u> '+AFL+' '+AFL_CNT+' <a target=_self href="/htsw_reports/report?exp=RNA-seq&aflid='+AFL_Id+'"><b>ChIP-Seq</b> Report</a>'
379 str += '<a target=_self href="/htsw_reports/report_RM?exp=RNA-seq&aflid='+AFL_Id+'"><b>RNA-Seq</b> Report</a>'
381 str += '<br/><br/><table border=1>'
382 str += '<tr><th colspan='+(Reps*len(CLLs)).__str__()+' style="text-align:center">'+AFL+' '+AFL_CNT+' <span style="font-size:140%">'+EXP+'</span></th></tr>'
387 str += '<th colspan='+Reps.__str__()+' style="text-align:center;background-color:'+bgc+'">'+Cellline.objects.get(id=H['cell_line']).cellline_name+'</th>'
395 for r in range(1,Reps+1):
396 str += '<th style="text-align:center;background-color:'+bgc+'">Rep. '+r.__str__()+'</th>'
406 for r in range(1,Reps+1):
407 repReads = Library.objects.filter(experiment_type=EXP,affiliations__name=AFL,affiliations__contact=AFL_CNT,cell_line=H['cell_line'],replicate=r)
408 str += "<td align=center valign=top style='background-color:"+bgc+"'>"
409 if len(repReads) == 0:
410 str += 'No Libraries'
414 rres = R1.aligned_m_reads()
417 str += '<div style="border:solid red 2px">'+rres[2]
421 str += "<div style='background-color:"+getBgColor(cnt,EXP)+";border:solid #cccccc 1px;font-size:140%'>"
422 str += "%1.2f" % (cnt/1000000.0)+" M"
423 else: str += "<div style='background-color:#ffcdd0;border:solid #cccccc 1px;width:100%;font-size:140%'>0 Reads"
424 str += "<div style='font-size:80%'><a title='View Record' style='color:black' target=_self href=/admin/fctracker/library/?q="+R1.library_id+">"+R1.library_id+" ("+rres[0].__str__()+" lanes)</a>, "+R1.condition.nickname+", "+R1.library_species.common_name+"</div>"
425 str += "<div style='font-size:70%'>\""+R1.library_name+"\""
426 if R1.libtags().find('Data submitted to DCC') != -1:
427 str += "<div style='width:75%;border:solid #666666 1px;'>data submitted</div>"
437 return render_to_response('htsw_reports/report.html',{'main': str})
439 def getNotRanFCs(request):
440 if not request.user.is_authenticated():
441 str= '<span style="margin-right:20px"><a target=_self href="/admin" target=_self style="font-size:140%">Please log in first</a></span>'
442 return render_to_response('htsw_reports/report.html',{'main':str})
444 FCall = FlowCell.objects.order_by('-run_date').distinct()
445 str = '<table><tr><th>FlowCell</th><th>Lanes</th><th>Creation Date</th></tr>'
448 t = DataRun.objects.get(fcid=f.id)
449 except ObjectDoesNotExist:
450 str += '<tr><td>'+f.flowcell_id+'</td><td>'+f.Lanes()+'</td><td>'+f.run_date.__str__()+'</td></tr>'
452 return render_to_response('htsw_reports/report.html',{'main':str})
454 def test_Libs(request):
455 if not request.user.is_authenticated():
456 str= '<span style="margin-right:20px"><a target=_self href="/admin" target=_self style="font-size:140%">Please log in first</a></span>'
457 return render_to_response('htsw_reports/report.html',{'main':str})
460 str += '<table border=1><tr><th>Lib ID</th><th>Current Libaray Name (Free Text)</th><th>Auto-composed Libaray Name (antibody + celline + libid + species + [replicate])</th></tr>'
461 allLibs = Library.objects.all()
462 #allLibs = Library.objects.filter(antibody__isnull=False)
465 str += '<td>'+L.library_id+'</td><td>'+L.library_name+'</td>'
467 str += L.experiment_type+'_'
468 if L.cell_line.cellline_name != 'Unknown':
469 str += L.cell_line.cellline_name+'_'
472 if L.antibody is not None:
473 str += L.antibody.nickname + '_'
474 except Antibody.DoesNotExist:
477 str += 'Rep'+L.replicate.__str__()
481 return HttpResponse(str)