mkt.databases.oncokb.OncoKBCancerGeneList

class mkt.databases.oncokb.OncoKBCancerGeneList(url: str = 'https://www.oncokb.org/api/v1/utils/cancerGeneList')[source]

Bases: RESTAPIClient

Client for the OncoKB cancer gene list endpoint.

Fetches the full OncoKB cancer gene list (/utils/cancerGeneList) in a single network call, exposing the raw JSON in _json and a tidy table in _df. The endpoint is public (no token required), so this subclasses the plain RESTAPIClient rather than the token-bearing OncoKB hierarchy used for therapeutic-level/variant annotations. Mirrors the cancerhotspots client: query once, filter client-side via get_gene(), and round-trip to CSV via to_csv() / from_csv().

__init__(url: str = 'https://www.oncokb.org/api/v1/utils/cancerGeneList') None

Methods

__eq__(other)

Return self==value.

__init__([url])

__post_init__()

_stamp_from_response(res)

Record query datetime + cache provenance from a requests-cache response.

_stamp_now()

Record current UTC datetime; cache provenance unknown.

check_response(res)

Check the response status code for errors.

from_csv(path)

Build a client from a CSV written by to_csv(), without querying.

from_dataframe(df)

Build a client from an existing table without querying the API.

get_gene(hugo_symbol)

Return the cancer gene list record(s) for a single gene.

query_api()

Query the OncoKB cancer gene list endpoint and populate _json and _df.

read_csv(path)

Read a cancer gene list written by to_csv() back into a DataFrame.

to_csv(path)

Write the cancer gene list to CSV, json-encoding list-valued columns.

Attributes

__dataclass_fields__

__dataclass_params__

__match_args__

_df

_json

df

Cancer gene list as a DataFrame (one row per gene).

from_cache

Whether the most recent response was served from requests-cache.

query_datetime

UTC datetime the underlying network query was made (cache creation time if served from cache).

url

URL for the OncoKB cancer gene list endpoint.

__init__(url: str = 'https://www.oncokb.org/api/v1/utils/cancerGeneList') None
property df: DataFrame | None

Cancer gene list as a DataFrame (one row per gene).

classmethod from_csv(path: str) OncoKBCancerGeneList[source]

Build a client from a CSV written by to_csv(), without querying.

Parameters:

path (str) – Path to a CSV previously written by to_csv().

Returns:

Instance backed by the cached table.

Return type:

OncoKBCancerGeneList

classmethod from_dataframe(df: DataFrame) OncoKBCancerGeneList[source]

Build a client from an existing table without querying the API.

Bypasses __post_init__ (which would issue the network query) via object.__new__ and sets _df directly, so cached data can be reloaded offline. _json is left None.

Parameters:

df (pd.DataFrame) – Cancer gene list table (e.g. from read_csv() or df).

Returns:

Instance backed by df; get_gene() works as usual.

Return type:

OncoKBCancerGeneList

get_gene(hugo_symbol: str) DataFrame[source]

Return the cancer gene list record(s) for a single gene.

Parameters:

hugo_symbol (str) – HGNC gene symbol to filter on (e.g. "BRAF").

Returns:

Rows of df whose hugoSymbol matches; empty if none.

Return type:

pd.DataFrame

query_api() None[source]

Query the OncoKB cancer gene list endpoint and populate _json and _df.

static read_csv(path: str) DataFrame[source]

Read a cancer gene list written by to_csv() back into a DataFrame.

Inverts to_csv(): json-decodes the list-valued columns.

Parameters:

path (str) – Path to a CSV previously written by to_csv().

Returns:

Cancer gene list equivalent to df.

Return type:

pd.DataFrame

to_csv(path: str) None[source]

Write the cancer gene list to CSV, json-encoding list-valued columns.

Parameters:

path (str) – Output CSV path.

url: str = 'https://www.oncokb.org/api/v1/utils/cancerGeneList'

URL for the OncoKB cancer gene list endpoint.