Grouper.libraries.Libraries module

Module for pre-loading libraries of GroupGraphs.

This module defines classes for managing and querying libraries commonly used in group contribution methods. It includes predefined libraries for Joback, UNIFAC, and SaftGammaMie methods.

class Grouper.libraries.Libraries.BasisSet

Bases: object

Base class for managing a library of chemical groups.

group_traces_

A list of GroupExtension objects representing the groups in the library.

Type:

list

add_group(group, doi=None, smarts=None, priority=None)

Add a group to the library.

Parameters:
  • group (Group) – The chemical group to add.

  • doi (str, optional) – doi reference for the group. Defaults to None.

  • smarts (str, optional) – SMARTS pattern for the group. Defaults to None.

  • priority (int, optional) – Priority of the group. Defaults to None.

fragment_smiles(smiles, onFail='error', **kwargs)

Fragment a SMILES string based on the groups in self.group_traces.

Parameters:
  • smiles (str) – The Daylight SMILES string for the molecule to fragment.

  • onFail (str, default "error") – Method for handling failing fragmentation approaches. - “error”: Raise an exception if fragmentation returns no matching groups. - “itemize”: All missing atoms are treated as atomistic Groups with the name “DEFAULT#N”, where N is the atomic number of the atom. - “condense”: A group is returned that is the single Group with no edges for the entire molecule. Useful if the Library does not have specific definitions for small molecules such as methane (CH4), water (H2O), or formamide (NC=O).

Notes

See Grouper.fragmentation.fragment method for more details on kwargs.

Returns:

groupGList – The list of all fragmented group graphs generated using Grouper.fragmentation.fragment to perform fragmentation.

Return type:

List[Grouper.GroupGraph]

get_groups()

Return an iterator of the groups in the library.

Yields:

Group – The next group in the library.

property group_traces

Get the list of group traces.

property n_groups

Get the number of groups in the library.

Returns:

The number of groups. int: The number of groups.

Return type:

int

query_groups(query)

Query the library for groups that match the query.

Parameters:

query (dict) – A dictionary of attributes and their values to match.

Returns:

A list of groups that match the query.

Return type:

list

visualize_library()

Visualize the library using RDKit.

class Grouper.libraries.Libraries.GroupExtension(group, doi, extended_smarts, priority)

Bases: tuple

doi

Alias for field number 1

extended_smarts

Alias for field number 2

group

Alias for field number 0

priority

Alias for field number 3

class Grouper.libraries.Libraries.Joback

Bases: BasisSet

Joback group contribution method for estimating physical properties of organic compounds.

This class predefines a library of chemical groups based on the Joback method.

class Grouper.libraries.Libraries.SaftGammaMie

Bases: BasisSet

SAFT-gamma-Mie group contribution method for thermodynamic modeling.

This class is a placeholder for the SAFT-gamma-Mie library.

class Grouper.libraries.Libraries.Unifac

Bases: BasisSet

UNIFAC group contribution method for estimating activity coefficients.

This class predefines a library of chemical groups based on the UNIFAC method.