from django.core.exceptions import ObjectDoesNotExist
from django.shortcuts import render_to_response, get_object_or_404
-def getBgColor(reads_cnt,exp_type):
+badLibBgColor = '#cccccc'
+def getBgColor(reads_cnt,exp_type,isBadLib):
+ if isBadLib: return badLibBgColor
# 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
- bgcolor = '#ff3300' # Red is the color for minimum read counts
+ bgcolor = '#ffcdd0' # Red is the color for minimum read counts
rc_thr = [12000000,5000000,3000000] # Default for ChIP-Seq and Methyl-Seq
if exp_type == 'RNA-seq':
rc_thr = [20000000,10000000,6000000]
return bgcolor
def report1(request):
+ if not request.user.is_authenticated():
+ str= '<span style="margin-right:20px"><a target=_self href="/admin" target=_self style="font-size:140%">Please log in first</a></span>'
+ return render_to_response('htsw_reports/report.html',{'main':str})
+
EXP = 'ChIP-seq'
if request.has_key('aflid'):
AFL = Affiliation.objects.get(id=AFL_Id).name
AFL_CNT = Affiliation.objects.get(id=AFL_Id).contact
except ObjectDoesNotExist:
- return HttpResponse("ERROR: Affiliation Record Not Found for: '"+AFL_ID+"'")
+ return HttpResponse("ERROR: Affiliation Record Not Found for: '"+AFL_Id+"'")
else:
AFL = 'ENCODE_Tier1'
AFL_CNT = ''
AFL_Id = Affiliation.objects.get(name=AFL,contact=AFL_CNT).id.__str__()
except ObjectDoesNotExist:
return HttpResponse("ERROR: Affiliation Record Not Found for: '"+AFL+"'")
+
+ if request.user.username == 'caltech':
+ 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>')
TFall = Library.objects.values('antibody').order_by('antibody').distinct()
CLLall = Library.objects.values('cell_line').order_by('cell_line').distinct()
########
str = ''
- str += '<span style="margin-right:20px"><a target=_self href="/admin" target=_self">Main Page</a></span>'
+ str += '<span style="margin-right:20px"><a target=_self href="/admin" target=_self style="font-size:140%">HOME</a></span>'
##str += '<span style="margin-right:20px">Max Replicates: '+MaxRep.replicate.__str__()+'</span>'
- str += '<span>Select another <b>'+EXP+'</b> Report:</span> <select>'
- for af in Affiliation.objects.distinct():
+ str += '<span>Select another <b>'+EXP+'</b> Report:</span> <select onchange="window.location=\'/htsw_reports/report?aflid=\'+this.options[selectedIndex].value; return false;">'
+
+ if request.user.username == 'caltech':
+ Affil_List = Affiliation.objects.filter(name__contains='ENCODE').distinct()
+ else:
+ Affil_List = Affiliation.objects.distinct()
+
+ for af in Affil_List:
str += '<option value='+af.id.__str__()
if AFL_Id == af.id.__str__():
str += ' selected'
- str += ' onclick="window.location=\'/htsw_reports/report?aflid='+af.id.__str__()+'\'; return false;">'+af.name+' '+af.contact+'</option>'
+ str += '>'+af.name+' '+af.contact+'</option>'
str += '</select>'
- 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:#ff3300"> < 3 M</span></span>'
+ 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 style="margin-left:5px;background-color:'+badLibBgColor+'">Bad Library</span></span>'
str += '<span style="margin-left:20px">'
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>'
else:
cnt = rres[1]
if cnt > 0:
- str += "<div style='background-color:"+getBgColor(cnt,EXP)+";font-size:140%'>"
+ str += "<div style='background-color:"+getBgColor(cnt,EXP,(R1.libtags().find('Bad library')!=-1))+";font-size:140%'>"
str += "%1.2f" % (cnt/1000000.0)+" M"
- else: str += "<div style='background-color:#ff3300;width:100%;font-size:140%'>0 Reads"
- str += "<div style='font-size:70%'>"+R1.library_id+", "+R1.condition.nickname
+ else: str += "<div style='background-color:#ffcdd0;width:100%;font-size:140%'>0 Reads"
+ 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+"</a>, "+R1.condition.nickname
if R1.libtags().find('Data submitted to DCC') != -1:
str += "<div style='border:solid #666666 1px;'>data submitted</div>"
str += "</div>"
cnt = 0
for R1 in repReads:
rres = R1.aligned_m_reads()
- # Check data sanlty
+ # Check data sanity
if rres[2] != 'OK':
str += '<div style="border:solid red 2px">'+rres[2]
else:
cnt = rres[1]
if cnt > 0:
- str += "<div style='background-color:"+getBgColor(cnt,EXP)+";font-size:140%;margin:2px'>"
+ str += "<div style='background-color:"+getBgColor(cnt,EXP,(R1.libtags().find('Bad library')!=-1))+";font-size:140%;margin:2px'>"
str += "%1.2f" % (cnt/1000000.0)+" M"
- else: str += "<div style='background-color:#ff3300;width:100%;font-size:140%'>0 Reads"
- str += "<div style='font-size:70%'>"+R1.library_id+", "+R1.condition.nickname
+ else: str += "<div style='background-color:#ffcdd0;width:100%;font-size:140%'>0 Reads"
+ 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+"</a>, "+R1.condition.nickname
if R1.libtags().find('Data submitted to DCC') != -1:
str += "<div style='border:solid #666666 1px;'>data submitted</div>"
str += "</div>"
def report_RM(request): #for RNA-Seq and Methyl-Seq
+ if not request.user.is_authenticated():
+ str= '<span style="margin-right:20px"><a target=_self href="/admin" target=_self style="font-size:140%">Please log in first</a></span>'
+ return render_to_response('htsw_reports/report.html',{'main':str})
+
EXP = 'RNA-seq'
if request.has_key('exp'):
AFL = Affiliation.objects.get(id=AFL_Id).name
AFL_CNT = Affiliation.objects.get(id=AFL_Id).contact
except ObjectDoesNotExist:
- return HttpResponse("ERROR: Affiliation Record Not Found for: '"+AFL_ID+"'")
+ return HttpResponse("ERROR: Affiliation Record Not Found for: '"+AFL_Id+"'")
else:
AFL = 'ENCODE_Tier1'
AFL_CNT = ''
except ObjectDoesNotExist:
return HttpResponse("ERROR: Affiliation Record Not Found for: '"+AFL+"'")
+ if request.user.username == 'caltech':
+ 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>')
+
CLLall = Library.objects.values('cell_line').order_by('cell_line').distinct()
CLLs = CLLall.filter(experiment_type=EXP,affiliations__name=AFL,affiliations__contact=AFL_CNT)
if len(RepRecs) > 0: Reps = RepRecs[0].replicate
str = ''
- str += '<span style="margin-right:20px"><a target=_self href="/admin" target=_self">Main Page</a></span>'
- str += '<span>Select another <b>'+EXP+'</b> Report:</span> <select>'
- for af in Affiliation.objects.distinct():
+ str += '<span style="margin-right:20px"><a target=_self href="/admin" target=_self" style="font-size:140%">HOME</a></span>'
+ 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;">'
+
+ if request.user.username == 'caltech':
+ Affil_List = Affiliation.objects.filter(name__contains='ENCODE').distinct()
+ else:
+ Affil_List = Affiliation.objects.distinct()
+
+ for af in Affil_List:
str += '<option value='+af.id.__str__()
if AFL_Id == af.id.__str__():
str += ' selected'
- str += ' onclick="window.location=\'/htsw_reports/report_RM?exp='+EXP+'&aflid='+af.id.__str__()+'\'; return false;">'+af.name+' '+af.contact+'</option>'
+ str += '>'+af.name+' '+af.contact+'</option>'
str += '</select>'
if EXP == 'RNA-seq':
- 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:#ff3300"> < 6 M</span></span>'
+ 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 style="margin-left:5px;background-color:'+badLibBgColor+'">Bad Library</span></span>'
str += '<span style="margin-left:20px">'
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>'
str += ' | '
str += '<a target=_self href="/htsw_reports/report_RM?exp=Methyl-seq&aflid='+AFL_Id+'"><b>Methyl-Seq</b> Report</a>'
else:
- 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:#ff3300"> < 3 M</span></span>'
+ 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 style="margin-left:5px;background-color:'+badLibBgColor+'">Bad Library</span></span>'
str += '<span style="margin-left:20px">'
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>'
str += ' | '
else:
cnt = rres[1]
if cnt > 0:
- str += "<div style='background-color:"+getBgColor(cnt,EXP)+";border:solid #cccccc 1px;font-size:140%'>"
+ str += "<div style='background-color:"+getBgColor(cnt,EXP,(R1.libtags().find('Bad library')!=-1))+";border:solid #cccccc 1px;font-size:140%'>"
str += "%1.2f" % (cnt/1000000.0)+" M"
- else: str += "<div style='background-color:#ff3300;border:solid #cccccc 1px;width:100%;font-size:140%'>0 Reads"
- str += "<div style='font-size:80%'><a title='View Record' target=_self href=/admin/fctracker/library/?q="+R1.library_id+">"+R1.library_id+"</a>, "+R1.condition.nickname+", "+R1.library_species.common_name+"</div>"
+ else: str += "<div style='background-color:#ffcdd0;border:solid #cccccc 1px;width:100%;font-size:140%'>0 Reads"
+ 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+"</a>, "+R1.condition.nickname+", "+R1.library_species.common_name+"</div>"
str += "<div style='font-size:70%'>\""+R1.library_name+"\""
if R1.libtags().find('Data submitted to DCC') != -1:
str += "<div style='width:75%;border:solid #666666 1px;'>data submitted</div>"
return render_to_response('htsw_reports/report.html',{'main': str})
def getNotRanFCs(request):
+ if not request.user.is_authenticated():
+ str= '<span style="margin-right:20px"><a target=_self href="/admin" target=_self style="font-size:140%">Please log in first</a></span>'
+ return render_to_response('htsw_reports/report.html',{'main':str})
+
FCall = FlowCell.objects.order_by('-run_date').distinct()
str = '<table><tr><th>FlowCell</th><th>Lanes</th><th>Creation Date</th></tr>'
for f in FCall:
return render_to_response('htsw_reports/report.html',{'main':str})
def test_Libs(request):
+ if not request.user.is_authenticated():
+ str= '<span style="margin-right:20px"><a target=_self href="/admin" target=_self style="font-size:140%">Please log in first</a></span>'
+ return render_to_response('htsw_reports/report.html',{'main':str})
+
str = ''
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>'
allLibs = Library.objects.all()