From: Diane Trout Date: Sat, 2 Apr 2011 01:13:59 +0000 (-0700) Subject: Add pages to show information about a particular flowcell. X-Git-Tag: 0.5.2~50 X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=htsworkflow.git;a=commitdiff_plain;h=b316e446f23c7ac4228ecd94b02c9e4ae30ac374 Add pages to show information about a particular flowcell. -- in both human and RDFa formats. Also I implemented get_absolute_url for flowcells & lanes, which means "view on site" pops up on the flowcell admin page. Also with modifying the templates for RDFa, many more elements on the library, flowcell, and flowcell lane detail pages link to each other. I moved the table formatting css out of the library page and into app.css. I also switched experiments/views.py from using Context to RequestContext which provides the default media url to the template. There were a few changes to samples/views.py to get the more informative object to the template instead of our on-the-fly created lists. --- diff --git a/htsworkflow/frontend/experiments/models.py b/htsworkflow/frontend/experiments/models.py index 6554405..10599e2 100755 --- a/htsworkflow/frontend/experiments/models.py +++ b/htsworkflow/frontend/experiments/models.py @@ -88,6 +88,11 @@ class FlowCell(models.Model): return u"Paired" else: return u"Single" + + @models.permalink + def get_absolute_url(self): + return ('htsworkflow.frontend.experiments.views.flowcell_detail', + [str(self.flowcell_id)]) ### ----------------------- class DataRun(models.Model): @@ -157,3 +162,8 @@ class Lane(models.Model): cluster_estimate = models.IntegerField(blank=True, null=True) status = models.IntegerField(choices=LANE_STATUS_CODES, null=True, blank=True) comment = models.TextField(null=True, blank=True) + + @models.permalink + def get_absolute_url(self): + return ('htsworkflow.frontend.experiments.views.flowcell_lane_detail', + [str(self.flowcell.flowcell_id), str(self.lane_number)]) diff --git a/htsworkflow/frontend/experiments/views.py b/htsworkflow/frontend/experiments/views.py index 7b6d4ba..b187363 100755 --- a/htsworkflow/frontend/experiments/views.py +++ b/htsworkflow/frontend/experiments/views.py @@ -8,7 +8,7 @@ from django.core.exceptions import ObjectDoesNotExist from django.core.mail import EmailMessage, mail_managers from django.http import HttpResponse from django.shortcuts import render_to_response, get_object_or_404 -from django.template import Context +from django.template import RequestContext from django.template.loader import get_template from htsworkflow.frontend.experiments.models import * @@ -87,13 +87,14 @@ def startedEmail(request, pk): for user_email in email_lane.keys(): sending = "" # build body - context = Context({u'flowcell': fc, - u'lanes': email_lane[user_email], - u'runfolder': 'blank', - u'finish_low': estimate_low, - u'finish_high': estimate_high, - u'now': datetime.now(), - }) + context = RequestContext(request, + {u'flowcell': fc, + u'lanes': email_lane[user_email], + u'runfolder': 'blank', + u'finish_low': estimate_low, + u'finish_high': estimate_high, + u'now': datetime.now(), + }) # build view subject = "Flowcell %s" % ( fc.flowcell_id ) @@ -108,14 +109,15 @@ def startedEmail(request, pk): emails.append((user_email, subject, body, sending)) - verify_context = Context({ - 'emails': emails, - 'flowcell': fc, - 'from': sender, - 'send': send, - 'site_managers': settings.MANAGERS, - 'title': fc.flowcell_id, - 'warnings': warnings, + verify_context = RequestContext( + request, + { 'emails': emails, + 'flowcell': fc, + 'from': sender, + 'send': send, + 'site_managers': settings.MANAGERS, + 'title': fc.flowcell_id, + 'warnings': warnings, }) return HttpResponse(email_verify.render(verify_context)) @@ -123,3 +125,29 @@ def finishedEmail(request, pk): """ """ return HttpResponse("I've got nothing.") + + +def flowcell_detail(request, flowcell_id): + fc = get_object_or_404(FlowCell, flowcell_id=flowcell_id) + + print unicode(fc.get_absolute_url()) + for lane in fc.lane_set.all(): + print unicode(lane.get_absolute_url()) + + context = RequestContext(request, + {'flowcell': fc}) + + return render_to_response('experiments/flowcell_detail.html', + context) + +def flowcell_lane_detail(request, flowcell_id, lane_number): + fc = get_object_or_404(FlowCell, flowcell_id=flowcell_id) + lane = get_object_or_404(fc.lane_set, lane_number=lane_number) + + context = RequestContext(request, + {'lib': lane.library, + 'lane': lane, + 'flowcell': fc}) + + return render_to_response('experiments/flowcell_lane_detail.html', + context) diff --git a/htsworkflow/frontend/samples/models.py b/htsworkflow/frontend/samples/models.py index 8314c71..a8201c9 100644 --- a/htsworkflow/frontend/samples/models.py +++ b/htsworkflow/frontend/samples/models.py @@ -102,6 +102,10 @@ class Species(models.Model): class Meta: verbose_name_plural = "species" ordering = ["scientific_name"] + + @models.permalink + def get_absolute_url(self): + return ('htsworkflow.frontend.samples.views.species', [str(self.id)]) class Affiliation(models.Model): name = models.CharField(max_length=256, db_index=True, verbose_name='Name') @@ -286,9 +290,6 @@ class Library(models.Model): @models.permalink def get_absolute_url(self): return ('htsworkflow.frontend.samples.views.library_to_flowcells', [str(self.id)]) - - - class HTSUser(User): diff --git a/htsworkflow/frontend/samples/urls.py b/htsworkflow/frontend/samples/urls.py index 470ab93..eb3fa46 100644 --- a/htsworkflow/frontend/samples/urls.py +++ b/htsworkflow/frontend/samples/urls.py @@ -3,4 +3,5 @@ from django.conf.urls.defaults import * urlpatterns = patterns('', (r"^library/(?P\w+)/json", 'htsworkflow.frontend.samples.views.library_json'), (r"^species/(?P\w+)/json", 'htsworkflow.frontend.samples.views.species_json'), + (r"^species/(?P\w+)", 'htsworkflow.frontend.samples.views.species'), ) diff --git a/htsworkflow/frontend/samples/views.py b/htsworkflow/frontend/samples/views.py index a6286d7..c57508f 100644 --- a/htsworkflow/frontend/samples/views.py +++ b/htsworkflow/frontend/samples/views.py @@ -12,7 +12,7 @@ except ImportError, e: from htsworkflow.frontend.auth import require_api_key from htsworkflow.frontend.experiments.models import FlowCell, Lane, LANE_STATUS_MAP from htsworkflow.frontend.samples.changelist import ChangeList -from htsworkflow.frontend.samples.models import Library, HTSUser +from htsworkflow.frontend.samples.models import Library, Species, HTSUser from htsworkflow.frontend.samples.results import get_flowcell_result_dict, parse_flowcell_id from htsworkflow.frontend.bcmagic.forms import BarcodeMagicForm from htsworkflow.pipelines.runfolder import load_pipeline_run_xml @@ -26,7 +26,7 @@ from htsworkflow.util import opener from django.core.exceptions import ObjectDoesNotExist from django.http import HttpResponse, HttpResponseRedirect, Http404 -from django.shortcuts import render_to_response +from django.shortcuts import render_to_response, get_object_or_404 from django.template import RequestContext from django.template.loader import get_template from django.contrib.auth.decorators import login_required @@ -68,6 +68,7 @@ def create_library_context(cl): #for lib in library_items.object_list: for lib in cl.result_list: summary = {} + summary['library'] = lib summary['library_id'] = lib.id summary['library_name'] = lib.library_name summary['species_name' ] = lib.library_species.scientific_name @@ -391,13 +392,14 @@ def get_eland_result_type(pathname): else: return 'unknown' -def _make_eland_results(flowcell_id, lane, interesting_flowcells): +def _make_eland_results(flowcell_id, lane_number, interesting_flowcells): fc_id, status = parse_flowcell_id(flowcell_id) cur_fc = interesting_flowcells.get(fc_id, None) if cur_fc is None: return [] flowcell = FlowCell.objects.get(flowcell_id=flowcell_id) + lane = flowcell.lane_set.get(lane_number=lane_number) # Loop throw storage devices if a result has been archived storage_id_list = [] if cur_fc is not None: @@ -421,6 +423,7 @@ def _make_eland_results(flowcell_id, lane, interesting_flowcells): result_path = cur_fc[cycle]['eland_results'].get(lane, None) result_link = make_result_link(fc_id, cycle, lane, result_path) results.append({'flowcell_id': fc_id, + 'flowcell': flowcell, 'run_date': flowcell.run_date, 'cycle': cycle, 'lane': lane, @@ -552,9 +555,7 @@ def library_json(request, library_id): require_api_key(request) # what validation should we do on library_id? - lib = library_dict(library_id) - if lib is None: - raise Http404 + lib = get_object_or_404(Library, library_id=library_id) lib_json = json.dumps(lib) return HttpResponse(lib_json, mimetype='application/json') @@ -565,6 +566,14 @@ def species_json(request, species_id): """ raise Http404 +def species(request, species_id): + species = get_object_or_404(Species, id=species_id) + + context = RequestContext(request, + { 'species': species }) + + return render_to_response("samples/species_detail.html", context) + @login_required def user_profile(request): """ diff --git a/htsworkflow/frontend/static/css/app.css b/htsworkflow/frontend/static/css/app.css index 32c55e5..fec1733 100644 --- a/htsworkflow/frontend/static/css/app.css +++ b/htsworkflow/frontend/static/css/app.css @@ -31,3 +31,55 @@ div.msg { color: white; background: #880000; } + +div.htswdetail { + margin: 0; + padding: 0; +} +div.htswdetail table, div.htswdetail td { + border-style: solid; +} +div.htswdetail table { + border-width: 0 0 1px 1px; + border-spacing: 0; + border-collapse: collapse; +} +div.htswdetail td { + margin: 0; + padding: 3px; + border-width: 1px 1px 0 0; +} +div.htswdetail thead { + text-align: center; +} +div.htswdetail tbody { + text-align: left; + } +div.htswdetail h1, +div.htswdetail h2 +{ + font-size: 150%; +} + +div.htswdetail h3 { + font-size: 125%; + margin: 0; +} + + div.htswdetail h4, + div.htswdetail h5, + div.htswdetail ul, + div.htswdetail ol, + div.htswdetail li + { + list-style: none; + margin: 0; + } + + div.htswdetail ul, + div.htswdetail ol + { + margin-bottom: .5em; + } + /* ]]> */ + diff --git a/htsworkflow/frontend/templates/base.html b/htsworkflow/frontend/templates/base.html index ed9ffb9..479f470 100644 --- a/htsworkflow/frontend/templates/base.html +++ b/htsworkflow/frontend/templates/base.html @@ -31,10 +31,13 @@
{% block branding %}{% endblock %}
- {% if user.is_authenticated and user.is_staff %} -
{% trans 'Welcome,' %} {% firstof user.first_name user.username %}. {% block userlinks %}{% url django-admindocs-docroot as docsroot %}{% if docsroot %}{% trans 'Documentation' %} / {% endif %}{% trans 'Change password' %} / {% trans 'Log out' %}{% endblock %} -
+
+ {% if user.is_authenticated %} + {% trans 'Welcome,' %} {% firstof user.first_name user.username %}. {% block userlinks %}{% url django-admindocs-docroot as docsroot %}{% if docsroot %}{% trans 'Documentation' %} / {% endif %}{% trans 'Change password' %} / {% trans 'Log out' %}{% endblock %} + {% else %} + {% trans 'Log in' %} {% endif %} +
{% block nav-global %}{% endblock %} {% endif %} diff --git a/htsworkflow/frontend/templates/experiments/flowcell_detail.html b/htsworkflow/frontend/templates/experiments/flowcell_detail.html new file mode 100644 index 0000000..3c9329c --- /dev/null +++ b/htsworkflow/frontend/templates/experiments/flowcell_detail.html @@ -0,0 +1,58 @@ +{% extends "base_site.html" %} +{% load adminmedia humanize i18n %} +{% block extrahead %} + + + + + {% block additional_javascript %} + {% endblock %} +{% endblock %} + +{% block content %} +
+

