Attempt to be robust to not having an alignment in our RunXml file
[htsworkflow.git] / htsworkflow / frontend / samples / views.py
index 28a3e1ea73e7794e1b5988bc189484b17537d9b8..e50b5b357c2caa1b88d73cb2f2884cf0124f6158 100644 (file)
@@ -92,6 +92,7 @@ def create_library_context(cl):
     cl.result_count = unicode(cl.paginator._count)
     return {'library_list': records }
 
+
 def library(request, todo_only=False):
     queryset = Library.objects.filter(hidden__exact=0)
     if todo_only:
@@ -110,9 +111,11 @@ def library(request, todo_only=False):
     c = RequestContext(request, context)
     return HttpResponse( t.render(c) )
 
+
 def library_not_run(request):
     return library(request, todo_only=True)
 
+
 def library_to_flowcells(request, lib_id):
     """
     Display information about all the flowcells a library has been run on.
@@ -293,6 +296,10 @@ def _summary_stats(flowcell_id, lane_id, library_id):
             continue
 
         run = load_pipeline_run_xml(xmlpath)
+        # skip if we don't have available metadata.
+        if run.gerald is None or run.gerald.summary is None:
+            continue
+        
         gerald_summary = run.gerald.summary.lane_results
         key = SampleKey(lane=lane_id, sample='s')
         eland_results = list(run.gerald.eland_results.find_keys(key))
@@ -306,7 +313,7 @@ def _summary_stats(flowcell_id, lane_id, library_id):
             read = key.read-1 if key.read is not None else 0
             try:
                 eland_summary.clusters = gerald_summary[read][key.lane].cluster
-            except IndexError as e:
+            except (IndexError, KeyError) as e:
                 eland_summary.clustes = None
             eland_summary.cycle_width = cycle_width
             if hasattr(eland_summary, 'genome_map'):
@@ -459,6 +466,7 @@ def library_dict(library_id):
     for lane in lib.lane_set.all():
         lane_info.append( {'flowcell':lane.flowcell.flowcell_id,
                            'lane_number': lane.lane_number,
+                           'lane_id': lane.id,
                            'paired_end': lane.flowcell.paired_end,
                            'read_length': lane.flowcell.read_length,
                            'status_code': lane.status,