Mercurial > repos > greg > pima_report
comparison pima_report.py @ 32:163260afc1b1 draft
Uploaded
author | greg |
---|---|
date | Thu, 31 Aug 2023 18:30:13 +0000 |
parents | a859de7cce94 |
children | f5a9f1969199 |
comparison
equal
deleted
inserted
replaced
31:a859de7cce94 | 32:163260afc1b1 |
---|---|
462 | 462 |
463 def add_alignment(self): | 463 def add_alignment(self): |
464 if self.quast_report_file is not None: | 464 if self.quast_report_file is not None: |
465 # Process quast values. | 465 # Process quast values. |
466 quast_report = pandas.read_csv(self.quast_report_file, header=0, index_col=0, sep='\t') | 466 quast_report = pandas.read_csv(self.quast_report_file, header=0, index_col=0, sep='\t') |
467 quast_mismatches = int(float(quast_report.loc['# mismatches per 100 kbp', :][0]) * (float(quast_report.loc['Total length (>= 0 bp)', :][0]) / 100000.)) | 467 try: |
468 quast_indels = int(float(quast_report.loc['# indels per 100 kbp', :][0]) * (float(quast_report.loc['Total length (>= 0 bp)', :][0]) / 100000.)) | 468 quast_mismatches = int(float(quast_report.loc['# mismatches per 100 kbp', :][0]) * (float(quast_report.loc['Total length (>= 0 bp)', :][0]) / 100000.)) |
469 self.doc.new_line() | 469 quast_indels = int(float(quast_report.loc['# indels per 100 kbp', :][0]) * (float(quast_report.loc['Total length (>= 0 bp)', :][0]) / 100000.)) |
470 self.doc.new_header(level=2, title=self.alignment_title) | 470 self.doc.new_line() |
471 self.doc.new_line() | 471 self.doc.new_header(level=2, title=self.alignment_title) |
472 self.doc.new_header(level=3, title=self.snp_indel_title) | 472 self.doc.new_line() |
473 Table_1 = [ | 473 self.doc.new_header(level=3, title=self.snp_indel_title) |
474 "Category", | 474 Table_1 = [ |
475 "Quantity", | 475 "Category", |
476 'SNPs', | 476 "Quantity", |
477 '{:,}'.format(quast_mismatches), | 477 'SNPs', |
478 'Small indels', | 478 '{:,}'.format(quast_mismatches), |
479 '{:,}'.format(quast_indels) | 479 'Small indels', |
480 ] | 480 '{:,}'.format(quast_indels) |
481 ] | |
482 except Exception: | |
483 # Likely a high dissimilarity bewteen the sample | |
484 # and the reference, resulting in a failed alignment. | |
485 pass | |
481 self.doc.new_table(columns=2, rows=3, text=Table_1, text_align='left') | 486 self.doc.new_table(columns=2, rows=3, text=Table_1, text_align='left') |
482 self.doc.new_line('<div style="page-break-after: always;"></div>') | 487 self.doc.new_line('<div style="page-break-after: always;"></div>') |
483 self.doc.new_line() | 488 self.doc.new_line() |
484 # TODO: self.alignment_notes is not currently populated. | 489 # TODO: self.alignment_notes is not currently populated. |
485 if len(self.alignment_notes) > 0: | 490 if len(self.alignment_notes) > 0: |