About this Flowcell

+ Flowcell: + {{flowcell.flowcell_id}}
+ Run Date: + {{ flowcell.run_date }}
+ Type: + {{flowcell.flowcell_type}}
+ Read Length: + {{flowcell.read_length}}
+ Control Lane: + {{flowcell.control_lane}}
+ + Notes: +

{{flowcell.notes}}

+
+

Lanes

+ + + + + + + + + + + + {% for lane in flowcell.lane_set.all %} + + + + + + + + {% endfor %} + +
LaneLibrary IDLibrary NameSpeciesComment
+ {{lane.lane_number}}{{lane.library.id}}{{lane.library.library_name}} + {{ lane.library.library_species.scientific_name }}{{lane.comment}}
+
+
+{% endblock %} diff --git a/htsworkflow/frontend/templates/experiments/flowcell_lane_detail.html b/htsworkflow/frontend/templates/experiments/flowcell_lane_detail.html new file mode 100644 index 0000000..aceb186 --- /dev/null +++ b/htsworkflow/frontend/templates/experiments/flowcell_lane_detail.html @@ -0,0 +1,86 @@ +{% extends "base_site.html" %} +{% load adminmedia humanize i18n %} +{% block extrahead %} + + + + + {% block additional_javascript %} + {% endblock %} +{% endblock %} + +{% block content %} +
+

