def build_report(self, params, reads_refs, alignments, alignment_set=None): """ Builds and uploads the HISAT2 report. """ report_client = KBaseReport(self.callback_url) report_text = None created_objects = list() for k in alignments: created_objects.append({ "ref": alignments[k]["ref"], "description": "Reads {} aligned to Genome {}".format(k, params["genome_ref"]) }) if alignment_set is not None: created_objects.append({ "ref": alignment_set, "description": "Set of all new alignments" }) report_text = "Created {} alignments from the given alignment set.".format( len(alignments)) qm = kb_QualiMap(self.callback_url, service_ver='dev') qc_ref = alignment_set if qc_ref is None: # then there's only one alignment... qc_ref = alignments[alignments.keys()[0]]["ref"] bamqc_params = {"create_report": 0, "input_ref": qc_ref} result = qm.run_bamqc(bamqc_params) index_file = None for f in os.listdir(result["qc_result_folder_path"]): if f.endswith(".html"): index_file = f if index_file is None: raise RuntimeError( "QualiMap failed - no HTML file was found in the generated output." ) html_zipped = package_directory(self.callback_url, result["qc_result_folder_path"], index_file, 'QualiMap Results') report_params = { "message": report_text, "direct_html_link_index": 0, "html_links": [html_zipped], "report_object_name": "QualiMap-" + str(uuid.uuid4()), "workspace_name": params["ws_name"], "objects_created": created_objects } report_info = report_client.create_extended_report(report_params) return report_info
def __init__(self, scratch_dir, workspace_url, callback_url, srv_wiz_url, provenance): self.scratch_dir = scratch_dir self.workspace_url = workspace_url self.callback_url = callback_url self.srv_wiz_url = srv_wiz_url self.provenance = provenance # from the provenance, extract out the version to run by exact hash if possible self.my_version = 'release' if len(provenance) > 0: if 'subactions' in provenance[0]: self.my_version = self.get_version_from_subactions( 'kb_Bwa', provenance[0]['subactions']) print('Running kb_Bwa version = ' + self.my_version) self.ws = Workspace(self.workspace_url) self.bwa = BwaRunner(self.scratch_dir) self.parallel_runner = KBParallel(self.callback_url) self.qualimap = kb_QualiMap(self.callback_url)