From c5400c6e18d625da96909588a491a8eafcf6e491 Mon Sep 17 00:00:00 2001 From: Santiago Castro Dau Date: Tue, 14 May 2024 14:21:29 +0200 Subject: [PATCH] in online mode download db to temp directory --- q2_moshpit/busco/busco.py | 2 +- q2_moshpit/busco/tests/test_busco.py | 20 +++++++++----- q2_moshpit/plugin_setup.py | 41 +++++++++++++++------------- 3 files changed, 36 insertions(+), 27 deletions(-) diff --git a/q2_moshpit/busco/busco.py b/q2_moshpit/busco/busco.py index 4b0ac0db..a49880c7 100644 --- a/q2_moshpit/busco/busco.py +++ b/q2_moshpit/busco/busco.py @@ -70,7 +70,7 @@ def _run_busco( "-o", sample ]) - run_command(cmd) + run_command(cmd, cwd=os.path.dirname(output_dir)) path_to_run_summary = os.path.join( output_dir, sample, "batch_summary.txt" diff --git a/q2_moshpit/busco/tests/test_busco.py b/q2_moshpit/busco/tests/test_busco.py index c8ee7b6b..d69e5f3b 100644 --- a/q2_moshpit/busco/tests/test_busco.py +++ b/q2_moshpit/busco/tests/test_busco.py @@ -61,15 +61,21 @@ def test_run_busco(self, mock_run): self.assertDictEqual(obs, exp) mock_run.assert_has_calls([ call( - ['busco', '--lineage_dataset', 'bacteria_odb10', - '--cpu', '7', '--in', self.get_data_path('mags/sample1'), - '--out_path', self.temp_dir.name, '-o', 'sample1'], + [ + 'busco', '--lineage_dataset', 'bacteria_odb10', + '--cpu', '7', '--in', self.get_data_path('mags/sample1'), + '--out_path', self.temp_dir.name, '-o', 'sample1' + ], + cwd=os.path.dirname(self.temp_dir.name) ), call( - ['busco', '--lineage_dataset', 'bacteria_odb10', - '--cpu', '7', '--in', self.get_data_path('mags/sample2'), - '--out_path', self.temp_dir.name, '-o', 'sample2'], - ) + [ + 'busco', '--lineage_dataset', 'bacteria_odb10', + '--cpu', '7', '--in', self.get_data_path('mags/sample2'), + '--out_path', self.temp_dir.name, '-o', 'sample2' + ], + cwd=os.path.dirname(self.temp_dir.name) + ), ]) @patch('q2_moshpit.busco.busco._run_busco') diff --git a/q2_moshpit/plugin_setup.py b/q2_moshpit/plugin_setup.py index 96ef8fa3..6e8b9bce 100644 --- a/q2_moshpit/plugin_setup.py +++ b/q2_moshpit/plugin_setup.py @@ -1103,6 +1103,21 @@ description="Collates BUSCO results." ) +plugin.visualizers.register_function( + function=q2_moshpit.busco._visualize_busco, + inputs={ + "busco_results": BUSCOResults, + }, + parameters={}, + input_descriptions={ + "busco_results": "BUSCO results table.", + }, + parameter_descriptions={}, + name="Visualize BUSCO results.", + description="This method generates a visualization " + "from the BUSCO results table.", + citations=[citations["manni_busco_2021"]], +) plugin.methods.register_function( function=q2_moshpit.busco._evaluate_busco, @@ -1117,7 +1132,9 @@ input_descriptions={ "bins": "MAGs to be analyzed.", "busco_db": "BUSCO database. If provided BUSCO will run in offline " - "mode." + "mode. If not provided a BUSCO database " + "will be downloaded to a temporary location and then " + "deleted." }, parameter_descriptions=busco_param_descriptions, output_descriptions={ @@ -1131,22 +1148,6 @@ citations=[citations["manni_busco_2021"]], ) -plugin.visualizers.register_function( - function=q2_moshpit.busco._visualize_busco, - inputs={ - "busco_results": BUSCOResults, - }, - parameters={}, - input_descriptions={ - "busco_results": "BUSCO results table.", - }, - parameter_descriptions={}, - name="Visualize BUSCO results.", - description="This method generates a visualization " - "from the BUSCO results table.", - citations=[citations["manni_busco_2021"]], -) - plugin.pipelines.register_function( function=q2_moshpit.busco.evaluate_busco, inputs={ @@ -1161,7 +1162,9 @@ input_descriptions={ "bins": "MAGs to be analyzed.", "busco_db": "BUSCO database. If provided BUSCO will run in offline " - "mode." + "mode. If not provided a BUSCO database " + "will be downloaded to a temporary location and then " + "deleted." }, parameter_descriptions={ **busco_param_descriptions, **partition_param_descriptions @@ -1174,7 +1177,7 @@ description="This method uses BUSCO " "(Benchmarking Universal Single-Copy Ortholog assessment " "tool) to assess the quality of assembled MAGs and generates " - "visualizations summarizing the results.", + "a table summarizing the results.", citations=[citations["manni_busco_2021"]], )