About this lane

+
+ Flowcell: + {{flowcell.flowcell_id}}
+ Run Date: + {{ flowcell.run_date }}
+ Type: + {{flowcell.flowcell_type}}
+
+ Lane: + {{lane.lane_number}}
+ pM + {{ lane.pM }}
+ Cluster Estimate + {{ lane.cluster_estimate|intcomma }}
+ Lane Status: + {{ lane.status }}
+ Comment: + {{ lane.comment }}
+ + +
+

About the library

+ Library ID: + {{ lib.id }}
+ Name: + {{ lib.library_name }} +
+ Species: + {{ lib.library_species.scientific_name }} +
+ Concentration: + {{ lib.undiluted_concentration }} ng/µl +
+ Gel Cut Size: + {{ lib.gel_cut_size }} +
+ Insert Size: + {{ lib.insert_size }} +
+ Background or Cell Line: + {{ lib.cell_line }} +
+ Replicate: + {{ lib.replicate }} +
+ Library Type: + {{ lib.library_type }} +
+ Experiment Type: + {{ lib.experiment_type }} +
+ Made By: + {{ lib.made_by }} +
+ Creation Date + {{ lib.creation_date }} +
+ Protocol Stopping Point + {{ lib.stopping_point_name }} +
+ Affiliations: +
    + {% for individual in lib.affiliations.all %} +
  • + {{ individual.name }} ( {{ individual.contact }} ) +
  • + {% endfor %} +
