Skip to main content

FCCgroup

PyPI Python License: CC BY-SA 4.0 Issues

FCCgroup is a Python package for grouping chemicals with three complementary methods:

  • Structural pattern matching with SMARTS fingerprints
  • Functional list matching against packaged reference lists
  • Regex-based grouping from chemical names and formulas

The package is developed under the organization of Food Packaging Forum. Authored by Albert Anguera Sempere and Helene Wiesinger.

Features

  • Structural classification using SMARTS fingerprints
  • Functional list matching from packaged assets
  • Regex-based classification from names and formulas
  • Automatic CompTox enrichment when selected methods require missing fields
  • Flexible method selection through GroupingConfig(methods=...)
  • Optional SMARTS fingerprint subsetting via GroupingConfig(smarts_fingerprints=...)
  • Package data bundled under fccgroup/assets

Installation

Install from PyPI:

pip install fccgroup

Install from source:

git clone https://github.com/Food-Packaging-Forum/fccgroup.git
cd fccgroup
pip install -e .

Install development dependencies:

pip install -e .[dev]

Quick Start

import pandas as pd

from fccgroup import ChemicalGrouper, ColumnMapping, GroupingConfig, GroupingMethod

df = pd.DataFrame(
  {
    "CASRN": ["74-84-0"],
    "Structure": ["CC"],
    "Name": ["ethane"],
    "IUPAC": ["ethane"],
    "Formula": ["C2H6"],
  }
)

config = GroupingConfig(
  methods=[GroupingMethod.SMARTS, GroupingMethod.REGEX],
  column_mapping=ColumnMapping(
    cas="CASRN",
    smiles="Structure",
    name_columns=["Name", "IUPAC"],
    formula="Formula",
  ),
)

grouper = ChemicalGrouper(df=df, grouping_config=config)
results = grouper.group_chemicals(save=False)

# Columns are a MultiIndex: (group_label, column_name)
print(results.columns.tolist())
print(results.head())

Selecting Grouping Methods

FCCgroup does not expose a GroupingMode enum. Method selection is configured with GroupingMethod values:

  • GroupingMethod.SMARTS: structural pattern matching
  • GroupingMethod.LISTS: functional list matching
  • GroupingMethod.REGEX: regex-based grouping from names and formulas

Common configurations:

GroupingConfig(methods=[GroupingMethod.SMARTS], column_mapping=...)
GroupingConfig(methods=[GroupingMethod.SMARTS, GroupingMethod.LISTS], column_mapping=...)
GroupingConfig(
  methods=[GroupingMethod.SMARTS, GroupingMethod.LISTS, GroupingMethod.REGEX],
  column_mapping=...,
)

Filtering SMARTS fingerprints

To apply only a subset of the ~400 bundled SMARTS patterns, pass their names to smarts_fingerprints:

GroupingConfig(
  methods=[GroupingMethod.SMARTS],
  column_mapping=...,
  smarts_fingerprints={"Alkanes", "PAH derivatives hydrocarbon"},
)

When smarts_fingerprints is None (default), all available patterns are applied.

Custom assets path

By default ChemicalGrouper loads assets from the package installation directory. To point it at a different directory:

ChemicalGrouper(df=df, grouping_config=config, assets_path="/path/to/custom/assets")

Input Requirements

  • ChemicalGrouper must be initialized with a non-empty pandas DataFrame.
  • ColumnMapping must provide at least one of cas or smiles (the other may be None).
  • name_columns and formula are optional at configuration time, but REGEX grouping may trigger CompTox enrichment when they are missing.
  • Input column names can be custom; FCCgroup maps them to canonical internal fields.

Assets And External Services

  • Packaged assets live under fccgroup/assets.
  • Mapping.xlsx and the files in fccgroup/assets/lists are required for LISTS workflow.
  • CompTox (EPA) is used only when the selected methods require fields that are not already available in the mapped input columns (e.g. SMILES needed for SMARTS but only CAS provided).
  • CompTox enrichment requires a valid API key set in the COMPTOX_API_KEY environment variable.
  • CompTox usage depends on network availability and the EPA CompTox service.

Output

group_chemicals(save=True) returns a pandas DataFrame with a MultiIndex on columns. The first level groups results by method; the second level is the column name.

Top-level label Contents
Identifier Internal identifier columns (casId, SMILES)
Structural patterns Chemical groups and per-fingerprint columns (SMARTS method)
Lists Per-list membership columns (LISTS method)
Regex Pattern group columns (REGEX method)

Example column access:

# Access the SMILES identifier column
results[("Identifier", "SMILES")]

# Access the Chemical groups column
results[("Structural patterns", "Chemical groups")]

When save=True (default), results are also written to an Excel file in the current working directory.

Runtime Dependencies

FCCgroup currently declares the runtime dependencies described in requirements.txt

Citation

If you use FCCgroup in your research, please cite:

@software{fccgroup,
  title={FCCgroup: Chemical Grouping and Classification Package},
  author={Anguera Sempere, Albert and Wiesinger, Helene},
  organization={Food Packaging Forum},
  year={2026},
}

Contributing

Contributions are welcome through pull requests.

Support

For issues, questions, or suggestions, open an issue at https://github.com/Food-Packaging-Forum/fccgroup/issues.

License

Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0). See LICENSE for details.

Disclaimer

This software is provided "as is", without warranties of any kind, express or implied. To the maximum extent permitted by applicable law, Food Packaging Forum and contributors shall not be liable for any direct, indirect, incidental, special, exemplary, or consequential damages arising from the use or misuse of this software.

Metadata

Release files for fccgroup 0.4.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fccgroup 0.4.3
File Size Uploaded
fccgroup-0.4.3.tar.gz 78.6 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for fccgroup 0.4.3
File Interpreter ABI Platform
fccgroup-0.4.3-py3-none-any.whl Python 3 none any Details

Total release size: 157.2 MB

Release files / fccgroup-0.4.3.tar.gz

Download URL fccgroup-0.4.3.tar.gz
Size 78.6 MB
Tags Source
SHA-256 checksum
How to use checksums
b9a73606ebbdce16e1b0af549b4533f3c04baf21e6bafce977a186d760981d3a
BLAKE2b-256 checksum
How to use checksums
a6a06360b40b776dfa32b1e90c52e21ab2f15feac4d96c614f27b20aa4c3c72e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 21, 2026.

Transparency log

Release files / fccgroup-0.4.3-py3-none-any.whl

Download URL fccgroup-0.4.3-py3-none-any.whl
Size 78.7 MB
Tags Python 3
SHA-256 checksum
How to use checksums
62d38e9cefd669e8795337c0faf6b02e6debdab6e1213b75f1ab1792418d72e0
BLAKE2b-256 checksum
How to use checksums
853155a68a85e299e731e562731a6534ca1ffbe558b29f17a58aa827405eb10f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 21, 2026.

Transparency log

Release history Release notifications | RSS feed

0.4.5

2 release files

0.4.4

2 release files

This release

0.4.3 This release

2 release files

0.4.2

2 release files

0.4.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page