Skip to content

makers

Makers responsible for performing operations.

PymatGenMaker dataclass

Bases: JFChemMaker[InputType, OutputType]


              flowchart TD
              jfchemistry.core.makers.PymatGenMaker[PymatGenMaker]
              jfchemistry.core.makers.jfchem_maker.JFChemMaker[JFChemMaker]
              jfchemistry.core.makers.core_maker.CoreMaker[CoreMaker]

                              jfchemistry.core.makers.jfchem_maker.JFChemMaker --> jfchemistry.core.makers.PymatGenMaker
                                jfchemistry.core.makers.core_maker.CoreMaker --> jfchemistry.core.makers.jfchem_maker.JFChemMaker
                



              click jfchemistry.core.makers.PymatGenMaker href "" "jfchemistry.core.makers.PymatGenMaker"
              click jfchemistry.core.makers.jfchem_maker.JFChemMaker href "" "jfchemistry.core.makers.jfchem_maker.JFChemMaker"
              click jfchemistry.core.makers.core_maker.CoreMaker href "" "jfchemistry.core.makers.core_maker.CoreMaker"
            

Base class for makers that process single structures or molecules.

Source code in jfchemistry/core/makers/pymatgen_maker.py
11
12
13
14
15
16
17
18
@dataclass
class PymatGenMaker[
    InputType: RecursiveStructureList | RecursiveMoleculeList,
    OutputType: RecursiveStructureList | RecursiveMoleculeList,
](JFChemMaker[InputType, OutputType]):
    """Base class for makers that process single structures or molecules."""

    _output_model: Type[Output] = Output

make

make(input: InputType | list[InputType], **kwargs) -> Response[_output_model]

Create a workflow job for processing structure(s).

Automatically handles job distribution for lists of structures. Each structure in a list is processed as a separate job for parallel execution.

PARAMETER DESCRIPTION
input

Single Pymatgen SiteCollection or list of SiteCollections.

TYPE: InputType | list[InputType]

**kwargs

Additional kwargs to pass to the operation.

DEFAULT: {}

RETURNS DESCRIPTION
Response[_output_model]

Response containing: - structure: Processed structure(s) - files: XYZ format file(s) of the structure(s) - properties: Computed properties from the operation

Examples:

>>> from jfchemistry.conformers import CRESTConformers
>>> from pymatgen.core import Molecule
>>> molecule = Molecule.from_ase_atoms(molecule("C2H6"))
>>> # Generate conformers
>>> conformer_gen = CRESTConformers(ewin=6.0)
>>> job = conformer_gen.make(input)
Source code in jfchemistry/core/makers/jfchem_maker.py
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
@jfchem_job()
def make(
    self,
    input: InputType | list[InputType],
    **kwargs,
) -> Response[_output_model]:
    """Create a workflow job for processing structure(s).

    Automatically handles job distribution for lists of structures. Each
    structure in a list is processed as a separate job for parallel execution.

    Args:
        input: Single Pymatgen SiteCollection or list of SiteCollections.
        **kwargs: Additional kwargs to pass to the operation.

    Returns:
        Response containing:
            - structure: Processed structure(s)
            - files: XYZ format file(s) of the structure(s)
            - properties: Computed properties from the operation

    Examples:
        >>> from jfchemistry.conformers import CRESTConformers # doctest: +SKIP
        >>> from pymatgen.core import Molecule # doctest: +SKIP
        >>> molecule = Molecule.from_ase_atoms(molecule("C2H6")) # doctest: +SKIP
        >>> # Generate conformers
        >>> conformer_gen = CRESTConformers(ewin=6.0) # doctest: +SKIP
        >>> job = conformer_gen.make(input) # doctest: +SKIP
    """
    return self._run_job(input, **kwargs)

RDKitMaker dataclass

Bases: JFChemMaker[InputType, OutputType]


              flowchart TD
              jfchemistry.core.makers.RDKitMaker[RDKitMaker]
              jfchemistry.core.makers.jfchem_maker.JFChemMaker[JFChemMaker]
              jfchemistry.core.makers.core_maker.CoreMaker[CoreMaker]

                              jfchemistry.core.makers.jfchem_maker.JFChemMaker --> jfchemistry.core.makers.RDKitMaker
                                jfchemistry.core.makers.core_maker.CoreMaker --> jfchemistry.core.makers.jfchem_maker.JFChemMaker
                



              click jfchemistry.core.makers.RDKitMaker href "" "jfchemistry.core.makers.RDKitMaker"
              click jfchemistry.core.makers.jfchem_maker.JFChemMaker href "" "jfchemistry.core.makers.jfchem_maker.JFChemMaker"
              click jfchemistry.core.makers.core_maker.CoreMaker href "" "jfchemistry.core.makers.core_maker.CoreMaker"
            

Base class for operations on molecules without 3D geometry.