+
+
+{% endblock %} diff --git a/htsworkflow/frontend/templates/samples/library_detail.html b/htsworkflow/frontend/templates/samples/library_detail.html index 0aa83d0..35baefc 100644 --- a/htsworkflow/frontend/templates/samples/library_detail.html +++ b/htsworkflow/frontend/templates/samples/library_detail.html @@ -8,70 +8,18 @@ {% block additional_javascript %} {% endblock %} - {% endblock %} {% block content %} -
+

About this library

Library ID: {{ lib.id }}
Name: {{ lib.library_name }}
Species: - {{ lib.library_species.scientific_name }} + + {{ lib.library_species.scientific_name }}
Concentration: {{ lib.undiluted_concentration }} ng/µl @@ -111,7 +59,7 @@ {% endfor %} - +

Raw Result Files

@@ -128,11 +76,11 @@ {% for result in eland_results %} - + - - + + {% for lane in lane_summary_list %} - + @@ -222,30 +170,18 @@ {% for lane in lib.lane_set.all %} - - - + + + {% endfor %}
{{ result.run_date|date}} {{ result.cycle }}{{ result.flowcell_id }}{{ result.lane }}{{ result.flowcell_id }}{{ result.lane.lane_number }} Summary {{ result.result_label }} @@ -186,7 +134,7 @@
{{ lane.cycle_width }} {{ lane.flowcell_id }} {{ lane.lane_id }}
{{ lane.flowcell.flowcell_id }}{{ lane.lane_number }}
+ {{ lane.flowcell.flowcell_id }} + {{ lane.lane_number }} {{ lane.comment }}
-
-
-

