Metadata for User facility Template Transformations (MUTTs)
Table of Contents
- Metadata for User facility Template Transformations (MUTTs)
Introduction
The programs bundled in this repository automatically retrieve Biosample metadata records for studies submitted to NMDC through the NMDC Submission Portal, and convert the metadata into Excel spreadsheets that are accepted by DOE user facilities.
MUTTs User Documentation
The documentation and setup instructions in this section are meant for any user who would like to install the MUTTs Python package and use it's transformation capabilities to convert data from the NMDC Submission Portal into an Excel spreadsheet that follows a template, based on the MUTTs JSON mapper file that is used.
Prerequisites
- Python 3.12 or higher
- An NMDC user account with an API access token
To create an NMDC user account you will need to sign up at the above link by clicking on the 'ORCID LOGIN' button/link at the top right corner of the NMDC site, and signing in appropriately with your ORCID credentials
Setting up your API access token
This is required for running the examples in the Usage section below (after going through all the Installation steps).
Create a .env file in your working directory with the following environment variables:
echo "DATA_PORTAL_REFRESH_TOKEN=your_token_here" > .env
echo "SUBMISSION_PORTAL_BASE_URL=https://data.microbiomedata.org" >> .env
To get your access token:
- Visit https://data.microbiomedata.org/user
- Copy your Refresh Token
- Replace
your_token_herein the.envfile with your token
Installation
- Create a virtual environment (recommended)
python -m venv mutts-env
source mutts-env/bin/activate # On Windows: mutts-env\Scripts\activate
- Install the MUTTs package from PyPI
pip install mutts
- Download any of the MUTTs JSON mapper configuration files
Note: It is not mandatory that you need to download/use any of the pre-existing/already defined JSON mapper files that are present in this repository. You can always define your own custom JSON mapper files that follow a format similar to the ones defined in this repo.
Create a directory for your mapper files and download them from this repository:
mkdir input-files
cd input-files
Download the mapper files you need from the input-files directory:
- For EMSL:
emsl_header.json - For JGI Metagenome:
jgi_mg_header.json,jgi_mg_header_v15.jsonorjgi_mg_header_v16.json - For JGI Metatranscriptome:
jgi_mt_header.json,jgi_mt_header_v15.jsonorjgi_mt_header_v16.json - For JGI Isolate:
jgi_isolate_header_v19.json
Updating to the Latest Version
To ensure you have the latest features and bug fixes, you can upgrade the MUTTs package from PyPI:
pip install --upgrade mutts
To check your currently installed version:
pip show mutts
You can also install a specific version if needed:
pip install mutts==<version>
Usage
Run the mutts command with the required options:
mutts --help
Note: In the below examples there is a --sample-set argument that requires you to pass it an NMDC Sample Set UUID as value. Each NMDC Submission has one or more Sample Sets associated with it. You can find the Sample Set UUIDs for your Submission by visiting the NMDC Submission Portal and navigating to the Sample Metadata page for a Sample Set within a Submission. The URL will contain the Sample Set UUID.
An example would look like below:
https://data.microbiomedata.org/submission/<submission-uuid>/sample_set/<sample-set-uuid>/samples
Example 1: Generate a JGI Metagenome spreadsheet
mutts --sample-set <sample-set-uuid> \
--user-facility jgi_mg \
--mapper input-files/jgi_mg_header.json \
--output my-samples_jgi.xlsx
Example 2: Generate a JGI Metagenome v15 spreadsheet
mutts --sample-set <sample-set-uuid> \
--user-facility jgi_mg \
--mapper input-files/jgi_mg_header_v15.json \
--output my-samples_jgi_v15.xlsx
Example 3: Generate an EMSL spreadsheet
mutts --sample-set <sample-set-uuid> \
--user-facility emsl \
--mapper input-files/emsl_header.json \
--header \
--output my-samples_emsl.xlsx
Example 4: Generate a JGI Isolate v19 spreadsheet
mutts --sample-set <sample-set-uuid> \
--user-facility jgi_isolate \
--mapper input-files/jgi_isolate_header_v19.json \
--output my-samples_jgi_isolate_v19.xlsx
If your submission has both isolate genome (DNA) and isolate transcriptome (RNA) samples, this single command puts them all on one spreadsheet, one row per sample. The organism details you entered once — genus, species, strain, NCBI taxonomy ID — appear on every row for that organism.
Some columns only apply to one kind of sample and are left blank on the others. The ribosomal sequence and fungal screening questions, for example, are asked of genome samples. And on transcriptome rows the collection date columns hold the date of the lab experiment rather than the date the organism was collected, which is what JGI asks for on RNA samples.
Command Options
-s, --sample-set: Your NMDC sample set UUID (required)-u, --user-facility: Target facility (required):emsl,jgi_mg,jgi_mg_lr,jgi_mt, orjgi_isolate-m, --mapper: Path to the JSON mapper file (required)-o, --output: Output Excel file path (required)-h, --header: Include headers in output (use for EMSL, omit for JGI)
MUTTs Developer Documentation
The documentation and setup instructions in this section are largely meant for any developer/programmer whose primary use case is to extend/improve/build upon the current capabilities of the MUTTs software.
The software consists of two main components:
- JSON Mapper Configuration Files
- Controls/specifies the mapping between columns from the NMDC Submission Portal and column names used in the output spreadsheets
- Top-level keys indicate main headers in the output
- Numbered keys add clarifying header information
- The
headerkeyword allows custom column names - The
sub_port_mappingkeyword specifies mappings between Submission Portal columns/slots (as dictated by the NMDC submission schema) and user facility template columns - Examples available in input-files/
muttsCLI
- Command-line application that performs the metadata conversion
- Consumes mapper files and submission sample set data as inputs
Software Requirements
Development Installation
- Clone this repository
git clone https://github.com/microbiomedata/metadata-for-user-facility-template-transformations.git
cd metadata-for-user-facility-template-transformations
- Install dependencies
uv sync
This creates or synchronizes the project's virtual environment, installs mutts in development mode, includes the development dependencies, and creates the mutts command-line tool.
- Set up your
.envfile
cp .env.example .env # if available, or create a new .env file
Add your NMDC API token and submission portal base URL:
DATA_PORTAL_REFRESH_TOKEN=your_token_here
SUBMISSION_PORTAL_BASE_URL=https://data.microbiomedata.org
Get your token from: https://data.microbiomedata.org/user
- Run the CLI in development mode
uv run mutts --help
Running Tests
Unit Tests
The unit tests are isolated from NMDC services, so they do not require an API token, a .env file, or network access. This is also the test suite run for pull requests.
Run the complete unit test suite:
uv run pytest
Run a single test file:
uv run pytest tests/test_dataframe.py
Run a single test function:
uv run pytest tests/test_dataframe.py::test_merges_environmental_records_by_sample_name
Integration Test
The integration test makes authenticated, read-only requests to the configured nmdc-server instance. It refreshes an access token, reads one stable sample set, and verifies that MUTTs can produce a DataFrame containing an expected sample.
In addition to the URL and token environment variables described above, the integration test requires three additional environment variables. Add these to your .env file to run the integration test locally:
INTEGRATION_TEST_SAMPLE_SET_ID=<test-sample-set-id>
INTEGRATION_TEST_USER_FACILITY=<test-user-facility>
INTEGRATION_TEST_EXPECTED_SAMPLE_NAME=<test-sample-name>
Then run the integration test with:
uv run pytest -m integration
Pytest excludes integration tests by default. Selecting the integration marker explicitly overrides that default.
The Dev nmdc-server integration tests GitHub Actions workflow runs nightly and can also be started manually. It is configured through repository secrets and variables to talk to the deployed dev nmdc-server instance. The workflow tests both the default-branch (main) source and the latest published MUTTs package:
| Published MUTTs | Default-branch MUTTs | Meaning |
|---|---|---|
| Pass | Pass | Dev nmdc-server remains compatible with current and future MUTTs. |
| Fail | Pass | A compatible MUTTs change exists but has not been published. |
| Fail | Fail | The nmdc-server contract, deployment, authentication, fixture, or shared client path may be broken. |
| Pass | Fail | Published users remain safe; MUTTs development has regressed. |
Failures create or update one GitHub issue. A successful recovery comments on and closes that issue.
Creating Custom Mapper Files
To create a custom mapper for a new user facility, refer to the existing examples:
- emsl_header.json - EMSL configuration
- jgi_mg_header.json - JGI Metagenome configuration
- jgi_mt_header.json - JGI Metatranscriptome configuration
- jgi_mg_header_v15.json - JGI Metagenome v15 configuration
- jgi_mt_header_v15.json - JGI Metatranscriptome v15 configuration
- jgi_mg_header_v16.json - JGI Metagenome v16 configuration
- jgi_mt_header_v16.json - JGI Metatranscriptome v16 configuration
- jgi_isolate_header_v19.json - JGI Isolate v19 configuration
A handful of sub_port_mapping values do not name a submission schema slot directly, but a column derived in src/mutts/dataframe.py — for example collection_year, collection_month_name and country_name. The JGI Isolate mapper adds three more: ncbi_tax_id (from classified_as, with the NCBITaxon: prefix removed), culture_collection_id (from source_mat_id, rendered as the collection name and ID rather than a CURIE) and isolate_meth (from dna_isolate_meth or rna_isolate_meth, whichever the row has). A mapping that names neither a slot nor a derived column is silently skipped, leaving that column blank.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mutts-2.1.0.tar.gz.
File metadata
- Download URL: mutts-2.1.0.tar.gz
- Upload date:
- Size: 501.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec7af8b218946f72663ea021ee5929ae3d2a7c8d481c2f35487407c1c1b5e0ae
|
|
| MD5 |
f7fb26a4c56125fbcb5ce7dd1cff4b4f
|
|
| BLAKE2b-256 |
43a31092d9d41d774f96d6e84fd075611d5540a02287d96ffcecc65ea13bd5ef
|
Provenance
The following attestation bundles were made for mutts-2.1.0.tar.gz:
Publisher:
pypi-publish.yaml on microbiomedata/metadata-for-user-facility-template-transformations
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mutts-2.1.0.tar.gz -
Subject digest:
ec7af8b218946f72663ea021ee5929ae3d2a7c8d481c2f35487407c1c1b5e0ae - Sigstore transparency entry: 2454825371
- Sigstore integration time:
-
Permalink:
microbiomedata/metadata-for-user-facility-template-transformations@89aa2ff6f87b34603db168ca57f8643565b5225b -
Branch / Tag:
refs/tags/v2.1.0 - Owner: https://github.com/microbiomedata
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yaml@89aa2ff6f87b34603db168ca57f8643565b5225b -
Trigger Event:
release
-
Statement type:
File details
Details for the file mutts-2.1.0-py3-none-any.whl.
File metadata
- Download URL: mutts-2.1.0-py3-none-any.whl
- Upload date:
- Size: 79.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c77876648e6dec0f88b0d756ef09826ecba48974341c931cd0ef2d33f09144e3
|
|
| MD5 |
f767ae5b00789b260738692de638f220
|
|
| BLAKE2b-256 |
2e36e4b73440485019b5211464297cdbbff5308af7b21776228fbc1e649246ad
|
Provenance
The following attestation bundles were made for mutts-2.1.0-py3-none-any.whl:
Publisher:
pypi-publish.yaml on microbiomedata/metadata-for-user-facility-template-transformations
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mutts-2.1.0-py3-none-any.whl -
Subject digest:
c77876648e6dec0f88b0d756ef09826ecba48974341c931cd0ef2d33f09144e3 - Sigstore transparency entry: 2454825632
- Sigstore integration time:
-
Permalink:
microbiomedata/metadata-for-user-facility-template-transformations@89aa2ff6f87b34603db168ca57f8643565b5225b -
Branch / Tag:
refs/tags/v2.1.0 - Owner: https://github.com/microbiomedata
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yaml@89aa2ff6f87b34603db168ca57f8643565b5225b -
Trigger Event:
release
-
Statement type: