Added 'lanes_for' which will show recent flowcell lanes ordered by date,
authorDiane Trout <diane@caltech.edu>
Tue, 26 Jan 2010 01:40:00 +0000 (01:40 +0000)
committerDiane Trout <diane@caltech.edu>
Tue, 26 Jan 2010 01:40:00 +0000 (01:40 +0000)
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.

htsworkflow/frontend/experiments/models.py
htsworkflow/frontend/samples/changelist.py
htsworkflow/frontend/samples/views.py
htsworkflow/frontend/templates/base.html
htsworkflow/frontend/templates/base_site.html
htsworkflow/frontend/templates/samples/lanes_for.html [new file with mode: 0644]
htsworkflow/frontend/templates/samples/library_index.html
htsworkflow/frontend/urls.py

index 7fdf3f1e97a96d26522cc66b23e43cdf3a716136..9329add350cf36dc14887dc68dd44981bcd8231d 100755 (executable)
@@ -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."
index dccba273fb8dac6fe7b00341cef48731cb89d057..1b4525b7128aba0feee8d1d1872171553521e1f9 100644 (file)
@@ -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 =  []
index dd474a6506b844da3eaaa7d89807769c2975d3e9..642094630e4ad3ddea2734cf9b112636e34dc32e 100644 (file)
@@ -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):
     """
index 7f64055b1ed09d36623b01d6dad937b21a045a9e..b201c8802e7b55f9d2bc8ef37cecca46d90da4f4 100644 (file)
@@ -1,5 +1,20 @@
 {% load i18n %}
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
+<html lang="en">
+<head>
+    <title>{% block title %}{{ app_name }} - {{ page_name }}{% endblock %}</title>
 
+{% block additional_css %}
+    {% load adminmedia %}
+    {% if LANGUAGE_BIDI %}<link rel="stylesheet" type="text/css" href="{% block stylesheet_rtl %}{% admin_media_prefix %}css/rtl.css{% endblock %}" />{% endif %}
+    {% block extrastyle %}{% endblock %}
+    {% block extrahead %}{% endblock %}
+    {% block blockbots %}<meta name="robots" content="NONE,NOARCHIVE" />{% endblock %}
+    <link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/data-browse-index.css" />
+{% endblock %}
+
+</head>
+<body>
 <!-- Container -->
    {% if not is_popup %}
     
@@ -35,3 +50,5 @@
 
     {% block footer %}<div id="footer" class="djangocss"></div>{% endblock %}
 <!-- END Container -->
+</body>
+</html>
\ No newline at end of file
index 7e80060d8b1f04338595b5c5ab78b56b7f15d10c..dae6d9acc424c3001954725366647dd3a8347d4f 100644 (file)
@@ -1,6 +1,8 @@
 {% extends "base.html" %}
 {% load i18n %}
 
+<link type="text/css" rel="stylesheet" href="/static/css/app.css" />
+
 {% 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 (file)
index 0000000..2c3e44b
--- /dev/null
@@ -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 %}
+<div id="lanes-index-div" class="djangocss">
+  <div class="module{% if cl.has_filters %} filtered{% endif %}" id="changelist">
+    {% block search %}{% search_form lanes %}{% endblock %}
+
+    {% block filters %}
+    {% if lanes.has_filters %}
+    <div id="changelist-filter">
+      <h2 class="djangocss">{% trans 'Filter' %}</h2>
+      {% for spec in lanes.filter_specs %}
+         {% admin_list_filter lanes spec %}
+         {% endfor %}
+       </div>
+       {% endif %}
+       {% endblock %}
+
+  
+ {% block pagination %}{% pagination lanes %}{% endblock %}
+
+{% block body %}
+<table class="djangocss">
+  <thead class="djangocss">
+    <tr class="djangocss">
+      <td class="djangocss">Run Date</td>
+      <td class="djangocss">Flowcell Type</td>
+      <td class="djangocss">Cycles</td>
+      <td class="djangocss">Flowcell ID</td>
+      <td class="djangocss">Lane</td>
+      <td class="djangocss">Library ID</td>
+      <td class="djangocss">Library Name</td>
+  </tr>
+  </thead>
+  <tbody class="djangocss">
+    {% for lane in lanes.query_set %}
+    <tr class="djangocss">
+      <td class="djangocss">
+        {{ lane.flowcell.run_date|date:"Y-M-d" }}
+      </td>
+      <td class="djangocss">
+        {{ lane.flowcell.flowcell_type }}
+      </td>
+      <td class="djangocss">
+        {{ lane.flowcell.read_length }}
+      </td>
+      <td class="djangocss">
+        {{ lane.flowcell.flowcell_id }}
+      </td>
+      <td class="djangocss">
+        {{ lane.lane_number }}
+      </td>
+      <td class="djangocss">
+        <a href="/library/{{ lane.library_id }}">{{ lane.library_id }}</a>
+      </td>
+      <td class="djangocss">
+        <a href="/library/{{ lane.library_id }}">{{ lane.library.library_name }}</a>
+      </td>
+   </tr>
+    {% endfor %}
+  </tbody>
+</table>
+</div>
+{% endblock %}
+{% endblock %}
index 56c8e79c00634977381388cfb39094646d6397e5..0c7b721c3d47190d99545a57050b7c38fbaf7d9b 100644 (file)
 <table class="djangocss">
   <thead class="djangocss">
     <tr class="djangocss">
-    <td class="djangocss">Parent</td>
-    <td class="djangocss">Library ID</td>
-    <td class="djangocss">Species</td>
-    <td class="djangocss">Library Name</td>
-    <td class="djangocss">Total Lanes</td>
-    <td class="djangocss">HD</td>
+      <td class="djangocss">Parent</td>
+      <td class="djangocss">Library ID</td>
+      <td class="djangocss">Species</td>
+      <td class="djangocss">Library Name</td>
+      <td colspan="3" class="djangocss">Single</td>
+      <td colspan="3" class="djangocss">Paired</td>
+      <td class="djangocss">HD</td>
+    </tr>
+    <tr class="djangocss">
+      <td colspan="4"></td>
+      <td>&lt;40</td>
+      <td>&lt;100</td>
+      <td>100+</td>
+      <td>&lt;40</td>
+      <td>&lt;100</td>
+      <td>100+</td>
+      <td></td>
     </tr>
   </thead>
   <tbody class="djangocss">
       <td class="djangocss"><a href="/library/{{ lib.library_id }}">{{ lib.library_id }}</a></td>
       <td class="djangocss"><a href="/library/{{ lib.library_id }}">{{ lib.species_name }}</a></td>
       <td class="djangocss"><a href="/library/{{ lib.library_id }}">{{ lib.library_name }}</a></td>
-      <td class="djangocss">{{ lib.lanes_run }}</td>
+      <td class="djangocss" bgcolor="#00BFFF">{{ lib.lanes_run.0.0 }}</td>      
+      <td class="djangocss" bgcolor="#00BFFF">{{ lib.lanes_run.0.1 }}</td>      
+      <td class="djangocss" bgcolor="#00BFFF">{{ lib.lanes_run.0.2 }}</td>      
+      <td class="djangocss" bgcolor="#66CDAA">{{ lib.lanes_run.1.0 }}</td>
+      <td class="djangocss" bgcolor="#66CDAA">{{ lib.lanes_run.1.1 }}</td>      
+      <td class="djangocss" bgcolor="#66CDAA">{{ lib.lanes_run.1.2 }}</td>      
       {% if lib.is_archived %}
         <td class="djangocss"><img src="/static/img/hdd_unmount.png" alt="Archived" /></td>
       {% else %}
index e822fa15615ca525ba39fe1a2c9ca7e3f1e7410b..57d00e1daf4d39664ca96b66daa08015a1686dd8 100644 (file)
@@ -35,6 +35,8 @@ urlpatterns = patterns('',
     (r'^library/$', 'htsworkflow.frontend.samples.views.library'),
     (r'^library/(?P<lib_id>\w+)/$', 
       'htsworkflow.frontend.samples.views.library_to_flowcells'),
+    (r'^lanes_for/$', 'htsworkflow.frontend.samples.views.lanes_for'),
+    (r'^lanes_for/(?P<username>\w+)', 'htsworkflow.frontend.samples.views.lanes_for'),
     # library id to admin url
     (r'^library_id_to_admin_url/(?P<lib_id>\w+)/$',
      'htsworkflow.frontend.samples.views.library_id_to_admin_url'),