Skip to content

Commit b56f64b

Browse files
authored
MAINT: move partitioning and collating actions to q2-types (#175)
1 parent e1ae7f1 commit b56f64b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+72
-731
lines changed

q2_moshpit/__init__.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from . import abundance
99
from . import busco
1010
from . import eggnog
11-
from . import partition
1211
from . import prodigal
1312
from ._version import get_versions
1413
from .dereplication import dereplicate_mags
@@ -31,8 +30,8 @@
3130
__all__ = [
3231
'metabat2', 'bracken', 'kraken_class', 'kraken_db',
3332
'kaiju_class', 'kaiju_db', 'dereplicate_mags', 'eggnog',
34-
'busco', 'prodigal', 'kraken_helpers', 'partition',
35-
'filter_derep_mags', 'filter_mags', 'get_feature_lengths',
33+
'busco', 'prodigal', 'kraken_helpers', 'filter_derep_mags',
34+
'filter_mags', 'get_feature_lengths',
3635
'multiply_tables', '_multiply_tables', '_multiply_tables_pa',
3736
'_multiply_tables_relative', 'abundance', 'filter_reads_pangenome'
3837
]

q2_moshpit/busco/__init__.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88

99
from .busco import evaluate_busco, _evaluate_busco, _visualize_busco
1010
from .database import fetch_busco_db
11+
from .partition import collate_busco_results
1112

1213
__all__ = [
13-
"evaluate_busco", "_evaluate_busco", "_visualize_busco", "fetch_busco_db"
14+
"evaluate_busco", "_evaluate_busco", "_visualize_busco", "fetch_busco_db",
15+
"collate_busco_results"
1416
]

q2_moshpit/busco/busco.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ def evaluate_busco(
296296
partition_action = "partition_sample_data_mags"
297297
else:
298298
partition_action = "partition_feature_data_mags"
299-
partition_mags = ctx.get_action("moshpit", partition_action)
299+
partition_mags = ctx.get_action("types", partition_action)
300300

301301
(partitioned_mags, ) = partition_mags(bins, num_partitions)
302302
results = []
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
mag_id sample_id input_file dataset complete single duplicated fragmented missing n_markers scaffold_n50 contigs_n50 percent_gaps scaffolds length
2+
bec9c09a-62c3-4fbb-8f7f-9fdf9aefc02f SRR13221817 bec9c09a-62c3-4fbb-8f7f-9fdf9aefc02f.fasta bacteria_odb10 28.2 27.4 0.8 8.9 62.9 124 4785 4785 0.000% 265 1219165
3+
5978e667-0476-4921-8cc2-34b9d1b508c1 SRR13221817 5978e667-0476-4921-8cc2-34b9d1b508c1.fasta bacteria_odb10 1.6 1.6 0.0 1.6 96.8 124 3548 3548 0.000% 67 245922
4+
625c95e6-ac2f-4e6e-9470-af8cd11c75dd SRR13221817 625c95e6-ac2f-4e6e-9470-af8cd11c75dd.fasta bacteria_odb10 26.6 26.6 0.0 3.2 70.2 124 78679 78679 0.000% 17 714893
5+
6ed8c097-1c87-4019-8b38-b95507011b41 SRR14143412 6ed8c097-1c87-4019-8b38-b95507011b41.fasta bacteria_odb10 8.1 8.1 0.0 0.8 91.1 124 74198 74198 0.000% 11 560715
6+
bf2c0af0-83ba-44a6-b550-3b7884a62a82 SRR14143412 bf2c0af0-83ba-44a6-b550-3b7884a62a82.fasta bacteria_odb10 95.9 93.5 2.4 2.4 1.7 124 80820 80820 0.000% 92 4253319
7+
a2401d15-802f-42c3-9eb4-c282e2141b14 SRR14143412 a2401d15-802f-42c3-9eb4-c282e2141b14.fasta bacteria_odb10 89.5 89.5 0.0 1.6 8.9 124 31708 31708 0.000% 106 2120157
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
mag_id sample_id input_file dataset complete single duplicated fragmented missing n_markers scaffold_n50 contigs_n50 percent_gaps scaffolds length
2+
bec9c09a-62c3-4fbb-8f7f-9fdf9aefc02f SRR13221817 bec9c09a-62c3-4fbb-8f7f-9fdf9aefc02f.fasta bacteria_odb10 28.2 27.4 0.8 8.9 62.9 124 4785 4785 0.000% 265 1219165
3+
5978e667-0476-4921-8cc2-34b9d1b508c1 SRR13221817 5978e667-0476-4921-8cc2-34b9d1b508c1.fasta bacteria_odb10 1.6 1.6 0.0 1.6 96.8 124 3548 3548 0.000% 67 245922
4+
625c95e6-ac2f-4e6e-9470-af8cd11c75dd SRR13221817 625c95e6-ac2f-4e6e-9470-af8cd11c75dd.fasta bacteria_odb10 26.6 26.6 0.0 3.2 70.2 124 78679 78679 0.000% 17 714893
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
mag_id sample_id input_file dataset complete single duplicated fragmented missing n_markers scaffold_n50 contigs_n50 percent_gaps scaffolds length
2+
6ed8c097-1c87-4019-8b38-b95507011b41 SRR14143412 6ed8c097-1c87-4019-8b38-b95507011b41.fasta bacteria_odb10 8.1 8.1 0.0 0.8 91.1 124 74198 74198 0.000% 11 560715
3+
bf2c0af0-83ba-44a6-b550-3b7884a62a82 SRR14143412 bf2c0af0-83ba-44a6-b550-3b7884a62a82.fasta bacteria_odb10 95.9 93.5 2.4 2.4 1.7 124 80820 80820 0.000% 92 4253319
4+
a2401d15-802f-42c3-9eb4-c282e2141b14 SRR14143412 a2401d15-802f-42c3-9eb4-c282e2141b14.fasta bacteria_odb10 89.5 89.5 0.0 1.6 8.9 124 31708 31708 0.000% 106 2120157
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# ----------------------------------------------------------------------------
2+
# Copyright (c) 2022-2023, QIIME 2 development team.
3+
#
4+
# Distributed under the terms of the Modified BSD License.
5+
#
6+
# The full license is in the file LICENSE, distributed with this software.
7+
# ----------------------------------------------------------------------------
8+
import os
9+
10+
import pandas as pd
11+
from qiime2.plugin.testing import TestPluginBase
12+
13+
from q2_moshpit.busco.partition import collate_busco_results
14+
from q2_moshpit.busco.types import BUSCOResultsDirectoryFormat
15+
16+
17+
class TestBUSCOPlots(TestPluginBase):
18+
package = "q2_moshpit.busco.tests"
19+
20+
def test_collate_busco_results(self):
21+
p1 = self.get_data_path("busco_results/sample1")
22+
p2 = self.get_data_path("busco_results/sample2")
23+
24+
busco_results = [
25+
BUSCOResultsDirectoryFormat(p1, mode="r"),
26+
BUSCOResultsDirectoryFormat(p2, mode="r")
27+
]
28+
29+
collated_busco_result = collate_busco_results(busco_results)
30+
31+
obs = pd.read_csv(
32+
os.path.join(str(collated_busco_result), "busco_results.tsv"))
33+
exp = pd.read_csv(
34+
self.get_data_path("busco_results/collated/busco_results.tsv"))
35+
36+
pd.testing.assert_frame_equal(obs, exp)

q2_moshpit/eggnog/annotation.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,12 @@ def eggnog_annotate(
6868
num_partitions=None
6969
):
7070
_eggnog_annotate = ctx.get_action("moshpit", "_eggnog_annotate")
71-
collate_annotations = ctx.get_action("moshpit", "collate_annotations")
71+
collate_annotations = ctx.get_action(
72+
"types", "collate_ortholog_annotations"
73+
)
7274

7375
if eggnog_hits.type <= SampleData[Orthologs]:
74-
partition_method = ctx.get_action("moshpit", "partition_orthologs")
76+
partition_method = ctx.get_action("types", "partition_orthologs")
7577
else:
7678
raise NotImplementedError()
7779

q2_moshpit/eggnog/orthologs/common.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,17 @@ def _run_eggnog_search_pipeline(
7474
- collated_tables: The collated feature tables.
7575
"""
7676
if sequences.type <= FeatureData[MAG]:
77-
plugin, action_name = "moshpit", "partition_feature_data_mags"
77+
plugin, action_name = "types", "partition_feature_data_mags"
7878
elif sequences.type <= SampleData[Contigs]:
7979
plugin, action_name = "assembly", "partition_contigs"
8080
elif sequences.type <= SampleData[MAGs]:
81-
plugin, action_name = "moshpit", "partition_sample_data_mags"
81+
plugin, action_name = "types", "partition_sample_data_mags"
8282
else:
8383
raise NotImplementedError()
8484

8585
partition_method = ctx.get_action(plugin, action_name)
8686
_eggnog_search = ctx.get_action("moshpit", search_action)
87-
collate_hits = ctx.get_action("moshpit", "collate_orthologs")
87+
collate_hits = ctx.get_action("types", "collate_orthologs")
8888
_eggnog_feature_table = ctx.get_action("moshpit", "_eggnog_feature_table")
8989
(partitioned_sequences,) = partition_method(sequences, num_partitions)
9090

q2_moshpit/kraken2/classification.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def classify_kraken2(
8181
partition_method = ctx.get_action("assembly", "partition_contigs")
8282
elif seqs.type <= SampleData[MAGs]:
8383
partition_method = ctx.get_action(
84-
"moshpit", "partition_sample_data_mags"
84+
"types", "partition_sample_data_mags"
8585
)
8686
# FeatureData[MAG] is not parallelized
8787
elif seqs.type <= FeatureData[MAG]:

q2_moshpit/partition/__init__.py

-24
This file was deleted.

q2_moshpit/partition/annotations.py

-23
This file was deleted.

q2_moshpit/partition/mags.py

-141
This file was deleted.

0 commit comments

Comments
 (0)