How bayer-group/mocca works
Project type and purpose
• MOCCA2 is an open-source Python library and CLI tool for automatic processing of HPLC chromatograms.
• Purpose: ingest raw chromatogram data (Agilent, Shimadzu, Waters), apply baseline correction, peak picking, deconvolution, clustering, and output results (plots, data objects).
File structure
• src/mocca2/… – core Python packages broken into subpackages:
• parsers – raw data file readers
• baseline – baseline-correction algorithms
• peaks – peak-finding and splitting
• deconvolution – deconvolution routines & models
• clustering – component clustering across runs
• classes – data models (Chromatogram, Peak, Component, etc.)
• dataset – dataset loader and settings
• example_data – data downloader+loaders
• serializing – saving/loading processed results
• __main__.py – CLI entrypoint (python -m mocca2)
• tests/ – unit tests for each component
• examples/ – sample scripts exercising the API
• docs/ – Sphinx documentation sources
• GitHub workflows – CI, docs deployment, packaging, PyPI publishing
README for additional insights
• Describes workflows:
• local API usage & example workflows
• automated testing on push
• docs build & GitHub Pages publication
• example data branch and download command
• PyPI publishing
Main components and interactions
a. Core Components
1. CLI / API Layer (src/mocca2/__main__.py)
2. Parsers (raw file → Chromatogram object)
3. Baseline Correction (Chromatogram → corrected Chromatogram)
4. Peak Picking (Chromatogram → Chromatogram+Peak list)
5. Deconvolution (Chromatogram + Peak list → DeconvolvedPeak list)
6. Clustering (multiple Chromatograms → tracked Components)
7. Serialization (persist processed data to disk)
8. Example Data Loader (download & unpack from example-data branch)
9. Data Models (Chromatogram, Peak, Component, Dataset)
b. External Dependencies & Services
• Python scientific stack (numpy, scipy, matplotlib, pandas)
• PyPI (package distribution)
• GitHub Actions (CI, docs, packaging)
• GitHub Pages (documentation hosting)
c. Data Flows & Relationships
• Raw files → Parsers → Chromatogram objects
• Chromatogram → Baseline → Filtered Chromatogram
• Filtered Chromatogram → Peak Picking → Chromatogram+Peaks
• Chromatogram+Peaks → Deconvolution → Chromatogram+DeconvolvedPeaks
• Multiple Chromatograms → Clustering → Component tracking
• Processed objects → Serialization → Re-loadable files
• CLI or Python API orchestrates above steps
Architectural patterns and design principles
• Modular subpackages following single responsibility principle
• Data model objects (Chromatogram, Peak) encapsulate state + behavior
• Pipeline design: each processing step returns enriched object
• Extensibility: wrapper modules for new parsers, baseline methods, deconvolution models
• CLI entrypoint vs. library API separation