def test_run_pipeline_no_rqcfilter(self): # load some data here. output = self.getImpl().run_mg_assembly_pipeline( self.getContext(), { "reads_upa": self.reads_upa, "output_assembly_name": "MyNewAssembly", "workspace_name": util.get_ws_name(), "skip_rqcfilter": 1, "debug": 1 })[0] self.assertIn('report_name', output) self.assertIn('report_ref', output) self.assertIn('assembly_upa', output) pprint(output) # again, but save cleaned reads output = self.getImpl().run_mg_assembly_pipeline( self.getContext(), { "reads_upa": self.reads_upa, "output_assembly_name": "MyNewAssembly", "workspace_name": util.get_ws_name(), "skip_rqcfilter": 1, "debug": 1, "cleaned_reads_name": "MyCleanedReads" })[0] self.assertIn("report_name", output) self.assertIn("report_ref", output) self.assertIn("assembly_upa", output) self.assertIn("cleaned_reads_upa", output) pprint(output)
def test_make_report_ok(self): pipeline_output = { "bbmap": { "stats_file": self.bbmap_stats_file, "coverage_file": self.cov_stats, "command": "bbmap cmd", "version_string": "bbmap version" }, "stats": { "stats_txt": self.assembly_stats_file, "stats_tsv": self.assembly_stats_tsv, "command": "stats command", "version_string": "stats version" }, "rqcfilter": { "run_log": self.rqcfilter_log, "command": "rqcfilter command", "version_string": "rqcfilter version" }, "reads_info_prefiltered": { "count": 10000, "command": "reads_info_prefiltered command", "version_string": "reads info version" }, "reads_info_filtered": { "count": 8000, "command": "reads_info_filtered command", "version_string": "reads info version" }, "reads_info_corrected": { "count": 7000, "command": "reads_info_corrected command", "version_string": "reads info version" }, "bfc": { "command": "bfc command", "version_string": "bfc version" }, "seqtk": { "command": "seqtk command", "version_string": "seqtk verseion" }, "spades": { "command": "spades command", "version_string": "spades version" }, "agp": { "command": "agp command", "version_string": "agp version" }, } report_info = self._get_report_util().make_report( pipeline_output, util.get_ws_name(), [] ) self.assertIn('report_ref', report_info) self.assertIn('report_name', report_info)
def test_run_pipeline_mismatched_inputs(self): with self.assertRaises(ValueError): self.getImpl().run_mg_assembly_pipeline( self.getContext(), { "reads_upa": self.reads_upa, "output_assembly_name": "MyNewAssembly", "workspace_name": util.get_ws_name(), "skip_rqcfilter": True, "filtered_reads_name": "MyFilteredReads" })
def test_run_pipeline_missing_inputs(self): with self.assertRaises(ValueError): self.getImpl().run_mg_assembly_pipeline( self.getContext(), { "reads_upa": None, "output_assembly_name": "MyNewAssembly", "workspace_name": util.get_ws_name() }) with self.assertRaises(ValueError): self.getImpl().run_mg_assembly_pipeline( self.getContext(), { "reads_upa": self.reads_upa, "output_assembly_name": None, "workspace_name": util.get_ws_name() }) with self.assertRaises(ValueError): self.getImpl().run_mg_assembly_pipeline( self.getContext(), { "reads_upa": self.reads_upa, "output_assembly_name": "MyNewAssembly", "workspace_name": None })
def test_run_pipeline_default_ok(self): # load some data here. output = self.getImpl().run_mg_assembly_pipeline( self.getContext(), { "reads_upa": self.reads_upa, "output_assembly_name": "MyNewAssembly", "workspace_name": util.get_ws_name(), "debug": 1 })[0] self.assertIn('report_name', output) self.assertIn('report_ref', output) self.assertIn('assembly_upa', output) pprint(output)
def test_upload_assembly_bad_inputs(self): """ Missing or malformed inputs to file.upload_assembly(). Should fail properly. """ file_util = self._get_file_util() with self.assertRaises(ValueError) as cm: file_util.upload_assembly(None, util.get_ws_name(), "MyAssembly") self.assertIn("must be defined", str(cm.exception)) with self.assertRaises(ValueError) as cm: file_util.upload_assembly("not_a_file", util.get_ws_name(), "MyAssembly") self.assertIn("does not exist", str(cm.exception)) with self.assertRaises(ValueError) as cm: file_util.upload_assembly(self.scratch_assembly, None, "MyAssembly") self.assertIn("must be defined", str(cm.exception)) with self.assertRaises(ValueError) as cm: file_util.upload_assembly(self.scratch_assembly, util.get_ws_name(), None) self.assertIn("must be defined", str(cm.exception)) with self.assertRaises(Exception): file_util.upload_assembly(self.scratch_assembly, "not_a_workspace", "MyAssembly")
def test_upload_assembly_ok(self): """ happy test - all fields properly made. """ file_util = self._get_file_util() asm_upa = file_util.upload_assembly(self.scratch_assembly, util.get_ws_name(), "MyAssembly") self.assertIsNotNone(asm_upa) ws = util.get_ws_client() asm_info = ws.get_object_info3({'objects': [{ 'ref': asm_upa }]})['infos'][0] self.assertEquals("MyAssembly", asm_info[1]) self.assertIn("KBaseGenomeAnnotations.Assembly", asm_info[2])
def test_make_report_bad_inputs(self): pipeline_output = { "bbmap": { "stats_file": self.bbmap_stats_file, "coverage_file": self.cov_stats, "command": "bbmap cmd", "version_string": "bbmap version" }, "stats": { "stats_txt": self.assembly_stats_file, "stats_tsv": self.assembly_stats_tsv, "command": "stats command", "version_string": "stats version" }, "rqcfilter": { "run_log": self.rqcfilter_log, "command": "rqcfilter command", "version_string": "rqcfilter version" }, "reads_info_prefiltered": { "count": 10000, "command": "reads_info_prefiltered command", "version_string": "reads info version" }, "reads_info_filtered": { "count": 8000, "command": "reads_info_filtered command", "version_string": "reads info version" }, "reads_info_corrected": { "count": 7000, "command": "reads_info_corrected command", "version_string": "reads info version" }, "bfc": { "command": "bfc command", "version_string": "bfc version" }, "seqtk": { "command": "seqtk command", "version_string": "seqtk verseion" }, "spades": { "command": "spades command", "version_string": "spades version" }, "agp": { "command": "agp command", "version_string": "agp version" }, } ru = self._get_report_util() with self.assertRaises(AssertionError) as err: ru.make_report(None, util.get_ws_name(), []) self.assertIn("Pipeline output not found!", str(err.exception)) for key in ["reads_info_prefiltered", "reads_info_filtered", "reads_info_corrected"]: output_copy = deepcopy(pipeline_output) del output_copy[key] with self.assertRaises(AssertionError) as err: ru.make_report(output_copy, util.get_ws_name(), []) self.assertIn("Required reads info '{}' is not present!".format(key), str(err.exception)) with self.assertRaises(AssertionError) as err: ru.make_report(pipeline_output, None, []) self.assertIn("A workspace name is required", str(err.exception))