Mwtab file parsing
Skill HolobiomicsLab/asb-skill-collections/collections/metabolomics/v2/skills/mwtab-file-parsing
Use when you have mwTab format files (Mass Spectrometry or Nuclear Magnetic Resonance experimental data from Metabolomics Workbench) that need to be loaded into Python for downstream analysis, validation, conversion to JSON, or programmatic manipulation of metadata and data sections.From its SKILL.md
npx -y skills add HolobiomicsLab/asb-skill-collections --skill mwtab-file-parsingAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 15 stars15 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its file declares
Copied from the file, not written here
The file declares its own license as CC-BY-4.0. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
6.4 KB, ~1.1k tokens by cl100k_base, as published. Nobody here has run it
mwtab-file-parsing
Summary
Parse mwTab-formatted files into structured Python objects to extract metadata and tabular data sections for MS and NMR experiments. This skill enables programmatic access to mass spectrometry and nuclear magnetic resonance experimental data archived in the Metabolomics Workbench using the mwtab library.
When to use
You have mwTab format files (Mass Spectrometry or Nuclear Magnetic Resonance experimental data from Metabolomics Workbench) that need to be loaded into Python for downstream analysis, validation, conversion to JSON, or programmatic manipulation of metadata and data sections.
When NOT to use
- Input is already a JSON representation or equivalent structured object (use JSON direct ingestion instead)
- File is in NetCDF, mzML, or other non-mwTab metabolomics formats (use format-specific parsers)
- Task requires only metadata extraction without touching tabular data (consider lightweight regex parsing)
Inputs
- mwTab-formatted text file (local path or remote ANALYSIS_ID)
- File handle or string path to .txt mwTab file
- ANALYSIS_ID string for remote Metabolomics Workbench fetch
Outputs
- MWTabFile instance (generator-yielded or list collected)
- Dictionary of named data blocks (metadata and tabular sections)
- Structured metadata (STUDY_ID, ANALYSIS_ID, SOURCE, instrument parameters)
- Tabular data sections (accessible via block keys and pandas conversion)
How to apply
Use the mwtab library's MWTabFile parser to load mwTab files, either from local disk or by ANALYSIS_ID from the Metabolomics Workbench remote service. The parser yields MWTabFile instances that provide dictionary-like access to named data blocks (metadata sections and tabular data). Extract study identifiers (STUDY_ID, ANALYSIS_ID), source metadata, and tabular blocks by iterating over the generator or accessing keys on each instance. The parser handles the mwTab text format specification internally, normalizing metadata key–value pairs and structuring tabular sections for downstream access via pandas DataFrames or direct inspection.
Related tools
- mwtab (Core library for reading, writing, and parsing mwTab format files into Python MWTabFile objects) — https://github.com/MoseleyBioinformaticsLab/mwtab
- jsonschema (Validates parsed mwTab data against JSON schema definitions after file parsing, enabling conformance checking)
- pandas (Converts mwTab tabular data sections into DataFrames for analysis and manipulation)
Examples
import mwtab
for mwfile in mwtab.read_files("1", "2"):
print("STUDY_ID:", mwfile.study_id)
print("ANALYSIS_ID:", mwfile.analysis_id)
print("Blocks:", list(mwfile.keys()))
Evaluation signals
- MWTabFile instance is successfully created without parse errors or exceptions
- STUDY_ID and ANALYSIS_ID are non-null and match expected identifiers from input file or remote source
- Named blocks (keys) from mwTab file are accessible via dict-like interface on MWTabFile instance
- Metadata key–value pairs are correctly normalized and present in extracted metadata dictionary
- Tabular data sections (e.g., Sample data, Raw data) can be retrieved and have expected column counts
Limitations
- Parser assumes valid mwTab format syntax; malformed files will raise exceptions and require manual repair
- Remote fetch via ANALYSIS_ID requires network access to Metabolomics Workbench API and valid credentials if applicable
- Large mwTab files with many samples or high-dimensional raw data may consume significant memory when fully loaded into memory
Evidence
- [readme] The
mwtabpackage is a Python library that facilitates reading and writing files inmwTabformat used by theMetabolomics Workbench_ for archival of Mass Spectrometry (MS) and Nuclear Magnetic Resonance (NMR) experimental data.: "Themwtabpackage is a Python library that facilitates reading and writing files inmwTabformat used by theMetabolomics Workbench_ for archival of Mass Spectrometry (MS) and Nuclear" - [other] Create the :class:
~mwtab.mwtab.MWTabFilegenerator function that will generate (yield) a single :class:~mwtab.mwtab.MWTabFileinstance at a time.: "Create the :class:~mwtab.mwtab.MWTabFilegenerator function that will generate (yield) a single :class:~mwtab.mwtab.MWTabFileinstance at a time." - [other] Process each :class:
~mwtab.mwtab.MWTabFileinstance: ProcessmwTabfiles in a for-loop, one file at a time.: "Process each :class:~mwtab.mwtab.MWTabFileinstance: ProcessmwTabfiles in a for-loop, one file at a time." - [readme] As a library for accessing and manipulating data stored in
mwTabformat files.: "As a library for accessing and manipulating data stored inmwTabformat files." - [readme] Here we use ANALYSIS_ID of file to fetch data from URL: "Here we use ANALYSIS_ID of file to fetch data from URL"
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.