Remove unused imports
[htsworkflow.git] / samples / views.py
index 0684ee7f5589cf8436a5a1e6c1fff1cb8e023150..e173b08d5974f193ee7ea27fabbc545f4894973c 100644 (file)
@@ -1,36 +1,27 @@
-from __future__ import absolute_import, print_function
+from __future__ import absolute_import, print_function, unicode_literals
 
 # Create your views here.
 import logging
 import os
-import sys
-
-try:
-    import json
-except ImportError as e:
-    import simplejson as json
+import json
 
 from django.views.decorators.csrf import csrf_exempt
-from django.core.exceptions import ObjectDoesNotExist
 from django.http import HttpResponse, HttpResponseRedirect, Http404
 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
-from django.conf import settings
 
 from htsworkflow.auth import require_api_key
-from experiments.models import FlowCell, Lane, LANE_STATUS_MAP
-from experiments.admin import LaneOptions
+from experiments.models import FlowCell, LANE_STATUS_MAP
 from .changelist import HTSChangeList
-from .models import Antibody, Library, Species, HTSUser
+from .models import Antibody, Library, Species
 from .admin import LibraryOptions
 from .results import get_flowcell_result_dict
 from bcmagic.forms import BarcodeMagicForm
 from htsworkflow.pipelines import runfolder
-from htsworkflow.pipelines.eland import ResultLane
 from htsworkflow.pipelines.samplekey import SampleKey
-from htsworkflow.util.conversion import unicode_or_none, parse_flowcell_id
+from htsworkflow.util.conversion import str_or_none, parse_flowcell_id
 from htsworkflow.util import makebed
 from htsworkflow.util import opener
 
@@ -86,14 +77,14 @@ def create_library_context(cl):
             summary['amplified_from'] = ''
         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] = ''
+        for row_index, row in enumerate(lanes_run):
+            for col_index, cell in enumerate(row):
+                if lanes_run[row_index][col_index] == 0:
+                    lanes_run[row_index][col_index] = ''
         summary['lanes_run'] = lanes_run
         summary['is_archived'] = lib.is_archived()
         records.append(summary)
-    cl.result_count = unicode(cl.paginator._count)
+    cl.result_count = str(cl.paginator._count)
     return {'library_list': records}
 
 
@@ -163,31 +154,6 @@ def library_to_flowcells(request, lib_id):
         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})
-    fcl = HTSChangeList(request, Lane,
-                        list_filter=[],
-                        search_fields=['flowcell__flowcell_id', 'library__id', 'library__library_name'],
-                        list_per_page=200,
-                        model_admin=LaneOptions,
-                        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.
@@ -492,7 +458,7 @@ def library_dict(library_id):
         #'antibody_name': lib.antibody_name(), # we have no antibodies.
         'antibody_id': lib.antibody_id,
         'cell_line_id': lib.cell_line_id,
-        'cell_line': unicode_or_none(lib.cell_line),
+        'cell_line': str_or_none(lib.cell_line),
         'experiment_type': lib.experiment_type.name,
         'experiment_type_id': lib.experiment_type_id,
         'gel_cut_size': lib.gel_cut_size,
@@ -511,8 +477,8 @@ def library_dict(library_id):
         'notes': lib.notes,
         'replicate': lib.replicate,
         'stopping_point': lib.stopping_point,
-        'successful_pM': unicode_or_none(lib.successful_pM),
-        'undiluted_concentration': unicode_or_none(lib.undiluted_concentration)
+        'successful_pM': str_or_none(lib.successful_pM),
+        'undiluted_concentration': str_or_none(lib.undiluted_concentration)
         }
     if lib.library_type_id is None:
         info['library_type'] = None