# HG changeset patch
# User greg
# Date 1693506613 0
# Node ID 163260afc1b1afd971d2a69c5a855e5574bf86b3
# Parent  a859de7cce949051c0e886e87f9a3b4ba44a4691
Uploaded

diff -r a859de7cce94 -r 163260afc1b1 pima_report.py
--- a/pima_report.py	Tue Jun 27 13:39:14 2023 +0000
+++ b/pima_report.py	Thu Aug 31 18:30:13 2023 +0000
@@ -464,20 +464,25 @@
         if self.quast_report_file is not None:
             # Process quast values.
             quast_report = pandas.read_csv(self.quast_report_file, header=0, index_col=0, sep='\t')
-            quast_mismatches = int(float(quast_report.loc['# mismatches per 100 kbp', :][0]) * (float(quast_report.loc['Total length (>= 0 bp)', :][0]) / 100000.))
-            quast_indels = int(float(quast_report.loc['# indels per 100 kbp', :][0]) * (float(quast_report.loc['Total length (>= 0 bp)', :][0]) / 100000.))
-            self.doc.new_line()
-            self.doc.new_header(level=2, title=self.alignment_title)
-            self.doc.new_line()
-            self.doc.new_header(level=3, title=self.snp_indel_title)
-            Table_1 = [
-                "Category",
-                "Quantity",
-                'SNPs',
-                '{:,}'.format(quast_mismatches),
-                'Small indels',
-                '{:,}'.format(quast_indels)
-            ]
+            try:
+                quast_mismatches = int(float(quast_report.loc['# mismatches per 100 kbp', :][0]) * (float(quast_report.loc['Total length (>= 0 bp)', :][0]) / 100000.))
+                quast_indels = int(float(quast_report.loc['# indels per 100 kbp', :][0]) * (float(quast_report.loc['Total length (>= 0 bp)', :][0]) / 100000.))
+                self.doc.new_line()
+                self.doc.new_header(level=2, title=self.alignment_title)
+                self.doc.new_line()
+                self.doc.new_header(level=3, title=self.snp_indel_title)
+                Table_1 = [
+                    "Category",
+                    "Quantity",
+                    'SNPs',
+                    '{:,}'.format(quast_mismatches),
+                    'Small indels',
+                    '{:,}'.format(quast_indels)
+                ]
+            except Exception:
+                # Likely a high dissimilarity bewteen the sample
+                # and the reference, resulting in a failed alignment.
+                pass
         self.doc.new_table(columns=2, rows=3, text=Table_1, text_align='left')
         self.doc.new_line('<div style="page-break-after: always;"></div>')
         self.doc.new_line()