mkt.databases.oncokb.OncoKBCancerGeneList
- class mkt.databases.oncokb.OncoKBCancerGeneList(url: str = 'https://www.oncokb.org/api/v1/utils/cancerGeneList')[source]
Bases:
RESTAPIClientClient 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_jsonand a tidy table in_df. The endpoint is public (no token required), so this subclasses the plainRESTAPIClientrather than the token-bearingOncoKBhierarchy used for therapeutic-level/variant annotations. Mirrors the cancerhotspots client: query once, filter client-side viaget_gene(), and round-trip to CSV viato_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 the OncoKB cancer gene list endpoint and populate
_jsonand_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_jsonCancer gene list as a DataFrame (one row per gene).
from_cacheWhether the most recent response was served from requests-cache.
query_datetimeUTC datetime the underlying network query was made (cache creation time if served from cache).
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:
- 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) viaobject.__new__and sets_dfdirectly, so cached data can be reloaded offline._jsonis left None.- Parameters:
df (pd.DataFrame) – Cancer gene list table (e.g. from
read_csv()ordf).- Returns:
Instance backed by
df;get_gene()works as usual.- Return type:
- 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
dfwhosehugoSymbolmatches; empty if none.- Return type:
pd.DataFrame
- 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.
- 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.