Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions data_managers/data_manager_humann_database_downloader/.shed.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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)))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<description>Download HUMAnN database</description>
<macros>
<token name="@TOOL_VERSION@">3.9</token>
<token name="@VERSION_SUFFIX@">0</token>
<token name="@VERSION_SUFFIX@">2</token>
<token name="@PROFILE@">22.01</token>
</macros>
<requirements>
Expand Down Expand Up @@ -58,7 +58,7 @@ python '$__tool_directory__/data_manager_humann_download.py'
<has_text text="humann_nucleotide_database"/>
<has_text text="Demo ChocoPhlAn for HUManN"/>
<has_text text="chocophlan/DEMO"/>
<has_text text="chocophlan-DEMO-"/>
<has_text text="chocophlan-DEMO-DEMO_chocophlan.v201901_v31"/>
</assert_contents>
</output>
</test>
Expand All @@ -69,10 +69,9 @@ python '$__tool_directory__/data_manager_humann_download.py'
</conditional>
<output name="out_file">
<assert_contents>
<has_text text="DEMO_diamond"/>
<has_text text="Demo UniRef for HUManN"/>
<has_text text="uniref/DEMO_diamond"/>
<has_text text="uniref-DEMO_diamond-"/>
<has_text text="uniref-DEMO_diamond-uniref90_DEMO_diamond_v201901b"/>
</assert_contents>
</output>
</test>
Expand All @@ -83,7 +82,6 @@ python '$__tool_directory__/data_manager_humann_download.py'
</conditional>
<output name="out_file">
<assert_contents>
<has_text text="utility_mapping"/>
<has_text text="Mapping (full)"/>
<has_text text="utility_mapping/full"/>
<has_text text="map_uniref50_uniref90"/>
Expand All @@ -106,17 +104,110 @@ python '$__tool_directory__/data_manager_humann_download.py'
<has_text text="map_uniref50_name"/>
<has_text text="map_ec_name"/>
<has_text text="map_pfam_name"/>
<has_text text="full_mapping_v201901b"/>
<has_text text=".gz"/>
<has_text text=".bz2"/>
</assert_contents>
</output>
</test>
</tests>
<help>
This tool downloads the HUMAnN databases.
<help><![CDATA[
**What this tool installs**

The three HUMAnN reference data tables that the HUMAnN tools select from:

| Table | Data | Used for |
| --- | --- | --- |
| ``humann_nucleotide_database`` | ChocoPhlAn pangenome catalog | nucleotide (bowtie2) search, and the catalog the per-sample pangenome is built from |
| ``humann_protein_database`` | UniRef protein clusters | translated (DIAMOND) search |
| ``humann_utility_mapping`` | feature to group / to name mappings | ``humann_regroup_table``, ``humann_rename_table`` |

**Data versions live in the artifact names, not in the HUMAnN version**

HUMAnN names each bundle after the data it contains. Query them with
``humann_databases --available``:

- ``full_chocophlan.v201901_v31`` (chocophlan, full)
http://huttenhower.sph.harvard.edu/humann_data/chocophlan/full_chocophlan.v201901_v31.tar.gz
- ``DEMO_chocophlan.v201901_v31`` (chocophlan, DEMO)
http://huttenhower.sph.harvard.edu/humann_data/chocophlan/DEMO_chocophlan.v201901_v31.tar.gz
- ``uniref90_annotated_v201901b_full`` (uniref, uniref90_diamond)
http://huttenhower.sph.harvard.edu/humann_data/uniprot/uniref_annotated/uniref90_annotated_v201901b_full.tar.gz
- ``full_mapping_v201901b`` (utility_mapping, full)
http://huttenhower.sph.harvard.edu/humann_data/full_mapping_v201901b.tar.gz

**These are the same for every HUMAnN from 3.1.1 to 3.9** — the ChocoPhlAn
``v201901_v31`` catalog and the UniRef/mapping ``201901b`` bundle. Upgrading
HUMAnN between those releases does not require downloading anything again, and
HUMAnN validates this: it refuses to run if the data directory contains a file
that does not carry the expected version string.

The one exception is **HUMAnN 3.0.x**, which shipped ``chocophlan.v296_201901b``.
That cohort is only usable with HUMAnN 3.0.x; every later release aborts with
``CRITICAL ERROR: The directory provided for ChocoPhlAn contains files ... that
are not of the expected version``. The HUMAnN wrappers therefore only offer
nucleotide databases whose entries mention ``v201901_v31``.

A future HUMAnN 4 uses a new generation (``chocophlan.v4_alpha``,
``uniref90_annotated_v4_alpha_ec_filtered``, ``full_mapping_v4_alpha``) with
fewer variants (no UniRef50, no DEMO); those bundles are not offered to the
current wrappers.

The **MetaPhlAn marker database** used for the prescreen step is separate data
(the ``metaphlan_database_versioned`` table, installed by the MetaPhlAn data
manager) and is versioned independently. HUMAnN accepts:

| HUMAnN | Accepted marker database |
| --- | --- |
| 3.1.1 | ``mpa_v30_CHOCOPhlAn_201901`` |
| 3.5 - 3.6.1 | ``mpa_v30_CHOCOPhlAn_201901``, ``mpa_vJan21_CHOCOPhlAnSGB_202103`` |
| 3.7 - 3.8 | ``mpa_v30_CHOCOPhlAn_201901``, ``mpa_vOct22_CHOCOPhlAnSGB_202212`` |
| 3.9 | ``mpa_v30_CHOCOPhlAn_201901``, ``mpa_vJun23_CHOCOPhlAnSGB_202307``, ``mpa_vJun23_CHOCOPhlAnSGB_202403`` |

Rows holding a pre-v3 (``legacy``) database must be marked as such in the
``db_version`` column of ``metaphlan_database_versioned``, so that HUMAnN is
called with ``--mpa3``. These databases are installed by the MetaPhlAn data
manager, whose help describes their naming scheme, sizes and consumers.

Mind that the *MetaPhlAn* version matters as well: HUMAnN 3.9 needs MetaPhlAn
4.1.1 or older, because 4.2 renamed the command line options of the prescreen
step and 4.1.2 changed the format of ``metaphlan --version``, which HUMAnN
parses. The marker database itself is independent of that (it is plain data).

**Columns**

``value``
Stable identity of the data, ``<database>-<build>-<artifact name>`` (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 <database> <build>
<target dir> --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 .
</help>
]]></help>
<citations>
<citation type="doi">10.1371/journal.pcbi.1003153</citation>
</citations>
Expand Down
Original file line number Diff line number Diff line change
@@ -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
#to use a directory of metagenomics files.
#Tab separated with 4 columns (value, name, dbkey, path):
# - value: stable identity of the data, "<database>-<build>-<artifact name>"
# (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.
Original file line number Diff line number Diff line change
@@ -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
#to use a directory of metagenomics files.
#Tab separated with 4 columns (value, name, dbkey, path):
# - value: stable identity of the data, "<database>-<build>-<artifact name>"
# (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.
Original file line number Diff line number Diff line change
@@ -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
#to use a directory of metagenomics files.
#Tab separated with 4 columns (value, name, dbkey, path):
# - value: stable identity of the data, "<database>-<build>-<artifact name>"
# (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.
Original file line number Diff line number Diff line change
@@ -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
#to use a directory of metagenomics files.
#Tab separated with 4 columns (value, name, dbkey, path):
# - value: stable identity of the data, "<database>-<build>-<artifact name>"
# (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
Original file line number Diff line number Diff line change
@@ -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
#to use a directory of metagenomics files.
#Tab separated with 4 columns (value, name, dbkey, path):
# - value: stable identity of the data, "<database>-<build>-<artifact name>"
# (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
Loading
Loading