Merge in new modules from htsworkflow branch.
[htsworkflow.git] / htsworkflow / frontend / experiments / views.py
1 # Create your views here.
2 #from django.template import Context, loader
3 #shortcut to the above modules
4 from django.shortcuts import render_to_response, get_object_or_404
5 #from htswfrontend.fctracker.models import *
6 from htswfrontend.exp_track.models import *
7 from django.http import HttpResponse
8 from django.core.exceptions import ObjectDoesNotExist
9
10 def index(request):
11     all_runs = DataRun.objects.all().order_by('-run_start_time')
12     #t = loader.get_template('exptrack/index.html')
13     #c = Context({
14     #    'data_run_list': all_runs,
15     #})
16     #return HttpResponse(t.render(c)) 
17     # shortcut to the above module usage
18     return render_to_response('exptrack/index.html',{'data_run_list': all_runs}) 
19     
20 def detail(request, run_folder):
21     html_str = '<h2>Exp Track Details Page</h2>'
22     html_str += 'Run Folder: '+run_folder
23     r = get_object_or_404(DataRun,run_folder=run_folder)
24     return render_to_response('exptrack/detail.html',{'run_f': r})
25
26 def makeFCSheet(request,fcid):
27   # get Flowcell by input fcid
28   # ...
29   rec = None
30   try:
31     rec = FlowCell.objects.get(flowcell_id=fcid)
32   except ObjectDoesNotExist:
33     pass
34   lanes = ['1','2','3','4','5','6','7','8']
35   return render_to_response('exptrack/flowcellSheet.html',{'fc': rec})
36
37 def test_Libs(request):
38   str = ''
39   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>'
40   allLibs = Library.objects.all()
41   #allLibs = Library.objects.filter(antibody__isnull=False)
42   for L in allLibs:
43     str += '<tr>'
44     str += '<td>'+L.library_id+'</td><td>'+L.library_name+'</td>'   
45     str += '<td>'
46     str += L.experiment_type+'_'
47     if L.cell_line.cellline_name != 'Unknown':
48       str += L.cell_line.cellline_name+'_'
49
50     try:
51       if L.antibody is not None:
52         str += L.antibody.nickname + '_'
53     except Antibody.DoesNotExist:
54       pass
55   
56     str += 'Rep'+L.replicate.__str__()
57     str += '</td></tr>' 
58
59   str += '</table>'
60   return HttpResponse(str)