Using gorder as a Python package

gorder can also be used as a Python package, allowing you to call it directly from your Python code.

To install gorder, you can use pip:

$ pip install git+https://github.com/Ladme/gorder.git#subdirectory=pygorder

However, you should use the uv package manager instead. To add gorder to your uv project, run:

$ uv add git+https://github.com/Ladme/gorder.git#subdirectory=pygorder

Next, import the package into your Python code:

import gorder

Once imported, you can access all the options and functionality described in this manual.

For instance, the following configuration YAML file:

structure: system.tpr
trajectory: md.xtc
analysis_type: !CGOrder
  beads: "@membrane"
output: order.yaml

can also by written as the following Python code:

analysis = gorder.Analysis(
    structure = "system.tpr",
    trajectory = "md.xtc",
    analysis_type = gorder.analysis_types.CGOrder("@membrane"),
    output_yaml = "order.yaml",
)

You can then run the analysis like this:

results = analysis.run()

and either write the results into the output file(s):

results.write()

or access them programmatically.

See the Python API documentation on ladme.github.io/pygorder-docs for more information about using gorder as a Python package.