Skip to main content

Metabolomics Workbench - Metabolomics Hub Integration

Project description

Metabolomics Workbench - MHD Model Integration Framework

Development Environment

Development environment for linux or mac

# install python package manager uv
curl -LsSf https://astral.sh/uv/install.sh | sh

# add $HOME/.local/bin to your PATH, either restart your shell or run
export PATH=$HOME/.local/bin:$PATH

# install git from https://git-scm.com/downloads
# Linux command
apt update; apt install git -y

# Mac command
# brew install git

# clone project from github
git clone https://github.com/MetabolomicsHub/mw-mhd-integration.git

cd mw-mhd-integration

# install python if it is not installed
uv python install 3.12

# install python dependencies
uv sync

# install pre-commit to check repository integrity and format checking
uv run pre-commit

# open your IDE (vscode, pycharm, etc.) and set python interpreter as .venv/bin/python

Commandline Usage

# you can use any python version >= 3.12
pip install mw-mhd-integration

mw-mhd-cli
####################################################################
# Usage: mw-mhd-cli [OPTIONS] COMMAND [ARGS]...

#   Metabomics Workbench - MHD Integration CLI with subcommands.

# Options:
#   --version   Show the version and exit.
#   -h, --help  Show this message and exit.

# Commands:
#   announcement  Create announcement file from MHD data model file.
#   download      Download a Metabolomics Workbench study as json file.
#   mhd           Convert a Metabolomics Workbench study to MHD file format.
#   validate      Validate MHD model and annoucenment file.
####################################################################

mw-mhd-cli download

####################################################################
# Usage: mw-mhd-cli download [OPTIONS] STUDY_ID

#   Download a Metabolomics Workbench study as json file.

# Options:
#   --output-dir TEXT       Output directory for MHD file  [default: outputs]
#   --output-filename TEXT  MHD filename (e.g., MHD000001_mhd.json,
#                           ST000001_mhd.json)
#   -h, --help              Show this message and exit.
####################################################################

mw-mhd-cli download ST004083
# ST004083 is downloaded

ls outputs
# ST004083.json

mw-mhd-cli create mhd
####################################################################
# Usage: mw-mhd-cli create mhd [OPTIONS] MW_STUDY_ID MHD_IDENTIFIER

#   Convert a Metabolomics Workbench study to MHD file format.

#   Args:

#       mw_study_id (str): MW study accession id. e.g, ST0000001.

#       mhd_identifier (str): MHD accession number.      Use same value of
#       mw_study_id if study profile is legacy. e.g., ST0000001.

# Options:
#   --output-dir TEXT       Output directory for MHD file  [default: outputs]
#   --output-filename TEXT  MHD filename (e.g., MHD000001_mhd.json,
#                           ST000001_mhd.json)
#   --schema_uri TEXT       Target MHD model schema. It defines format of MHD
#                           model structure.  [default:
#                           https://metabolomicshub.github.io/mhd-
#                           model/schemas/v0_1/common-data-
#                           model-v0.1.schema.json]
#   --profile_uri TEXT      Target MHD model profile. It is used to validate MHD
#                           model  [default:
#                           https://metabolomicshub.github.io/mhd-
#                           model/schemas/v0_1/common-data-model-v0.1.legacy-
#                           profile.json]
#   -h, --help              Show this message and exit.
####################################################################

mw-mhd-cli create mhd ST004083 ST004083
ls outputs
# ST004083.json  ST004083.mhd.json

mw-mhd-cli validate
####################################################################
# Usage: mw-mhd-cli validate [OPTIONS] COMMAND [ARGS]...

#   Validate MHD model and annoucenment file.

# Options:
#   -h, --help  Show this message and exit.

# Commands:
#   announcement  Validate MHD announcement file.
#   mhd           Validate MHD model file.
####################################################################