Count of multi-reads

- {% for lane in lane_summary_list %} - {% if lane.summarized_reads %} -

- {{lane.cycle_width}} {{ lane.flowcell_id }} lane {{ lane.lane_id }} - {% if lane.end %} end {{ lane.end }}{% endif %} -

-
    - {% for name, counts in lane.summarized_reads.items %} -
  • {{ name }}: {{ counts|intcomma }}
  • - {% endfor %} -
- {% endif %} - {% endfor %} {% endblock %} +
{% endblock %} diff --git a/htsworkflow/frontend/templates/samples/library_index.html b/htsworkflow/frontend/templates/samples/library_index.html index 16cd9a3..024a83d 100644 --- a/htsworkflow/frontend/templates/samples/library_index.html +++ b/htsworkflow/frontend/templates/samples/library_index.html @@ -66,11 +66,11 @@ {% for lib in library_list %} - - {{ lib.amplified_from }} - {{ lib.library_id }} - {{ lib.species_name }} - {{ lib.library_name }} + + {{ lib.amplified_from }} + {{ lib.library_id }} + {{ lib.species_name }} + {{ lib.library_name }} {{ lib.lanes_run.0.0 }} {{ lib.lanes_run.0.1 }} {{ lib.lanes_run.0.2 }} diff --git a/htsworkflow/frontend/templates/samples/species_detail.html b/htsworkflow/frontend/templates/samples/species_detail.html new file mode 100644 index 0000000..5e47679 --- /dev/null +++ b/htsworkflow/frontend/templates/samples/species_detail.html @@ -0,0 +1,20 @@ +{% extends "base_site.html" %} +{% load adminmedia humanize i18n %} +{% block extrahead %} + + + + + {% block additional_javascript %} + {% endblock %} +{% endblock %} + +{% block content %} +
+

About this Genome

+ Common Name: + {{ species.common_name}}
+ Scientific Name: + {{ species.scientific_name}}
+
+{% endblock %} diff --git a/htsworkflow/frontend/urls.py b/htsworkflow/frontend/urls.py index 7856f06..c9ce79b 100644 --- a/htsworkflow/frontend/urls.py +++ b/htsworkflow/frontend/urls.py @@ -25,6 +25,11 @@ urlpatterns = patterns('', #(r'^admin/(.*)', admin.site.root), # Experiments: (r'^experiments/', include('htsworkflow.frontend.experiments.urls')), + # Flowcell: + (r'^flowcell/(?P\w+)/(?P\w+)/', + 'htsworkflow.frontend.experiments.views.flowcell_lane_detail'), + (r'^flowcell/(?P\w+)/', + 'htsworkflow.frontend.experiments.views.flowcell_detail'), # AnalysTrack: #(r'^analysis/', include('htsworkflow.frontend.analysis.urls')), # Inventory urls