Skip to main content

Figlinq Python Library

This package contains utilities for interfacing with Plotly's Chart Studio and Figlinq services. The project has been cloned from chart-studio 1.1.0. The original package has been modified so that credentials and configuration can be set from environment variables (see figlinq.tools.get_credentials() and figlinq.tools.get_config()). Additional functions have been added to support the Figlinq service. The original package is licensed under the MIT license, and this package is also licensed under the MIT license.

Installation

pip install figlinq

Editing figures: figlinq.open_figure

figlinq.open_figure(fid) edits a Figlinq figure (a multi-panel page of plots, images and text) from Python. All its methods are coroutines, so use await (in a script, asyncio.run(main())).

import figlinq

fig = figlinq.open_figure("alice:12")      # the figure's fid
state = await fig.state()                  # read first: page, layers, nodes, selection
await fig.add_content(["alice:12", "alice:15"], layout={"type": "grid", "cols": 2})
await fig.modify_plots(fids=["alice:12"], layout={"title": {"text": "Growth"}}, traceActions=["no_modify"])

async with fig.batch() as b:               # several operations, all or none
    t = b.add_text("A", 10, 10)            # a Ref to the new text's id
    b.align([t], "left")
img = await fig.image()                    # a PNG of the page

In a script or a plain Python session every call goes to the server and is stored at once as one revision of the figure. It is guarded by the figure's ETag, so a figure that changed in the meantime raises VersionConflict: read state() again. Inside the Figlinq web app (Flows, the assistant) with the figure open in the editor, the changes are live in the editor and are not saved until the user saves. modify_plots rewrites the plot files at once on both. Errors are subclasses of figlinq.FigureEditorError (figlinq.figure_editor.VersionConflict, ReadOnly, NotFound, PermissionDenied, ...) with a .code. See the docstring of figlinq.figure_editor for the full list of operations.

Reading and editing structures: figlinq.open_structure

figlinq.open_structure(fid) reads and edits a Figlinq chemistry file (a molecule or reaction drawn in the structure editor) from Python. A chemistry file is one canvas, so operations have no targets and results have no ids. All methods are coroutines. In a script, set the server and your API key first, for example in the environment (export FIGLINQ_USERNAME=alice FIGLINQ_API_KEY=... FIGLINQ_API_DOMAIN=https://figlinq.example.org), or in Python with figlinq.session.sign_in("alice", "<api key>", plotly_api_domain="https://figlinq.example.org").

import asyncio
import figlinq

async def main():
    s = figlinq.open_structure("alice:7")       # the structure file's fid
    state = await s.state()                     # SMILES, InChI, InChIKey, formula, weights, atom and bond counts
    print(state)
    await s.set("c1ccccc1O")                    # SMILES, molfile, rxn or Ketcher JSON (the format is detected)
    await s.add("CC(=O)O")                      # draw a second structure beside it
    img = await s.image(format="png")           # a picture on a white page
    open("structure.png", "wb").write(img.png)  # in the Figlinq app: img.display()

    async with s.batch() as b:                  # several operations, all or none
        b.set("CCO")
        b.layout()
        b.state(["smiles", "ket"])
    print(b.results)

asyncio.run(main())

(In a notebook cell or the Figlinq assistant, top-level await works and figlinq.open_structure() without a fid edits the structure open in the editor.)

state(include=[...]) can add ket (Ketcher JSON, the lossless form), molfile (V2000) and rxn; a part the engine cannot produce for this structure is None and named in state.unavailable. In a script every call goes to the server and is stored at once as one revision of the file, guarded by its ETag (VersionConflict if it changed in the meantime: read state() again). Inside the Figlinq web app with the file open in the editor the changes are live in the editor and not saved until the user saves. A .mol, .rxn or .smi file is never rewritten in another format: a change raises LossyFormat unless you pass save_as="ket" (server only), which creates a new .ket file beside the original (result.created has its fid). Errors are subclasses of figlinq.StructureEditorError (figlinq.structure_editor.VersionConflict, InvalidStructure, NoEditor, Rejected with failed_index and results_so_far, ...) with a .code.

Metadata

Release files for figlinq 0.15.0

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

Built distribution (wheel)

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

Release files / figlinq-0.15.0-py3-none-any.whl

Download URL figlinq-0.15.0-py3-none-any.whl
Size 172.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f58a823bd0371c38ee2784f49b49b4d88c547a5b2eb630a70d3b70262b4dcf4c
BLAKE2b-256 checksum
How to use checksums
b7332c79cf52c663b505de3f6d8b9367c91ae4cdb85f1611a0b584eae733ed58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.10.12

Security for figlinq 0.15.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.15.0 This release

1 release file No provenance

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