Attempt to be robust to not having an alignment in our RunXml file
[htsworkflow.git] / htsworkflow / frontend / samples / views.py
index a53552ce7135637718e6fd1377836250b486bf61..e50b5b357c2caa1b88d73cb2f2884cf0124f6158 100644 (file)
@@ -296,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))
@@ -309,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'):