def write_summary(self, summary_fn, isoforms_fa, hq_fa=None, lq_fa=None): """Extract number of consensus isoforms predicted, and total number of bases in all consensuus isoforms from isoforms_fa and write the two attributes to summary_fn. if hq_fa (polished high-quality isoforms) is not None, report the number of polished hq clusters if lq_fa (polished high-quality isoforms) is not None, report the number of polished hq clusters """ self.add_log("Writing a summary to {f}".format(f=summary_fn), level=logging.INFO) try: summary = ClusterSummary() with FastaReader(isoforms_fa) as reader: for r in reader: summary.numConsensusIsoforms += 1 summary.numTotalBases += len(r.sequence) if hq_fa is not None: summary.num_polished_hq_isoforms = 0 with FastaReader(hq_fa) as reader: for r in reader: summary.num_polished_hq_isoforms += 1 if lq_fa is not None: summary.num_polished_lq_isoforms = 0 with FastaReader(lq_fa) as reader: for r in reader: summary.num_polished_lq_isoforms += 1 summary.write(summary_fn) except ZeroDivisionError: errMsg = "No consensus isoforms predicted." self.add_log(errMsg, level=logging.ERROR) raise RuntimeError(errMsg)