Skip to content

Library (phoskintime.networkmodel.api)

The third way to use PhosKinTime, next to the command line and the app. Every function works on files: a config.toml and a run folder. Nothing here changes the model or its numbers; a run is the same python -m phoskintime.networkmodel.runner the command line starts.

from phoskintime.networkmodel import api

if __name__ == "__main__":  # needed: a run starts worker processes that import your script
    conf = api.write_example("my-project")       # a synthetic example project; or your own config.toml
    report = api.validate_inputs(conf)            # what a run would read, checked without fitting
    assert report.ok, report.errors

    run_dir = api.run(conf, log="run.log")        # one network-model run (a subprocess); returns the run folder
    tables = api.read_results(run_dir)            # the run's tables as pandas DataFrames
    print(tables["parameters"].query("sample_id == 'best'")[["name", "value", "identifiability_label"]])
    print(tables["missing"])                      # tables the run does not have, with the reason

    bundle = api.bundle_path(run_dir)             # <run>/<run name>.pkt.zip, written by the run
    check = api.check_bundle(bundle)              # the bundle against contracts/phoskintime/1.1
function returns
load_config(path=None) the [networkmodel] table of a config.toml (default: the repository's configs/config.toml)
validate_inputs(config=None, extra_args=()) ValidationReport(ok, errors, warnings, counts): input files, the KinOpt/TFOpt file contract, time columns and the network build of a run (phoskintime.networkmodel.PosteriorObjective.build_run_system), without fitting
run(config=None, output_dir=None, extra_args=(), log=None) the run folder; raises subprocess.CalledProcessError if the run fails
read_results(run_dir) the tables of the run bundle (trajectories, parameters, state_index, metrics, multistart, profile_likelihood, kinase_activity, matrix_labels) as DataFrames, plus missing
make_bundle(run_dir, out=None, zip=False, max_input_mb=50) / check_bundle(path) / bundle_path(run_dir) the run bundle (phoskintime.common.bundle)
write_example(folder, n_starts=4, cores=None) the example project's config.toml
simulate(model, experiments=None, preset=…, draws=…, out=…) in-silico experiments on a fitted model

The post-run analyses and exports are importable too: phoskintime.networkmodel.analysis.ANALYSES and run_analysis(name, argv), phoskintime.networkmodel.exchange.EXPORTS and run_export(name, argv) (the same as phoskintime analyze / export).

The model itself (data loading, the network, the mechanism file and SBML model, the objective, the fit engines, profiles, posterior) is documented in the API Reference and on the Global Network Model page.