mw-mhd-cli validate mhd ST004083 outputs/ST004083.mhd.json
####################################################################
# ST004083: outputs/ST004083.mhd.json MHD file validation started.
# Used schema: https://metabolomicshub.github.io/mhd-model/schemas/v0_1/common-data-model-v0.1.schema.json
# Validation profile: https://metabolomicshub.github.io/mhd-model/schemas/v0_1/common-data-model-v0.1.legacy-profile.json
# ST004083: File 'outputs/ST004083.mhd.json' is validated successfully.
####################################################################
mw-mhd-cli create announcement

####################################################################
# Usage: mw-mhd-cli create announcement [OPTIONS] MHD_STUDY_ID MHD_MODEL_FILE_PATH
#                                TARGET_MHD_MODEL_FILE_URL

#   Create announcement file from MHD data model file.

#   Args:

#   mhd_study_id (str): MHD study identifier

#   mhd_model_file_path (str): MHD data model path

#   target_mhd_model_file_url (str): target URL of MHD data model

#   output_dir (str): Output directory of announcement file

#   output_filename (str): Name of MHD announcement file. Default is <repository
#   identifier>.announcement.json

# Options:
#   --output-dir TEXT       Output directory for MHD file  [default: outputs]
#   --output-filename TEXT  MHD announcement filename (e.g.,
#                           MHD000001.announcement.json,
#                           ST000001.announcement.json)
#   -h, --help              Show this message and exit.
####################################################################


# MHD identifier will be reserved for each private study
# The following command assumes that MHD999999 is reserved for ST004083
mw-mhd-cli create announcement MHD999999  outputs/ST004083.mhd.json "https://www.metabolomicsworkbench.org/data/study_textformat_list.php?MHD_ID=MHD999999"

####################################################################
# MHD999999 announcement file conversion completed.
# MHD identifier will be reserved for each private study
####################################################################

ls outputs
####################################################################
# MHD999999.announcement.json  ST004083.json  ST004083.mhd.json
####################################################################

mw-mhd-cli validate announcement

####################################################################
# Usage: mw-mhd-cli validate announcement [OPTIONS] MHD_STUDY_ID
#                                         ANNOUNCEMENT_FILE_PATH

#   Validate MHD announcement file.

#   Args:

#   mhd_study_id (str): MHD study id

#   announcement_file_path (str): MHD announcement file path

#   output_path (None | str): If it is defined, validation results are saved in
#   output file path.

# Options:
#   --output-path TEXT  Validation output file path
#   -h, --help          Show this message and exit.
####################################################################

mw-mhd-cli validate announcement MHD999999 outputs/MHD999999.announcement.json

####################################################################
# MHD999999: File 'outputs/MHD999999.announcement.json' is validated successfully.
####################################################################

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mw_mhd_integration-0.0.19.tar.gz (23.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mw_mhd_integration-0.0.19-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

Details for the file mw_mhd_integration-0.0.19.tar.gz.

File metadata

  • Download URL: mw_mhd_integration-0.0.19.tar.gz
  • Upload date:
  • Size: 23.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for mw_mhd_integration-0.0.19.tar.gz
Algorithm Hash digest
SHA256 fc599627ca9a74179dc3c79fd570e217ba884e4c15c7814b82a985d8f8689f5a
MD5 5fa6bab67ed14ecff79e03661b92fe1e
BLAKE2b-256 bb43aa31975f67934b11f9b69a2d44dbacc81b84a65a8959dd4fefa56ffc731a

See more details on using hashes here.

File details

Details for the file mw_mhd_integration-0.0.19-py3-none-any.whl.

File metadata

  • Download URL: mw_mhd_integration-0.0.19-py3-none-any.whl
  • Upload date:
  • Size: 25.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for mw_mhd_integration-0.0.19-py3-none-any.whl
Algorithm Hash digest
SHA256 a3ca0b8f907a2cb9b09fd5bd6edb4d3bee59fddb700d44e2dd8f362ba67a028d
MD5 8013420231b490af4424be0ca2b9fe7c
BLAKE2b-256 1cc43a30889628d61ffca7febb3bfd5825f41b0e67d6a0f68a4d0d68c4dff34d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page