From: Diane Trout Date: Tue, 26 Jan 2010 01:40:00 +0000 (+0000) Subject: Added 'lanes_for' which will show recent flowcell lanes ordered by date, X-Git-Tag: 0.4.0~18 X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=htsworkflow.git;a=commitdiff_plain;h=53a9ed7ec95900175b752c0a160af51f661baf45 Added 'lanes_for' which will show recent flowcell lanes ordered by date, and allows filtering by username. In addition I modified the library index to bin runs into small (<40), medium (<100), and large (>=100) runs seperated by single and paired end reads. --- diff --git a/htsworkflow/frontend/experiments/models.py b/htsworkflow/frontend/experiments/models.py index 7fdf3f1..9329add 100755 --- a/htsworkflow/frontend/experiments/models.py +++ b/htsworkflow/frontend/experiments/models.py @@ -79,7 +79,16 @@ class FlowCell(models.Model): # that's the django way... except it didn't work #return urlresolvers.reverse('admin_experiments_FlowCell_change', args=(self.id,)) return '/admin/experiments/flowcell/%s/' % (self.id,) - + + def flowcell_type(self): + """ + Convert our boolean 'is paired' flag to a name + """ + if self.paired_end: + return u"Paired" + else: + return u"Single" + ### ----------------------- class DataRun(models.Model): ConfTemplate = "CONFIG PARAMS WILL BE GENERATED BY THE PIPELINE SCRIPT.\nYOU'LL BE ABLE TO EDIT AFTER IF NEEDED." diff --git a/htsworkflow/frontend/samples/changelist.py b/htsworkflow/frontend/samples/changelist.py index dccba27..1b4525b 100644 --- a/htsworkflow/frontend/samples/changelist.py +++ b/htsworkflow/frontend/samples/changelist.py @@ -28,7 +28,7 @@ class ChangeList(object): self.opts = model._meta self.lookup_opts = self.opts if queryset is None: - self.root_query_set = model.objects + self.root_query_set = model.objects.all() else: self.root_query_set = queryset self.list_display = [] diff --git a/htsworkflow/frontend/samples/views.py b/htsworkflow/frontend/samples/views.py index dd474a6..6420946 100644 --- a/htsworkflow/frontend/samples/views.py +++ b/htsworkflow/frontend/samples/views.py @@ -10,9 +10,9 @@ except ImportError, e: import simplejson as json from htsworkflow.frontend.auth import require_api_key -from htsworkflow.frontend.experiments.models import FlowCell +from htsworkflow.frontend.experiments.models import FlowCell, Lane from htsworkflow.frontend.samples.changelist import ChangeList -from htsworkflow.frontend.samples.models import Library +from htsworkflow.frontend.samples.models import Library, 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 @@ -37,6 +37,29 @@ SAMPLES_CONTEXT_DEFAULTS = { 'bcmagic': BarcodeMagicForm() } +def count_lanes(lane_set): + single = 0 + paired = 1 + short_read = 0 + medium_read = 1 + long_read = 2 + counts = [[0,0,0,],[0,0,0]] + + for lane in lane_set.all(): + if lane.flowcell.paired_end: + lane_type = paired + else: + lane_type = single + if lane.flowcell.read_length < 40: + read_type = short_read + elif lane.flowcell.read_length < 100: + read_type = medium_read + else: + read_type = long_read + counts[lane_type][read_type] += 1 + + return counts + def create_library_context(cl): """ Create a list of libraries that includes how many lanes were run @@ -52,11 +75,12 @@ def create_library_context(cl): summary['amplified_from'] = lib.amplified_from_sample.id else: summary['amplified_from'] = '' - lanes_run = 0 - #for lane_id in LANE_LIST: - # lane = getattr(lib, 'lane_%d_library' % (lane_id,)) - # lanes_run += len( lane.all() ) - lanes_run = lib.lane_set.count() + lanes_run = count_lanes(lib.lane_set) + # suppress zeros + for row in xrange(len(lanes_run)): + for col in xrange(len(lanes_run[row])): + if lanes_run[row][col] == 0: + lanes_run[row][col] = '' summary['lanes_run'] = lanes_run summary['is_archived'] = lib.is_archived() records.append(summary) @@ -129,6 +153,31 @@ def library_to_flowcells(request, lib_id): context, context_instance = RequestContext(request)) +def lanes_for(request, username=None): + """ + Generate a report of recent activity for a user + """ + query = {} + if username is not None: + user = HTSUser.objects.get(username=username) + query.update({'library__affiliations__users__id':user.id}) + print query, username + fcl = ChangeList(request, Lane, + list_filter=[], + search_fields=['flowcell__flowcell_id', 'library__id', 'library__library_name'], + list_per_page=200, + queryset=Lane.objects.filter(**query) + ) + + context = { 'lanes': fcl, 'title': 'Lane Index'} + + return render_to_response( + 'samples/lanes_for.html', + context, + context_instance = RequestContext(request) + ) + + def summaryhtm_fc_cnm(request, flowcell_id, cnm): """ returns a Summary.htm file if it exists. @@ -519,7 +568,7 @@ def species_json(request, species_id): Return information about a species. """ raise Http404 - + @login_required def user_profile(request): """ diff --git a/htsworkflow/frontend/templates/base.html b/htsworkflow/frontend/templates/base.html index 7f64055..b201c88 100644 --- a/htsworkflow/frontend/templates/base.html +++ b/htsworkflow/frontend/templates/base.html @@ -1,5 +1,20 @@ {% load i18n %} + + + + {% block title %}{{ app_name }} - {{ page_name }}{% endblock %} +{% block additional_css %} + {% load adminmedia %} + {% if LANGUAGE_BIDI %}{% endif %} + {% block extrastyle %}{% endblock %} + {% block extrahead %}{% endblock %} + {% block blockbots %}{% endblock %} + +{% endblock %} + + + {% if not is_popup %} @@ -35,3 +50,5 @@ {% block footer %}{% endblock %} + + \ No newline at end of file diff --git a/htsworkflow/frontend/templates/base_site.html b/htsworkflow/frontend/templates/base_site.html index 7e80060..dae6d9a 100644 --- a/htsworkflow/frontend/templates/base_site.html +++ b/htsworkflow/frontend/templates/base_site.html @@ -1,6 +1,8 @@ {% extends "base.html" %} {% load i18n %} + + {% block title %}{{ sitename }}{% endblock %} {% block branding %} diff --git a/htsworkflow/frontend/templates/samples/lanes_for.html b/htsworkflow/frontend/templates/samples/lanes_for.html new file mode 100644 index 0000000..2c3e44b --- /dev/null +++ b/htsworkflow/frontend/templates/samples/lanes_for.html @@ -0,0 +1,70 @@ +{% extends "base_site.html" %} +{# extends "app_base.html" #} +{% load adminmedia admin_list i18n %} + +{% block bodyclass %}change-list{% endblock %} +{% block coltype %}flex{% endblock %} + +{% block content %} +
+
+ {% block search %}{% search_form lanes %}{% endblock %} + + {% block filters %} + {% if lanes.has_filters %} +
+

{% trans 'Filter' %}

+ {% for spec in lanes.filter_specs %} + {% admin_list_filter lanes spec %} + {% endfor %} +
+ {% endif %} + {% endblock %} + + + {% block pagination %}{% pagination lanes %}{% endblock %} + +{% block body %} + + + + + + + + + + + + + + {% for lane in lanes.query_set %} + + + + + + + + + + {% endfor %} + +
Run DateFlowcell TypeCyclesFlowcell IDLaneLibrary IDLibrary Name
+ {{ lane.flowcell.run_date|date:"Y-M-d" }} + + {{ lane.flowcell.flowcell_type }} + + {{ lane.flowcell.read_length }} + + {{ lane.flowcell.flowcell_id }} + + {{ lane.lane_number }} + + {{ lane.library_id }} + + {{ lane.library.library_name }} +
+
+{% endblock %} +{% endblock %} diff --git a/htsworkflow/frontend/templates/samples/library_index.html b/htsworkflow/frontend/templates/samples/library_index.html index 56c8e79..0c7b721 100644 --- a/htsworkflow/frontend/templates/samples/library_index.html +++ b/htsworkflow/frontend/templates/samples/library_index.html @@ -27,12 +27,23 @@ - - - - - - + + + + + + + + + + + + + + + + + @@ -42,7 +53,12 @@ - + + + + + + {% if lib.is_archived %} {% else %} diff --git a/htsworkflow/frontend/urls.py b/htsworkflow/frontend/urls.py index e822fa1..57d00e1 100644 --- a/htsworkflow/frontend/urls.py +++ b/htsworkflow/frontend/urls.py @@ -35,6 +35,8 @@ urlpatterns = patterns('', (r'^library/$', 'htsworkflow.frontend.samples.views.library'), (r'^library/(?P\w+)/$', 'htsworkflow.frontend.samples.views.library_to_flowcells'), + (r'^lanes_for/$', 'htsworkflow.frontend.samples.views.lanes_for'), + (r'^lanes_for/(?P\w+)', 'htsworkflow.frontend.samples.views.lanes_for'), # library id to admin url (r'^library_id_to_admin_url/(?P\w+)/$', 'htsworkflow.frontend.samples.views.library_id_to_admin_url'),
ParentLibrary IDSpeciesLibrary NameTotal LanesHDParentLibrary IDSpeciesLibrary NameSinglePairedHD
<40<100100+<40<100100+
{{ lib.library_id }} {{ lib.species_name }} {{ lib.library_name }}{{ lib.lanes_run }}{{ lib.lanes_run.0.0 }}{{ lib.lanes_run.0.1 }}{{ lib.lanes_run.0.2 }}{{ lib.lanes_run.1.0 }}{{ lib.lanes_run.1.1 }}{{ lib.lanes_run.1.2 }}Archived