Skip to content

Commit

Permalink
[ALS-7658] Make dataset id dynamic in R (#279)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesPeck authored Oct 28, 2024
1 parent 710237f commit de2642e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib/assets/codeBlocks.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"bdcPythonExport": "# Requires python 3.7 or later\nimport sys\nimport pandas as pd\nimport matplotlib.pyplot as plt\n\n# BDC Powered by Terra users uncomment the following line to specify package install location\n# sys.path.insert(0, r\"/home/jupyter/.local/lib/python3.7/site-packages\")\n!{sys.executable} -m pip install --upgrade --force-reinstall git+https://github.com/hms-dbmi/pic-sure-python-client.git\n!{sys.executable} -m pip install --upgrade --force-reinstall git+https://github.com/hms-dbmi/pic-sure-python-adapter-hpds.git\n!{sys.executable} -m pip install --upgrade --force-reinstall git+https://github.com/hms-dbmi/pic-sure-biodatacatalyst-python-adapter-hpds.git\n\nimport PicSureClient\nimport PicSureBdcAdapter\n\ntoken_file = \"token.txt\"\nwith open(token_file, \"r\") as f:\n my_token = f.read()\n\nbdc = PicSureBdcAdapter.Adapter(\"https://picsure.biodatacatalyst.nhlbi.nih.gov/picsure\", my_token)\n\nresource = bdc.useResource('02e23f52-f354-4e8b-992c-d37c8b9ba140')\n\nqueryID = \"{{queryId}}\" \n\nresults = resource.retrieveQueryResults(queryID)\n\nfrom io import StringIO\ndf_UI = pd.read_csv(StringIO(results), low_memory=False)\ndf_UI.head() # View top 5 rows of dataframe",
"bdcRExport": "# Requires R 3.4 or later\n### Uncomment this code if you are not using the PIC-SURE environment in *BDC-Seven Bridges*, or if you do not have all the necessary dependencies installed.\n#install.packages(\"devtools\")\n\nSys.setenv(TAR = \"/bin/tar\")\noptions(unzip = \"internal\")\ndevtools::install_github(\"hms-dbmi/pic-sure-r-adapter-hpds\", ref=\"main\", force=T, quiet=FALSE)\nlibrary(dplyr)\n\ntoken_file <- \"token.txt\"\ntoken <- scan(token_file, what = \"character\")\n\nsession <- picsure::bdc.initializeSession(\"https://picsure.biodatacatalyst.nhlbi.nih.gov/picsure\", token)\nsession <- picsure::bdc.setResource(session = session, resourceName = \"AUTH\")\n\nqueryID <- \"526c318d-4a0c-4937-9baa-e21042a0e444\"\nresults <- picsure::getResultByQueryUUID(session, queryID)\nhead(results) # View top 5 rows of dataframe",
"bdcRExport": "# Requires R 3.4 or later\n### Uncomment this code if you are not using the PIC-SURE environment in *BDC-Seven Bridges*, or if you do not have all the necessary dependencies installed.\n#install.packages(\"devtools\")\n\nSys.setenv(TAR = \"/bin/tar\")\noptions(unzip = \"internal\")\ndevtools::install_github(\"hms-dbmi/pic-sure-r-adapter-hpds\", ref=\"main\", force=T, quiet=FALSE)\nlibrary(dplyr)\n\ntoken_file <- \"token.txt\"\ntoken <- scan(token_file, what = \"character\")\n\nsession <- picsure::bdc.initializeSession(\"https://picsure.biodatacatalyst.nhlbi.nih.gov/picsure\", token)\nsession <- picsure::bdc.setResource(session = session, resourceName = \"AUTH\")\n\nqueryID <- \"{{queryId}}\"\nresults <- picsure::getResultByQueryUUID(session, queryID)\nhead(results) # View top 5 rows of dataframe",
"bdcPythonAPI": "# Requires python 3.6 or later\nimport sys\nimport pandas as pd\nimport matplotlib.pyplot as plt\n# BDC Powered by Terra users uncomment the following line to specify package install location\n# sys.path.insert(0, r\"/home/jupyter/.local/lib/python3.7/site-packages\")\n!{sys.executable} -m pip install --upgrade --force-reinstall git+https://github.com/hms-dbmi/pic-sure-python-client.git\n!{sys.executable} -m pip install --upgrade --force-reinstall git+https://github.com/hms-dbmi/pic-sure-python-adapter-hpds.git\n!{sys.executable} -m pip install --upgrade --force-reinstall git+https://github.com/hms-dbmi/pic-sure-biodatacatalyst-python-adapter-hpds.git\nimport PicSureClient\nimport PicSureBdcAdapter\n# Set up connection to PIC-SURE API\nPICSURE_network_URL = \"https://picsure.biodatacatalyst.nhlbi.nih.gov/picsure\"\ntoken_file = \"token.txt\"\n\nwith open(token_file, \"r\") as f:\n my_token = f.read()\n\nbdc = PicSureBdcAdapter.Adapter(PICSURE_network_URL, my_token)",
"bdcRAPI": "# Requires R 3.4 or later\n### Uncomment this code if you are not using the PIC-SURE environment in *BDC-Seven Bridges*, or if you do not have all the necessary dependencies installed.\n#install.packages(\"devtools\")\nSys.setenv(TAR = \"/bin/tar\")\noptions(unzip = \"internal\")\ndevtools::install_github(\"hms-dbmi/pic-sure-r-adapter-hpds\", ref=\"main\", force=T, quiet=FALSE)\nlibrary(dplyr)\nPICSURE_network_URL = \"https://picsure.biodatacatalyst.nhlbi.nih.gov/picsure\"\ntoken_file <- \"token.txt\"\ntoken <- scan(token_file, what = \"character\")\nsession <- picsure::bdc.initializeSession(PICSURE_network_URL, token)\nsession <- picsure::bdc.setResource(session = session, resourceName = \"AUTH\")",
"basePythonExport": "Code not set",
Expand Down
3 changes: 2 additions & 1 deletion src/lib/components/explorer/export/ExportStepper.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@
<CodeBlock
language="r"
lineNumbers={true}
code={codeBlocks?.bdcRExport || 'Code not set'}
code={codeBlocks?.bdcRExport?.replace('{{queryId}}', datasetId) ||
'Code not set'}
></CodeBlock>
{:else if tabSet === 2}
<div>
Expand Down

0 comments on commit de2642e

Please sign in to comment.