Download mcp/cbio.py from mgbam/MCP_Res: direct link, hf CLI and curl.
- Browser
- Download file 721 Bytes
-
https://huggingface.co/spaces/mgbam/MCP_Res/resolve/7186f2cee4b0cd1ff11b5142acc03f7578ddcbc4/mcp/cbio.py
- Command line
-
hf download hf://spaces/mgbam/MCP_Res@7186f2cee4b0cd1ff11b5142acc03f7578ddcbc4/mcp/cbio.py
-
curl -L -o cbio.py https://huggingface.co/spaces/mgbam/MCP_Res/resolve/7186f2cee4b0cd1ff11b5142acc03f7578ddcbc4/mcp/cbio.py
721 Bytes
| # mcp/cbio.py | |
| from pybioportal import PyBioPortal | |
| import asyncio | |
| async def fetch_cbio_variants(gene_symbol: str) -> list[dict]: | |
| """ | |
| Fetches mutation/variant data for a specific gene symbol | |
| from the default cBioPortal study (e.g. 'brca_mskcc_2020'). | |
| """ | |
| base_url = "https://www.cbioportal.org" | |
| client = PyBioPortal(base_url) | |
| # Build the query path for mutations in the gene | |
| query_path = f"/mutation?gene={gene_symbol}&studyId=brca_mskcc_2020" | |
| loop = asyncio.get_event_loop() | |
| df = await loop.run_in_executor( | |
| None, | |
| lambda: client.get_data_frame(query_path) | |
| ) | |
| # Convert DataFrame rows to dicts for JSON serialization | |
| return df.to_dict(orient="records") | |