Metadata-Version: 2.4
Name: polyform-lattice
Version: 0.1.1
Summary: Structured analysis of proteoform distributions on finite, bounded, k-graded modal lattices.
Project-URL: Homepage, https://github.com/JamesCobley/PolyForm
Project-URL: Repository, https://github.com/JamesCobley/PolyForm
Project-URL: Issues, https://github.com/JamesCobley/PolyForm/issues
Author: James N. Cobley
License: MIT License
        
        Copyright (c) 2026 James N. Cobley
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: PTM,hamming,mass-spectrometry,modal-lattice,occupancy,proteoform,proteomics,top-down,topology
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Requires-Python: >=3.9
Requires-Dist: matplotlib>=3.6
Requires-Dist: numpy>=1.23
Requires-Dist: openpyxl>=3.0
Requires-Dist: pandas>=1.5
Provides-Extra: dev
Requires-Dist: build; extra == 'dev'
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: twine; extra == 'dev'
Description-Content-Type: text/markdown

# PolyForm

PolyForm is a Python package for structured analysis of proteoform
distributions. It maps measured proteoform catalogues onto finite, bounded,
*k*-graded modal lattices and computes structure-derived metrics including
state identity, occupancy, grade spread, support topology, native clustering,
principal occupied components, and statistical surprise.

## Install

```bash
pip install polyform-lattice
```

> The **import** name is `polyform`; the **PyPI distribution** name is
> `polyform-lattice` (the plain name `polyform` was already taken by an
> unrelated project). So you `pip install polyform-lattice` but `import polyform`.

From source (for development):

```bash
git clone https://github.com/JamesCobley/PolyForm.git
cd PolyForm
pip install -e .
```

## Usage

### Python API

Each analysis is a single call that returns a dict of pandas DataFrames and,
by default, writes CSVs and figures to an output directory.

```python
import polyform

# Global support-mode structural metrics on the choice-free modal lattice
support = polyform.run_support_mode(csv="proteoforms.csv", outdir="out_support")
support["global"]           # one-row global summary
support["protein_metrics"]  # protein-level structural metrics
support["grade"]            # protein-by-grade metrics

# Demonstration occupancy metrics on real observed supports
weight = polyform.run_weight_mode(csv="proteoforms.csv", outdir="out_weight")
weight["selected"]          # proteins selected for demonstration
weight["metrics"]           # occupancy-dependent metrics

# Tissue-resolved Hamming-1 support topology on a top-down atlas
topology = polyform.run_topology(xlsx="atlas.xlsx", outdir="out_topology")
topology["tissue_summary"]
topology["components"]
```

Set `make_figures=False` to skip figure rendering (faster; CSVs still written).

### Command line

```bash
polyform support   --csv proteoforms.csv --outdir out_support
polyform weight    --csv proteoforms.csv --outdir out_weight
polyform topology  --xlsx atlas.xlsx     --outdir out_topology

polyform support --help      # per-command options
polyform --version
```

### Core primitives

The lattice/topology/information primitives are importable directly:

```python
from polyform.core import (
    parse_ptms, read_fasta, log10_comb, hamming_distance_state,
    connected_components_for_states, shannon_entropy, normalized_entropy,
)
```

## Inputs

- **Support / weight modes** expect a proteoform catalogue CSV with at least
  `Entry Accession` and `PTMs` columns; protein lengths are resolved from an
  `Isoform Sequence` column or an optional `--fasta`. PTM strings use the
  `RESID:<code>@<position>` form, `|`-separated.
- **Topology mode** expects the multi-tissue top-down atlas spreadsheet
  (`--sheet`, default `All_Tissues`).

## Outputs

Each mode writes a set of `.csv` tables plus publication `.png`/`.pdf` figures
into its `--outdir`. See each function's docstring for the exact file list.

## Reproducibility

The original manuscript analysis scripts are preserved unchanged under
[`manuscript/`](manuscript/) as the provenance record. The packaged `run_*`
functions wrap those exact computational bodies (only parameterising
configuration and routing outputs) and were validated to reproduce the
manuscript reference outputs.

## Releasing (maintainers)

Releases publish to PyPI via **Trusted Publishing** (OIDC — no API tokens).
One-time setup: on PyPI, add a trusted publisher for the project pointing at
this repo's `publish.yml` workflow and a `pypi` environment.

To cut a release:

```bash
# bump version in pyproject.toml and src/polyform/__init__.py, update CHANGELOG.md
git commit -am "Release v0.1.0"
git tag v0.1.0
git push origin main --tags
```

Pushing the tag triggers `.github/workflows/publish.yml`, which builds the
sdist + wheel, runs `twine check`, and publishes to PyPI.

## License

MIT © 2026 James N. Cobley
