diff --git a/data_managers/data_manager_humann_database_downloader/.shed.yml b/data_managers/data_manager_humann_database_downloader/.shed.yml
index 15f56c948c4..a7364a31cd5 100644
--- a/data_managers/data_manager_humann_database_downloader/.shed.yml
+++ b/data_managers/data_manager_humann_database_downloader/.shed.yml
@@ -1,13 +1,17 @@
name: data_manager_humann_database_downloader
owner: iuc
-description: "HUMAnN2 for functionally profiling metagenomes and metatranscriptomes at species-level resolution"
+description: "Reference data (ChocoPhlAn, UniRef, utility mappings) for HUMAnN, for functional profiling of metagenomes and metatranscriptomes"
homepage_url: http://huttenhower.sph.harvard.edu/humann
long_description: |
- HUMAnN is a pipeline for efficiently and accurately profiling the presence/absence and abundance of microbial pathways
- in a community from metagenomic or metatranscriptomic sequencing data (typically millions of short DNA/RNA reads).
- This process, referred to as functional profiling, aims to describe the metabolic potential of a microbial community
- and its members. More generally, functional profiling answers the question "What are the microbes in my community-of-interest
- doing (or capable of doing)?"
+ Downloads the reference data HUMAnN needs: the ChocoPhlAn pangenome catalog (nucleotide
+ search), UniRef protein clusters (translated search) and the utility mapping files
+ (regrouping and renaming HUMAnN features).
+
+ The data manager records the versioned name of the upstream artifact in the data table
+ value (e.g. `full_chocophlan.v201901_v31`, `uniref90_annotated_v201901b_full`,
+ `full_mapping_v201901b`) instead of an installation date, so that the same data has the
+ same identity on every Galaxy instance and in serialized workflows. These data
+ generations are identical for every HUMAnN release from 3.1.1 to 3.9.
remote_repository_url: https://github.com/galaxyproject/tools-iuc/tree/main/data_managers/data_manager_humann_database_downloader
type: unrestricted
categories:
diff --git a/data_managers/data_manager_humann_database_downloader/data_manager/data_manager_humann_download.py b/data_managers/data_manager_humann_database_downloader/data_manager/data_manager_humann_download.py
index 6723922b5c1..e30b2d0176c 100644
--- a/data_managers/data_manager_humann_database_downloader/data_manager/data_manager_humann_download.py
+++ b/data_managers/data_manager_humann_database_downloader/data_manager/data_manager_humann_download.py
@@ -4,8 +4,8 @@
import argparse
import json
import subprocess
-from datetime import date
from pathlib import Path
+from urllib.parse import urlparse
HUMANN_REFERENCE_DATA = {
"chocophlan": {
@@ -113,6 +113,30 @@ def add_data_table_entry(d, table, entry):
raise Exception("add_data_table_entry: no table '%s'" % table)
+def get_database_source_id(database, build):
+ """Return the versioned artifact name advertised by HUMAnN.
+
+ HUMAnN names its reference bundles after the data they contain
+ (e.g. ``full_chocophlan.v201901_v31``), so the artifact name is the
+ only immutable identity available: it changes when the data changes
+ and is identical on every server. The human readable build labels
+ (``full``, ``DEMO``, ``uniref90_diamond``, ...) are not unique across
+ data generations, so they are only used as ``value`` namespaces.
+ """
+ available = subprocess.check_output(
+ ["humann_databases", "--available"], text=True
+ )
+ prefix = f"{database} : {build} = "
+ for line in available.splitlines():
+ if line.startswith(prefix):
+ filename = Path(urlparse(line[len(prefix):]).path).name
+ for suffix in (".tar.gz", ".tar.bz2", ".tgz", ".zip"):
+ if filename.endswith(suffix):
+ return filename[:-len(suffix)]
+ return filename
+ raise RuntimeError(f"Unable to determine source for {database} {build}")
+
+
def download_humann_db(data_tables, table_name, database, build, version, target_dp):
"""Download HUMAnN database
@@ -134,12 +158,18 @@ def download_humann_db(data_tables, table_name, database, build, version, target
db_target_dp = target_dp / Path(database)
db_dp = db_target_dp / Path(database)
build_target_dp = db_target_dp / Path(build)
+ source_id = get_database_source_id(database, build)
# launch tool to get db
- cmd = "humann_databases --download %s %s %s --update-config no" % (
+ cmd = [
+ "humann_databases",
+ "--download",
database,
build,
- db_target_dp)
- subprocess.check_call(cmd, shell=True)
+ str(db_target_dp),
+ "--update-config",
+ "no",
+ ]
+ subprocess.check_call(cmd)
# move db
db_dp.rename(build_target_dp)
# add details to data table
@@ -148,19 +178,21 @@ def download_humann_db(data_tables, table_name, database, build, version, target
data_tables,
table_name,
dict(
- value="%s-%s-%s-%s" % (database, build, version, date.today().strftime("%d%m%Y")),
- name=HUMANN_REFERENCE_DATA[database][build],
+ value=f"{database}-{build}-{source_id}",
+ # the label alone is identical for every data generation, so
+ # append the artifact name to make the choice reproducible
+ name=f"{HUMANN_REFERENCE_DATA[database][build]} ({source_id})",
dbkey=version,
path=str(build_target_dp)))
- elif args.database == "utility_mapping":
+ elif database == "utility_mapping":
for x in build_target_dp.iterdir():
name = str(x.stem).split('.')[0]
add_data_table_entry(
data_tables,
table_name,
dict(
- value="%s-%s-%s-%s-%s%s" % (database, build, name, version, date.today().strftime("%d%m%Y"), x.suffix),
- name=HUMANN_REFERENCE_DATA["utility_mapping"][build][name],
+ value=f"{database}-{build}-{name}-{source_id}{x.suffix}",
+ name=f"{HUMANN_REFERENCE_DATA['utility_mapping'][build][name]} ({source_id})",
dbkey=version,
path=str(x)))
diff --git a/data_managers/data_manager_humann_database_downloader/data_manager/data_manager_humann_download.xml b/data_managers/data_manager_humann_database_downloader/data_manager/data_manager_humann_download.xml
index 3c472d72f44..48608deeb86 100644
--- a/data_managers/data_manager_humann_database_downloader/data_manager/data_manager_humann_download.xml
+++ b/data_managers/data_manager_humann_database_downloader/data_manager/data_manager_humann_download.xml
@@ -2,7 +2,7 @@
Download HUMAnN database
3.9
- 0
+ 2
22.01
@@ -58,7 +58,7 @@ python '$__tool_directory__/data_manager_humann_download.py'
-
+
@@ -69,10 +69,9 @@ python '$__tool_directory__/data_manager_humann_download.py'
@@ -83,7 +82,6 @@ python '$__tool_directory__/data_manager_humann_download.py'
-
-This tool downloads the HUMAnN databases.
+ --`` (for
+ mappings additionally the mapping file name). It never contains an install
+ date: workflows serialize this value, so it has to be identical on every
+ Galaxy instance. The managed path is derived from it.
+``name``
+ Human readable label, as shown in the tool form, with the artifact name in
+ parentheses.
+``dbkey``
+ The HUMAnN version the entry was installed for. This is provenance, **not**
+ a data version — the data does not change between HUMAnN 3.1.1 and 3.9.
+``path``
+ Absolute path of the database directory (or of the mapping file) on this
+ server.
+
+**Adding data by hand**
+
+Install the bundle with ``humann_databases --download
+ --update-config no`` and add a row whose ``value`` follows the
+scheme above (the artifact name is the tarball name without the archive
+suffix). The directory must contain the files unmodified — HUMAnN checks the
+version strings in the file names. The ``DEMO`` bundles are reduced test data
+and are not suitable for real analyses.
+
+**Re-installing**
+
+The target path is derived from ``value``, so installing the same database and
+build twice produces the same entry and the same directory. Remove the existing
+entry first if you need to replace it.
Read more about the tool at http://huttenhower.sph.harvard.edu/humann .
-
+ ]]>
10.1371/journal.pcbi.1003153
diff --git a/data_managers/data_manager_humann_database_downloader/test-data/humann_nucleotide_database.loc b/data_managers/data_manager_humann_database_downloader/test-data/humann_nucleotide_database.loc
index bb2bbf45efd..81e55264cdf 100644
--- a/data_managers/data_manager_humann_database_downloader/test-data/humann_nucleotide_database.loc
+++ b/data_managers/data_manager_humann_database_downloader/test-data/humann_nucleotide_database.loc
@@ -1,4 +1,17 @@
#This is a sample file distributed with Galaxy that enables tools
-#to use a directory of metagenomics files.
-#file has this format (white space characters are TAB characters)
-#db-build-version-date db-name build /path/to/data
\ No newline at end of file
+#to use a directory of metagenomics files.
+#Tab separated with 4 columns (value, name, dbkey, path):
+# - value: stable identity of the data, "--"
+# (for utility mappings additionally the mapping file name and suffix),
+# never contains an install date, because workflows serialize it
+# e.g. chocophlan-full_full_chocophlan.v201901_v31
+# - name: human readable label shown in the tool form
+# - dbkey: the HUMAnN version the entry was installed for (provenance,
+# the data itself is the same for HUMAnN 3.1.1 - 3.9)
+# - path: absolute path of the database directory (or of the mapping file)
+#The artifact name is the name HUMAnN advertises for the bundle, see
+#`humann_databases --available`, without the archive suffix. HUMAnN checks the
+#version strings in the file names of the installed data, so the bundles must
+#be used unmodified.
+#Only the v201901_v31 generation works with HUMAnN 3.1.1 and later,
+#the v296_201901b bundles of HUMAnN 3.0.x are rejected at runtime.
diff --git a/data_managers/data_manager_humann_database_downloader/test-data/humann_protein_database.loc b/data_managers/data_manager_humann_database_downloader/test-data/humann_protein_database.loc
index bb2bbf45efd..29f981805a0 100644
--- a/data_managers/data_manager_humann_database_downloader/test-data/humann_protein_database.loc
+++ b/data_managers/data_manager_humann_database_downloader/test-data/humann_protein_database.loc
@@ -1,4 +1,16 @@
#This is a sample file distributed with Galaxy that enables tools
-#to use a directory of metagenomics files.
-#file has this format (white space characters are TAB characters)
-#db-build-version-date db-name build /path/to/data
\ No newline at end of file
+#to use a directory of metagenomics files.
+#Tab separated with 4 columns (value, name, dbkey, path):
+# - value: stable identity of the data, "--"
+# (for utility mappings additionally the mapping file name and suffix),
+# never contains an install date, because workflows serialize it
+# e.g. uniref-uniref90_diamond-uniref90_annotated_v201901b_full
+# - name: human readable label shown in the tool form
+# - dbkey: the HUMAnN version the entry was installed for (provenance,
+# the data itself is the same for HUMAnN 3.1.1 - 3.9)
+# - path: absolute path of the database directory (or of the mapping file)
+#The artifact name is the name HUMAnN advertises for the bundle, see
+#`humann_databases --available`, without the archive suffix. HUMAnN checks the
+#version strings in the file names of the installed data, so the bundles must
+#be used unmodified.
+#The 201901b bundles are used by every HUMAnN 3.x release.
diff --git a/data_managers/data_manager_humann_database_downloader/test-data/humann_utility_mapping.loc b/data_managers/data_manager_humann_database_downloader/test-data/humann_utility_mapping.loc
index bb2bbf45efd..150f23e5653 100644
--- a/data_managers/data_manager_humann_database_downloader/test-data/humann_utility_mapping.loc
+++ b/data_managers/data_manager_humann_database_downloader/test-data/humann_utility_mapping.loc
@@ -1,4 +1,17 @@
#This is a sample file distributed with Galaxy that enables tools
-#to use a directory of metagenomics files.
-#file has this format (white space characters are TAB characters)
-#db-build-version-date db-name build /path/to/data
\ No newline at end of file
+#to use a directory of metagenomics files.
+#Tab separated with 4 columns (value, name, dbkey, path):
+# - value: stable identity of the data, "--"
+# (for utility mappings additionally the mapping file name and suffix),
+# never contains an install date, because workflows serialize it
+# e.g. utility_mapping-full-map_go_uniref90-full_mapping_v201901b.txt
+# - name: human readable label shown in the tool form
+# - dbkey: the HUMAnN version the entry was installed for (provenance,
+# the data itself is the same for HUMAnN 3.1.1 - 3.9)
+# - path: absolute path of the database directory (or of the mapping file)
+#The artifact name is the name HUMAnN advertises for the bundle, see
+#`humann_databases --available`, without the archive suffix. HUMAnN checks the
+#version strings in the file names of the installed data, so the bundles must
+#be used unmodified.
+#Every HUMAnN 3.x release uses the same 201901b mapping bundle. The file
+#name (map_go_uniref90, map_go_name, ...) selects one of the ~20 mappings.
diff --git a/data_managers/data_manager_humann_database_downloader/tool-data/humann_nucleotide_database.loc.sample b/data_managers/data_manager_humann_database_downloader/tool-data/humann_nucleotide_database.loc.sample
index bb2bbf45efd..5599bc5ebda 100644
--- a/data_managers/data_manager_humann_database_downloader/tool-data/humann_nucleotide_database.loc.sample
+++ b/data_managers/data_manager_humann_database_downloader/tool-data/humann_nucleotide_database.loc.sample
@@ -1,4 +1,19 @@
#This is a sample file distributed with Galaxy that enables tools
-#to use a directory of metagenomics files.
-#file has this format (white space characters are TAB characters)
-#db-build-version-date db-name build /path/to/data
\ No newline at end of file
+#to use a directory of metagenomics files.
+#Tab separated with 4 columns (value, name, dbkey, path):
+# - value: stable identity of the data, "--"
+# (for utility mappings additionally the mapping file name and suffix),
+# never contains an install date, because workflows serialize it
+# e.g. chocophlan-full_full_chocophlan.v201901_v31
+# - name: human readable label shown in the tool form
+# - dbkey: the HUMAnN version the entry was installed for (provenance,
+# the data itself is the same for HUMAnN 3.1.1 - 3.9)
+# - path: absolute path of the database directory (or of the mapping file)
+#The artifact name is the name HUMAnN advertises for the bundle, see
+#`humann_databases --available`, without the archive suffix. HUMAnN checks the
+#version strings in the file names of the installed data, so the bundles must
+#be used unmodified.
+#Only the v201901_v31 generation works with HUMAnN 3.1.1 and later,
+#the v296_201901b bundles of HUMAnN 3.0.x are rejected at runtime.
+
+chocophlan-full-full_chocophlan.v201901_v31 Full ChocoPhlAn for HUManN (full_chocophlan.v201901_v31) 3.9 /path/to/data
diff --git a/data_managers/data_manager_humann_database_downloader/tool-data/humann_protein_database.loc.sample b/data_managers/data_manager_humann_database_downloader/tool-data/humann_protein_database.loc.sample
index bb2bbf45efd..a0089b6b631 100644
--- a/data_managers/data_manager_humann_database_downloader/tool-data/humann_protein_database.loc.sample
+++ b/data_managers/data_manager_humann_database_downloader/tool-data/humann_protein_database.loc.sample
@@ -1,4 +1,18 @@
#This is a sample file distributed with Galaxy that enables tools
-#to use a directory of metagenomics files.
-#file has this format (white space characters are TAB characters)
-#db-build-version-date db-name build /path/to/data
\ No newline at end of file
+#to use a directory of metagenomics files.
+#Tab separated with 4 columns (value, name, dbkey, path):
+# - value: stable identity of the data, "--"
+# (for utility mappings additionally the mapping file name and suffix),
+# never contains an install date, because workflows serialize it
+# e.g. uniref-uniref90_diamond-uniref90_annotated_v201901b_full
+# - name: human readable label shown in the tool form
+# - dbkey: the HUMAnN version the entry was installed for (provenance,
+# the data itself is the same for HUMAnN 3.1.1 - 3.9)
+# - path: absolute path of the database directory (or of the mapping file)
+#The artifact name is the name HUMAnN advertises for the bundle, see
+#`humann_databases --available`, without the archive suffix. HUMAnN checks the
+#version strings in the file names of the installed data, so the bundles must
+#be used unmodified.
+#The 201901b bundles are used by every HUMAnN 3.x release.
+
+uniref-uniref90_diamond-uniref90_annotated_v201901b_full Full UniRef90 for HUManN (uniref90_annotated_v201901b_full) 3.9 /path/to/data
diff --git a/data_managers/data_manager_humann_database_downloader/tool-data/humann_utility_mapping.loc.sample b/data_managers/data_manager_humann_database_downloader/tool-data/humann_utility_mapping.loc.sample
index bb2bbf45efd..8489b95efe1 100644
--- a/data_managers/data_manager_humann_database_downloader/tool-data/humann_utility_mapping.loc.sample
+++ b/data_managers/data_manager_humann_database_downloader/tool-data/humann_utility_mapping.loc.sample
@@ -1,4 +1,19 @@
#This is a sample file distributed with Galaxy that enables tools
-#to use a directory of metagenomics files.
-#file has this format (white space characters are TAB characters)
-#db-build-version-date db-name build /path/to/data
\ No newline at end of file
+#to use a directory of metagenomics files.
+#Tab separated with 4 columns (value, name, dbkey, path):
+# - value: stable identity of the data, "--"
+# (for utility mappings additionally the mapping file name and suffix),
+# never contains an install date, because workflows serialize it
+# e.g. utility_mapping-full-map_go_uniref90-full_mapping_v201901b.txt
+# - name: human readable label shown in the tool form
+# - dbkey: the HUMAnN version the entry was installed for (provenance,
+# the data itself is the same for HUMAnN 3.1.1 - 3.9)
+# - path: absolute path of the database directory (or of the mapping file)
+#The artifact name is the name HUMAnN advertises for the bundle, see
+#`humann_databases --available`, without the archive suffix. HUMAnN checks the
+#version strings in the file names of the installed data, so the bundles must
+#be used unmodified.
+#Every HUMAnN 3.x release uses the same 201901b mapping bundle. The file
+#name (map_go_uniref90, map_go_name, ...) selects one of the ~20 mappings.
+
+utility_mapping-full-map_go_uniref90-full_mapping_v201901b.txt Mapping (full) for Gene Ontology (GO) from UniRef90 (full_mapping_v201901b) 3.9 /path/to/data/map_go_uniref90.txt
diff --git a/data_managers/data_manager_metaphlan_database_downloader/data_manager/data_manager_metaphlan_download.xml b/data_managers/data_manager_metaphlan_database_downloader/data_manager/data_manager_metaphlan_download.xml
index c0e7b99c980..18c2076284f 100644
--- a/data_managers/data_manager_metaphlan_database_downloader/data_manager/data_manager_metaphlan_download.xml
+++ b/data_managers/data_manager_metaphlan_database_downloader/data_manager/data_manager_metaphlan_download.xml
@@ -2,7 +2,7 @@
4.0.6
- 5
+ 6
metaphlan
@@ -68,7 +68,75 @@
--bowtie2db `` for one selected
+database: it downloads the prebuilt Bowtie2 indexes plus ``.pkl``, the ``_SGB``/``_VSG``
+sequence files and ``_VINFO.csv`` from ``cmprod1.cibio.unitn.it/biobakery4/metaphlan_databases``
+(md5 verified), extracts them below the chosen directory and adds one row to the
+``metaphlan_database_versioned`` data table, from which the MetaPhlAn and HUMAnN tools choose
+their database. The job needs outbound HTTP(S) access to that host and roughly the download
+size as free disk.
+
+Available databases
+===================
+
+- ``mpa_vJan21_CHOCOPhlAnSGB_202103`` - release vJan21, 2.6 GB, for HUMAnN 3.5 to 3.6.1
+- ``mpa_vOct22_CHOCOPhlAnSGB_202212`` - release vOct22, 2.9 GB, for HUMAnN 3.7 and 3.8
+- ``mpa_vOct22_CHOCOPhlAnSGB_202403`` - release vOct22, 2.7 GB, likewise (rebuilt)
+- ``mpa_vJun23_CHOCOPhlAnSGB_202307`` - release vJun23, 3.2 GB, for HUMAnN 3.9
+- ``mpa_vJun23_CHOCOPhlAnSGB_202403`` - release vJun23, 3.2 GB, likewise (rebuilt)
+- ``mpa_vJan25_CHOCOPhlAnSGB_202503`` - release vJan25, 4.9 GB, MetaPhlAn 4.2 and later only
+- ``mpa_vJan21_TOY_CHOCOPhlAnSGB_202103`` - 1 MB, for demos and tests
+
+MetaPhlAn itself can profile with any SGB database; HUMAnN is the picky consumer. It does not
+accept a version range but one or two specific marker releases, because it checks the profile
+header (e.g. for ``vJun23``) and because it needs an SGB-to-pangenome map that is generated per
+marker release. ``vJan25`` and later are rejected by every released HUMAnN.
+
+Prefer the ``_202403`` builds: the ``_202212``/``_202307`` originals truncate profile lines
+(upstream ships a fixing script; the ``_202403`` rebuilds already contain the fix).
+
+Naming scheme
+=============
+
+The name packs two independent pieces of information, e.g. ``mpa_vOct22_CHOCOPhlAnSGB_202212``:
+
+- ``vOct22`` is the **marker release tag**. It changes when the SGB marker set changes
+ (``vJan21`` -> ``vOct22`` -> ``vJun23`` -> ``vJan25``) and it is what downstream tools test
+ against the profile header - this is the part to select for.
+- ``_202212`` is the **build date of that tarball**, not a version. A release is rebuilt when
+ bugs are fixed (``_202212`` -> ``_202403``), which is why the same build date suffix exists
+ under more than one release tag.
+
+``mpa_v30_CHOCOPhlAn_201901`` (MetaPhlAn 3.0, 366 MB) has no release tag and a different file
+format. It is not offered here: MetaPhlAn 4.x looks for it under a path where it no longer
+exists, so it has to be fetched from the ``biobakery3`` directory by hand and added to the table
+with ``db_version = legacy``. The Galaxy tools then pass ``--mpa3`` when they see that value.
+
+Table columns
+=============
+
+- ``value`` - ``-``. It carries the install date, so re-running this tool for
+ the same index adds a second row instead of replacing the first: delete the old row before
+ installing again. Rows added by hand should omit the date (a workflow step that pins ``value``
+ would otherwise not be portable between servers).
+- ``name`` - free text, shown in the tool forms.
+- ``dbkey`` - the database index, i.e. the value passed to ``metaphlan --index``.
+- ``path`` - the directory holding the database.
+- ``db_version`` - ``SGB`` for every database offered here, ``legacy`` for a pre-v4 one.
+
+There is deliberately no "latest" choice: upstream's ``mpa_latest`` currently points at
+``mpa_vJan26_CHOCOPhlAnSGB_202611``, which no released HUMAnN can use.
+
+Companion software
+==================
+
+HUMAnN 3.x needs MetaPhlAn 4.1.1 or older in its own environment: 4.2 renamed the command line
+options of the prescreen step, and 4.1.2 changed the output of ``metaphlan --version``, which
+HUMAnN parses (the run then stops with "CRITICAL ERROR: Can not call software version for
+metaphlan"). This concerns the *tool* version, not the database, which is plain data.
]]>
10.1101/2020.11.19.388223
diff --git a/tools/humann/humann.xml b/tools/humann/humann.xml
index b5dcd58b8f5..24b1deb13dc 100644
--- a/tools/humann/humann.xml
+++ b/tools/humann/humann.xml
@@ -1,4 +1,4 @@
-
+
to profile presence/absence and abundance of microbial pathways and gene families
macros.xml
@@ -11,8 +11,17 @@
-
-
+
+
+
@@ -47,6 +56,11 @@
#else
#set $metaphlan_option += " --bowtie2db %s" % $wf.prescreen.metaphlan_db.cached_db.fields.path
#set $metaphlan_option += " --index %s" % $wf.prescreen.metaphlan_db.cached_db.fields.dbkey
+ ## the data table records whether the database predates MetaPhlAn 4
+ ## (db_version: legacy), which requires the --mpa3 switch
+ #if $wf.prescreen.metaphlan_db.cached_db.fields.db_version == "legacy"
+ #set $metaphlan_option += " --mpa3"
+ #end if
#end if
--metaphlan-options="$metaphlan_option"
--prescreen-threshold $wf.prescreen.prescreen_threshold
@@ -64,6 +78,15 @@
+
+
+
@@ -110,6 +133,12 @@
+
+
@@ -977,6 +1006,10 @@ humann
+
+
+
+
@@ -1058,6 +1091,35 @@ HUMAnN can start from a few different types of input data each in a few differen
HUMAnN uses 3 reference databases
Locally cached databases have to be downloaded before using them (using the dedicated tool). Custom databases can also be used after upload.
+Reference data
+==============
+
+HUMAnN needs four databases: a nucleotide (ChocoPhlAn) and a protein (UniRef) database, the
+utility mappings, and a MetaPhlAn marker database for the prescreen step. All of them are read
+from data tables, and those offer only the entries this wrapper accepts, so an incompatible
+database cannot be selected by accident.
+
+The HUMAnN databases are named after their content, and that name is their version:
+``full_chocophlan.v201901_v31`` and ``uniref90_annotated_v201901b_full`` are unchanged from
+HUMAnN 3.1.1 to 3.9. HUMAnN 3.0.x is the exception: it fetched ``v296_201901b``, which every
+later release refuses.
+
+MetaPhlAn marker databases
+--------------------------
+
+``mpa_vOct22_CHOCOPhlAnSGB_202212`` packs two independent pieces of information:
+
+- ``vOct22`` is the **marker release tag**. It changes when the SGB marker set changes (vJan21 ->
+ vOct22 -> vJun23 -> vJan25) and it is what HUMAnN tests in the profile header, i.e. the part
+ that decides compatibility.
+- ``_202212`` is only the **build date of that tarball**. A release is rebuilt when bugs are fixed
+ (``_202212`` -> ``_202403``, which also fixes truncated profile lines), so the same suffix
+ appears under more than one release tag. Prefer the ``_202403`` builds.
+
+HUMAnN 3.9 accepts the releases ``v3`` (MetaPhlAn 3.x) and ``vJun23``; ``vJan21`` belonged to
+HUMAnN 3.5-3.6.1 and ``vOct22`` to 3.7/3.8, while ``vJan25`` and later have no HUMAnN at all.
+A pre-v4 database (``mpa_v30_CHOCOPhlAn_201901``) is passed with ``--mpa3`` automatically.
+
Outputs
=======
diff --git a/tools/humann/humann_regroup_table.xml b/tools/humann/humann_regroup_table.xml
index 7e99c167bfd..c17a435c7d6 100644
--- a/tools/humann/humann_regroup_table.xml
+++ b/tools/humann/humann_regroup_table.xml
@@ -46,7 +46,7 @@ humann_regroup_table
-
+
diff --git a/tools/humann/humann_rename_table.xml b/tools/humann/humann_rename_table.xml
index a2c5d0f7023..7f7504d3b3e 100644
--- a/tools/humann/humann_rename_table.xml
+++ b/tools/humann/humann_rename_table.xml
@@ -45,7 +45,7 @@ humann_rename_table
-
+
diff --git a/tools/humann/macros.xml b/tools/humann/macros.xml
index 9d950a7c35e..96fb4b8338c 100644
--- a/tools/humann/macros.xml
+++ b/tools/humann/macros.xml
@@ -1,7 +1,7 @@
3.9
- 0
+ 2
22.01
diff --git a/tools/humann/test-data/humann_nucleotide_database.loc b/tools/humann/test-data/humann_nucleotide_database.loc
index b504833cd67..13aa6ee0ab3 100644
--- a/tools/humann/test-data/humann_nucleotide_database.loc
+++ b/tools/humann/test-data/humann_nucleotide_database.loc
@@ -1,6 +1,5 @@
-# Tab separated with 4 columns:
-# - db-build-version-date
-# - db-name
-# - build
-# - /path/to/data
-chocophlan-DEMO-20210421 Demo ChocoPhlAn for HUManN humann_nucleotide_database ${__HERE__}/test-db/nucleotide-db/
\ No newline at end of file
+# Tab separated with 4 columns: value, name, dbkey, path
+# See tool-data/humann_nucleotide_database.loc.sample for the meaning of the columns.
+# Values of data installed by older versions of the data manager end with
+# the install date instead of the artifact name; those are accepted as well.
+chocophlan-DEMO-20210421 Demo ChocoPhlAn for HUMAnN humann_nucleotide_database ${__HERE__}/test-db/nucleotide-db/
diff --git a/tools/humann/test-data/humann_protein_database.loc b/tools/humann/test-data/humann_protein_database.loc
index bcb5adefff5..31184336fb4 100644
--- a/tools/humann/test-data/humann_protein_database.loc
+++ b/tools/humann/test-data/humann_protein_database.loc
@@ -1,6 +1,5 @@
-# Tab separated with 4 columns:
-# - db-build-version-date
-# - db-name
-# - build
-# - /path/to/data
-uniref-DEMO_diamond-20210421 Demo UniRef for HUManN DEMO_diamond ${__HERE__}/test-db/protein-db/
\ No newline at end of file
+# Tab separated with 4 columns: value, name, dbkey, path
+# See tool-data/humann_protein_database.loc.sample for the meaning of the columns.
+# Values of data installed by older versions of the data manager end with
+# the install date instead of the artifact name; those are accepted as well.
+uniref-DEMO_diamond-20210421 Demo UniRef for HUMAnN DEMO_diamond ${__HERE__}/test-db/protein-db/
diff --git a/tools/humann/test-data/humann_utility_mapping.loc b/tools/humann/test-data/humann_utility_mapping.loc
index 0031b5a4156..62e20dbdd54 100644
--- a/tools/humann/test-data/humann_utility_mapping.loc
+++ b/tools/humann/test-data/humann_utility_mapping.loc
@@ -1,7 +1,6 @@
-# Tab separated with 4 columns:
-# - db-build-version-date
-# - db-name
-# - build
-# - /path/to/data
+# Tab separated with 4 columns: value, name, dbkey, path
+# See tool-data/humann_utility_mapping.loc.sample for the meaning of the columns.
+# Values of data installed by older versions of the data manager end with
+# the install date instead of the artifact name; those are accepted as well.
utility_mapping-full-map_uniref90_name-3.0.0-29042021 Full mapping: UniRef90 from protein names full-map_uniref90_name ${__HERE__}/test-db/utility_mapping/map_uniref90_name.txt
-utility_mapping-full-map_go_uniref90-3.0.0-29042021 Full mapping: GO from UniRef90 full-map_go_uniref90 ${__HERE__}/test-db/utility_mapping/map_go_uniref90.txt
\ No newline at end of file
+utility_mapping-full-map_go_uniref90-3.0.0-29042021 Full mapping: GO from UniRef90 full-map_go_uniref90 ${__HERE__}/test-db/utility_mapping/map_go_uniref90.txt
diff --git a/tools/humann/test-data/metaphlan_database.loc b/tools/humann/test-data/metaphlan_database.loc
deleted file mode 100644
index 2df90b36493..00000000000
--- a/tools/humann/test-data/metaphlan_database.loc
+++ /dev/null
@@ -1,7 +0,0 @@
-# Tab separated with 4 columns:
-# - db-build-version-date
-# - db-name
-# - build
-# - /path/to/data
-metaphlan-demo-db-20210421 MetaPhlan Test Database demo-db-v30 ${__HERE__}/test-db/metaphlan-db
-metaphlan-db-old-structure MetaPhlan Test Database demo-db-v30 ${__HERE__}/test-db/metaphlan-db/old-structure
diff --git a/tools/humann/test-data/metaphlan_database_versioned.loc b/tools/humann/test-data/metaphlan_database_versioned.loc
new file mode 100644
index 00000000000..5e0f553c525
--- /dev/null
+++ b/tools/humann/test-data/metaphlan_database_versioned.loc
@@ -0,0 +1,9 @@
+# Tab separated with 5 columns: value, name, dbkey, path, db_version
+#
+# Only the db_version column is exercised by the tests: both fixtures are
+# MetaPhlAn 4 (SGB) databases, the second one with a legacy file layout and
+# empty bowtie2 indexes, which makes the prescreen step fail as expected.
+# A pre-v4 database (db_version: legacy) cannot be added here because there
+# is no such fixture, we would not be able to execute it.
+metaphlan-demo-db-20210421 MetaPhlAn SGB marker database (test) demo-db-v30 ${__HERE__}/test-db/metaphlan-db SGB
+metaphlan-db-old-structure MetaPhlAn database with outdated layout (test) demo-db-v30 ${__HERE__}/test-db/metaphlan-db/old-structure SGB
diff --git a/tools/humann/tool-data/humann_nucleotide_database.loc.sample b/tools/humann/tool-data/humann_nucleotide_database.loc.sample
index bc327952ea5..5599bc5ebda 100644
--- a/tools/humann/tool-data/humann_nucleotide_database.loc.sample
+++ b/tools/humann/tool-data/humann_nucleotide_database.loc.sample
@@ -1,8 +1,19 @@
#This is a sample file distributed with Galaxy that enables tools
-#to use a directory of metagenomics files.
-#file has this format (white space characters are TAB characters)
-# - db-build-version-date
-# - db-name
-# - build
-# - /path/to/data
-#02_16_2014 ChocoPhlAn chocophlan /path/to/data
\ No newline at end of file
+#to use a directory of metagenomics files.
+#Tab separated with 4 columns (value, name, dbkey, path):
+# - value: stable identity of the data, "--"
+# (for utility mappings additionally the mapping file name and suffix),
+# never contains an install date, because workflows serialize it
+# e.g. chocophlan-full_full_chocophlan.v201901_v31
+# - name: human readable label shown in the tool form
+# - dbkey: the HUMAnN version the entry was installed for (provenance,
+# the data itself is the same for HUMAnN 3.1.1 - 3.9)
+# - path: absolute path of the database directory (or of the mapping file)
+#The artifact name is the name HUMAnN advertises for the bundle, see
+#`humann_databases --available`, without the archive suffix. HUMAnN checks the
+#version strings in the file names of the installed data, so the bundles must
+#be used unmodified.
+#Only the v201901_v31 generation works with HUMAnN 3.1.1 and later,
+#the v296_201901b bundles of HUMAnN 3.0.x are rejected at runtime.
+
+chocophlan-full-full_chocophlan.v201901_v31 Full ChocoPhlAn for HUManN (full_chocophlan.v201901_v31) 3.9 /path/to/data
diff --git a/tools/humann/tool-data/humann_protein_database.loc.sample b/tools/humann/tool-data/humann_protein_database.loc.sample
index 3bb2b071ec3..a0089b6b631 100644
--- a/tools/humann/tool-data/humann_protein_database.loc.sample
+++ b/tools/humann/tool-data/humann_protein_database.loc.sample
@@ -1,8 +1,18 @@
#This is a sample file distributed with Galaxy that enables tools
-#to use a directory of metagenomics files.
-#file has this format (white space characters are TAB characters)
-# - db-build-version-date
-# - db-name
-# - build
-# - /path/to/data
-#02_16_2014 EC-filtered UniRef90 uniref90_ec_filtered_diamond /path/to/data
\ No newline at end of file
+#to use a directory of metagenomics files.
+#Tab separated with 4 columns (value, name, dbkey, path):
+# - value: stable identity of the data, "--"
+# (for utility mappings additionally the mapping file name and suffix),
+# never contains an install date, because workflows serialize it
+# e.g. uniref-uniref90_diamond-uniref90_annotated_v201901b_full
+# - name: human readable label shown in the tool form
+# - dbkey: the HUMAnN version the entry was installed for (provenance,
+# the data itself is the same for HUMAnN 3.1.1 - 3.9)
+# - path: absolute path of the database directory (or of the mapping file)
+#The artifact name is the name HUMAnN advertises for the bundle, see
+#`humann_databases --available`, without the archive suffix. HUMAnN checks the
+#version strings in the file names of the installed data, so the bundles must
+#be used unmodified.
+#The 201901b bundles are used by every HUMAnN 3.x release.
+
+uniref-uniref90_diamond-uniref90_annotated_v201901b_full Full UniRef90 for HUManN (uniref90_annotated_v201901b_full) 3.9 /path/to/data
diff --git a/tools/humann/tool-data/humann_utility_mapping.loc.sample b/tools/humann/tool-data/humann_utility_mapping.loc.sample
index 3f2d0efc1fb..8489b95efe1 100644
--- a/tools/humann/tool-data/humann_utility_mapping.loc.sample
+++ b/tools/humann/tool-data/humann_utility_mapping.loc.sample
@@ -1,9 +1,19 @@
#This is a sample file distributed with Galaxy that enables tools
-#to use a directory of metagenomics files.
-#file has this format (white space characters are TAB characters)
-# Tab separated with 4 columns:
-# - db-build-version-date
-# - db-name
-# - build
-# - /path/to/data
-#utility_mapping-full-20210421 Full mapping full /path/to/data
\ No newline at end of file
+#to use a directory of metagenomics files.
+#Tab separated with 4 columns (value, name, dbkey, path):
+# - value: stable identity of the data, "--"
+# (for utility mappings additionally the mapping file name and suffix),
+# never contains an install date, because workflows serialize it
+# e.g. utility_mapping-full-map_go_uniref90-full_mapping_v201901b.txt
+# - name: human readable label shown in the tool form
+# - dbkey: the HUMAnN version the entry was installed for (provenance,
+# the data itself is the same for HUMAnN 3.1.1 - 3.9)
+# - path: absolute path of the database directory (or of the mapping file)
+#The artifact name is the name HUMAnN advertises for the bundle, see
+#`humann_databases --available`, without the archive suffix. HUMAnN checks the
+#version strings in the file names of the installed data, so the bundles must
+#be used unmodified.
+#Every HUMAnN 3.x release uses the same 201901b mapping bundle. The file
+#name (map_go_uniref90, map_go_name, ...) selects one of the ~20 mappings.
+
+utility_mapping-full-map_go_uniref90-full_mapping_v201901b.txt Mapping (full) for Gene Ontology (GO) from UniRef90 (full_mapping_v201901b) 3.9 /path/to/data/map_go_uniref90.txt
diff --git a/tools/humann/tool-data/metaphlan_database.loc.sample b/tools/humann/tool-data/metaphlan_database.loc.sample
deleted file mode 100644
index 1a4f59aa831..00000000000
--- a/tools/humann/tool-data/metaphlan_database.loc.sample
+++ /dev/null
@@ -1,8 +0,0 @@
-#This is a sample file distributed with Galaxy that enables tools
-#to use a directory of metagenomics files.
-#file has this format (white space characters are TAB characters)
-# - db-build-version-date
-# - db-name
-# - build
-# - /path/to/data
-#02_16_2014 MetaPhlAn clade-specific marker genes db_v20 /path/to/data
diff --git a/tools/humann/tool-data/metaphlan_database_versioned.loc.sample b/tools/humann/tool-data/metaphlan_database_versioned.loc.sample
new file mode 100644
index 00000000000..4310410b45f
--- /dev/null
+++ b/tools/humann/tool-data/metaphlan_database_versioned.loc.sample
@@ -0,0 +1,28 @@
+#This is a sample file distributed with Galaxy that enables tools
+#to use MetaPhlAn reference data.
+#
+#Tab separated with 5 columns (value, name, dbkey, path, db_version):
+# - value: identity of the data. The MetaPhlAn data manager appends the
+# install date to the index name ("-"), which
+# makes workflows that select a locally cached database
+# non-portable; rows added by hand should leave the date away.
+# - name: human readable label, shown in the tool form
+# - dbkey: the MetaPhlAn index name, passed to MetaPhlAn as --index
+# - path: absolute path of the directory containing the index and the
+# marker gene metadata (the --bowtie2db argument)
+# - db_version: "legacy" for databases created by MetaPhlAn 3 (below v4), the
+# marker content ("SGB") otherwise. Tools use it to decide which
+# command line options are required; HUMAnN for example passes
+# --mpa3 only for legacy databases.
+#
+#This table is written by the MetaPhlAn data manager, which installs the SGB
+#databases (vJan21 and later).
+#
+#Migrating from the old (4 column) metaphlan_database table: add a fifth
+#column with "legacy" to every row. Note that HUMAnN 3.9 can only use
+#databases of its own release (index names containing "vJun23") and legacy
+#(pre-v4) ones, so an old row for vJan21/vOct22 stays unusable with HUMAnN.
+#
+#Examples:
+#mpa_vJun23_CHOCOPhlAnSGB_202403 MetaPhlAn clade-specific marker genes (mpa_vJun23_CHOCOPhlAnSGB_202403) mpa_vJun23_CHOCOPhlAnSGB_202403 /path/to/data/mpa_vJun23_CHOCOPhlAnSGB_202403 SGB
+#mpa_v30_CHOCOPhlAn_201901 MetaPhlAn 3 clade-specific marker genes (mpa_v30_CHOCOPhlAn_201901) mpa_v30_CHOCOPhlAn_201901 /path/to/data/mpa_v30_CHOCOPhlAn_201901 legacy
diff --git a/tools/humann/tool_data_table_conf.xml.sample b/tools/humann/tool_data_table_conf.xml.sample
index 39484a5372a..2ed1ee5af3c 100644
--- a/tools/humann/tool_data_table_conf.xml.sample
+++ b/tools/humann/tool_data_table_conf.xml.sample
@@ -1,7 +1,7 @@
-
- value, name, dbkey, path
-
+
+ value, name, dbkey, path, db_version
+
value, name, dbkey, path
diff --git a/tools/humann/tool_data_table_conf.xml.test b/tools/humann/tool_data_table_conf.xml.test
index a4aedc4858f..c876df65c4a 100644
--- a/tools/humann/tool_data_table_conf.xml.test
+++ b/tools/humann/tool_data_table_conf.xml.test
@@ -1,7 +1,7 @@
-
- value, name, dbkey, path
-
+
+ value, name, dbkey, path, db_version
+
value, name, dbkey, path
diff --git a/tools/metaphlan/metaphlan.xml b/tools/metaphlan/metaphlan.xml
index 0e2a0246b1e..62ce55a5ae1 100644
--- a/tools/metaphlan/metaphlan.xml
+++ b/tools/metaphlan/metaphlan.xml
@@ -1377,6 +1377,21 @@ The main output is a tab-separated file with the predicted taxon relative abunda
It also generates a BIOM file and some intermediate files (SAM and mapout) if sequence files are given as inputs.
+Database versions
+=================
+
+The name of a database packs two independent pieces of information, e.g.
+``mpa_vOct22_CHOCOPhlAnSGB_202212``:
+
+- ``vOct22`` is the **marker release tag**. It changes when the SGB marker set changes (vJan21 ->
+ vOct22 -> vJun23 -> vJan25).
+- ``_202212`` is the **build date of that tarball**, not a version. A release is rebuilt when bugs
+ are fixed (``_202212`` -> ``_202403``, which also fixes truncated profile lines), so the same
+ suffix appears under more than one release tag.
+
+The database in use is recorded in the profile header (e.g. ``#mpa_vJun23_CHOCOPhlAnSGB_202403``),
+and that is what downstream tools check: HUMAnN 3.9 accepts only ``v3`` and ``vJun23`` profiles.
+
More help and use cases
=======================