From 7ec6e8b76ab81ba2269f023a77842d366990a23b Mon Sep 17 00:00:00 2001 From: Christian Diener Date: Thu, 4 Jan 2024 13:08:57 -0800 Subject: [PATCH] fix trimming update RNs --- NEWS.md | 6 ++++++ q2_micom/_build.py | 24 ++++++++++++++++++++---- setup.cfg | 24 ++++++++++++------------ 3 files changed, 38 insertions(+), 16 deletions(-) diff --git a/NEWS.md b/NEWS.md index b24d734..22bde2e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,12 @@ This includes a list of major changes for each minor version starting from 0.10. For information on how to use `q2-micom` please refer to [the tutorial](https://micom-dev.github.io/q2-micom). +#### 0.13.1 + +Fixes the broken prefix trimming. + +Now also reports the matched relative abundance in verbose build output. + ### 0.13.0 Fixes issues with the new model databases due to automatic stripping of taxonomic rank diff --git a/q2_micom/_build.py b/q2_micom/_build.py index 0af7a80..b1ede67 100644 --- a/q2_micom/_build.py +++ b/q2_micom/_build.py @@ -46,13 +46,29 @@ def build_spec( micom_taxonomy = pd.merge(model_files, tax, on=ranks) micom_taxonomy = micom_taxonomy[micom_taxonomy.relative > cutoff] del micom_taxonomy["file"] - stats = micom_taxonomy.sample_id.value_counts().describe() + n_stats = micom_taxonomy.sample_id.value_counts().describe() + ab_stats = micom_taxonomy.groupby("sample_id").relative.sum().describe() * 100.0 print("Merged with the database using ranks: %s" % ", ".join(ranks)) - if stats.count == 1.0: - stats["std"] = 0.0 + if n_stats.count() == 1: + n_stats["std"] = 0.0 + ab_stats["std"] = 0.0 print( "Each community model contains %d-%d taxa (average %d+-%d)." - % (stats["min"], stats["max"], round(stats["mean"]), round(stats["std"])) + % ( + n_stats["min"], + n_stats["max"], + round(n_stats["mean"]), + round(n_stats["std"]), + ) + ) + print( + "Community models cover %.2f%%-%.2f%% of the total abundance (average %.2f%%+-%.2f%%)." + % ( + ab_stats["min"], + ab_stats["max"], + round(ab_stats["mean"]), + round(ab_stats["std"]), + ) ) return micom_taxonomy diff --git a/setup.cfg b/setup.cfg index b76e02b..32b05bd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -12,7 +12,7 @@ long_description = file: README.md long_description_content_type = text/markdown license = Apache License 2.0 url = https://github.com/micom-dev/q2-micom -classifiers = +classifiers = Development Status :: 4 - Beta Intended Audience :: Science/Research Topic :: Scientific/Engineering :: Bio-Informatics @@ -22,7 +22,7 @@ classifiers = Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 -keywords = +keywords = microbiome modeling metabolism @@ -32,25 +32,25 @@ keywords = zip_safe = False packages = find: python_requires = >=3.6 -install_requires = +install_requires = cobra>=0.18.1 - micom>=0.33.0 + micom>=0.33.1 jinja2>=2.10.3 qiime2>=2021.2 rich>=6.0 pandas>=1.0 -tests_require = +tests_require = coverage pytest pytest-cov flake8 [options.package_data] -q2_micom = +q2_micom = citations.bib [options.entry_points] -qiime2.plugins = +qiime2.plugins = q2-micom = q2_micom.plugin_setup:plugin [bumpversion:file:setup.py] @@ -62,7 +62,7 @@ search = __version__ = "{current_version}" replace = __version__ = "{new_version}" [tool:pytest] -filterwarnings = +filterwarnings = ignore::DeprecationWarning ignore::FutureWarning @@ -75,15 +75,15 @@ branch = True omit = q2_micom/tests/* [coverage:report] -exclude_lines = +exclude_lines = pragma: no cover - + def __repr__ if self\.debug - + raise AssertionError raise NotImplementedError - + if 0: if __name__ == .__main__.: ignore_errors = True