This Maker processes RDMolMolecule objects that do not yet have assigned 3D coordinates. It is primarily used for structure generation tasks that convert molecular representations (SMILES, SMARTS) into 3D structures.

The class handles automatic job distribution for lists of molecules and molecules with multiple conformers, enabling parallel processing of multiple structures.

ATTRIBUTE DESCRIPTION
name

Descriptive name for the job/operation being performed.

TYPE: str

Source code in jfchemistry/core/makers/rdkit_maker.py
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@dataclass
class RDKitMaker[
    InputType: RecursiveRDKitMoleculeList,
    OutputType: RecursiveRDKitMoleculeList | RecursiveMoleculeList | RecursiveStructureList,
](JFChemMaker[InputType, OutputType]):
    """Base class for operations on molecules without 3D geometry.

    This Maker processes RDMolMolecule objects that do not yet have assigned 3D
    coordinates. It is primarily used for structure generation tasks that convert
    molecular representations (SMILES, SMARTS) into 3D structures.

    The class handles automatic job distribution for lists of molecules and
    molecules with multiple conformers, enabling parallel processing of multiple
    structures.

    Attributes:
        name: Descriptive name for the job/operation being performed.

    """

    name: str = "Single RDMolMolecule Maker"
    _output_model: type[Output] = Output
    _properties_model: type[Properties] = Properties

    def _handle_conformers(self, structure: RDMolMolecule) -> Response[_output_model]:
        """Distribute workflow jobs for each conformer in a molecule.

        Creates separate jobs for each conformer in an RDKit molecule, allowing
        parallel processing of multiple conformations. This is useful when a
        molecule has multiple embedded conformers that need to be processed
        independently (e.g., optimized separately).

        Args:
            maker: A Maker instance that will process each conformer.
            structure: RDMolMolecule containing one or more conformers.

        Returns:
            Response containing:
                - structures: List of processed structures from each job
                - files: List of output files from each job
                - properties: List of computed properties from each job
                - detour: List of jobs to be executed

        """
        jobs: list[Response] = []
        for confId in range(structure.GetNumConformers()):
            s = RDMolMolecule(rdchem.Mol(structure, confId=confId))
            jobs.append(self.make(s))

        return Response(
            output=self._output_model(
                structure=[job.output.structure for job in jobs],
                files=[job.output.files for job in jobs],
                properties=[job.output.properties for job in jobs],
            ),
            detour=jobs,  # type: ignore
        )

    def _run_job(self, input: InputType | list[InputType], **kwargs) -> Response[_output_model]:
        """Run the job for a single molecule or a list of molecules."""
        if not isinstance(input, list) and input.GetNumConformers() > 1:
            return self._handle_conformers(input)
        return super()._run_job(input, **kwargs)

make

make(input: InputType | list[InputType], **kwargs) -> Response[_output_model]

Create a workflow job for processing structure(s).

Automatically handles job distribution for lists of structures. Each structure in a list is processed as a separate job for parallel execution.

PARAMETER DESCRIPTION
input

Single Pymatgen SiteCollection or list of SiteCollections.

TYPE: InputType | list[InputType]

**kwargs

Additional kwargs to pass to the operation.

DEFAULT: {}

RETURNS DESCRIPTION
Response[_output_model]

Response containing: - structure: Processed structure(s) - files: XYZ format file(s) of the structure(s) - properties: Computed properties from the operation

Examples:

>>> from jfchemistry.conformers import CRESTConformers
>>> from pymatgen.core import Molecule
>>> molecule = Molecule.from_ase_atoms(molecule("C2H6"))
>>> # Generate conformers
>>> conformer_gen = CRESTConformers(ewin=6.0)
>>> job = conformer_gen.make(input)
Source code in jfchemistry/core/makers/jfchem_maker.py
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
@jfchem_job()
def make(
    self,
    input: InputType | list[InputType],
    **kwargs,
) -> Response[_output_model]:
    """Create a workflow job for processing structure(s).

    Automatically handles job distribution for lists of structures. Each
    structure in a list is processed as a separate job for parallel execution.

    Args:
        input: Single Pymatgen SiteCollection or list of SiteCollections.
        **kwargs: Additional kwargs to pass to the operation.

    Returns:
        Response containing:
            - structure: Processed structure(s)
            - files: XYZ format file(s) of the structure(s)
            - properties: Computed properties from the operation

    Examples:
        >>> from jfchemistry.conformers import CRESTConformers # doctest: +SKIP
        >>> from pymatgen.core import Molecule # doctest: +SKIP
        >>> molecule = Molecule.from_ase_atoms(molecule("C2H6")) # doctest: +SKIP
        >>> # Generate conformers
        >>> conformer_gen = CRESTConformers(ewin=6.0) # doctest: +SKIP
        >>> job = conformer_gen.make(input) # doctest: +SKIP
    """
    return self._run_job(input, **kwargs)