Skip to content

Commit

Permalink
Added notebook to test PR11
Browse files Browse the repository at this point in the history
  • Loading branch information
ianfore committed Jan 22, 2021
1 parent b26f81c commit 63f1030
Show file tree
Hide file tree
Showing 3 changed files with 206 additions and 14 deletions.
10 changes: 8 additions & 2 deletions fasp/runner/fasp_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,13 @@ def runQuery(self, query, note):
query_job = self.searchClient.runQuery(query) # Send the query
creditor.creditClass(self.searchClient)
# repeat steps 2 and 3 for each row of the query
runIds = []
for row in query_job:

print("subject={}, drsID={}".format(row[0], row[1]))
# To do - get the subject/sample name from the query
runKey = 'subject'
print("{}={}, drsID={}".format(runKey, row[0], row[1]))


# Step 2 - Use DRS to get the URL
objInfo = self.drsClient.getObject(row[1])
Expand All @@ -72,6 +76,7 @@ def runQuery(self, query, note):
if self.live:
pipeline_id = self.workClient.runWorkflow(url, outfile)
print('workflow submitted, run:{}'.format(pipeline_id))
runIds.append({runKey:row[0], 'run_id':pipeline_id})
creditor.creditClass(self.workClient)
via = 'sh'
#pipeline_id = 'paste here'
Expand All @@ -80,4 +85,5 @@ def runQuery(self, query, note):
if self.live:
self.pipelineLogger.logRun(time, via, note, pipeline_id, outfile, str(fileSize),
self.searchClient, self.drsClient, self.workClient)


return runIds
184 changes: 184 additions & 0 deletions notebooks/GTEXExample-DNAStack.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This notebook computes on the freely available GTEX version 8 files on Amazon AWS using the Seven Bridges Cancer Genomics Cloud WES service. \n",
"\n",
"In this case the DRS ids of the GTEX files are available via a client which acccess a local manifest file. The manifest file is obtained from Anvil as follows.\n",
"https://anvilproject.org/learn/reference/gtex-v8-free-egress-instructions\n",
"\n",
"Rather than use the Gen3 Downloader described in the egress instructions, this example uses the Anvil DRS service to obtain URLs which can be passed to the Seven Bridges CGC WES Service.\n",
"\n",
"The following step demonstrates a query run against that file. "
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from fasp.runner import FASPRunner\n",
"\n",
"# The implementations we're using\n",
"from fasp.workflow import DNAStackWESClient\n",
"from fasp.loc import anvilDRSClient\n",
"from fasp.search import Gen3ManifestClient\n",
"\n",
"faspRunner = FASPRunner(program='GTEXExample')\n",
"\n",
"# Step 1 - Discovery\n",
"# query for relevant DRS objects\n",
"searchClient = Gen3ManifestClient('../fasp/data/gtex/gtex-cram-manifest.json')\n",
"res = searchClient.runQuery(3)\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'access_methods': [{'access_id': 'gs',\n",
" 'access_url': {'url': 'gs://fc-secure-ff8156a3-ddf3-42e4-9211-0fd89da62108/GTEx_Analysis_2017-06-05_v8_WGS_CRAM_files/GTEX-1B98T-0004-SM-7J38T.cram'},\n",
" 'region': '',\n",
" 'type': 'gs'},\n",
" {'access_id': 's3',\n",
" 'access_url': {'url': 's3://AnVIL/GTEx_Analysis_2017-06-05_v8_WGS_CRAM_files/GTEX-1B98T-0004-SM-7J38T.cram'},\n",
" 'region': '',\n",
" 'type': 's3'}],\n",
" 'aliases': [],\n",
" 'checksums': [{'checksum': 'cfd2f4cde4aa3e0cf9f726f0c1255fcd',\n",
" 'type': 'md5'}],\n",
" 'contents': [],\n",
" 'created_time': '2020-07-08T18:53:27.860156',\n",
" 'description': None,\n",
" 'form': 'object',\n",
" 'id': 'dg.ANV0/ed9ac9ae-02da-4e97-93da-ad86aa77d227',\n",
" 'mime_type': 'application/json',\n",
" 'name': 'GTEX-1B98T-0004-SM-7J38T.cram',\n",
" 'self_uri': 'drs://gen3.theanvil.io/dg.ANV0/ed9ac9ae-02da-4e97-93da-ad86aa77d227',\n",
" 'size': 38379493977,\n",
" 'updated_time': '2020-07-08T18:53:27.860163',\n",
" 'version': '64acd5a6'}"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"drsClient = anvilDRSClient('~/.keys/anvil_credentials.json', access_id='gs')\n",
"drsClient.getObject(res[2][1])"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"url = drsClient.getAccessURL(res[2][1])"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Running query\n",
"3\n",
"subject=GTEX-1GTWX-0001-SM-7J3A5.cram, drsID=dg.ANV0/76bb893d-12da-41ca-8828-ff89551d3e15\n",
"workflow submitted, run:2f73492e-d109-4e1a-b2be-9950deae9890\n",
"subject=GTEX-14PQA-0003-SM-7DLH4.cram, drsID=dg.ANV0/66352de8-4b50-4cae-881d-b76d03df5ac8\n",
"workflow submitted, run:6c63ef08-e61b-43a8-ab07-7975a98bdbb8\n",
"subject=GTEX-1B98T-0004-SM-7J38T.cram, drsID=dg.ANV0/ed9ac9ae-02da-4e97-93da-ad86aa77d227\n",
"workflow submitted, run:1d764abd-5c8f-4c89-ad2b-26a43b2025f1\n"
]
}
],
"source": [
"settings = faspRunner.settings\n",
"wesClient = DNAStackWESClient('~/.keys/dnastack_wes_credentials.json')\n",
"\n",
"faspRunner.configure(searchClient, drsClient, wesClient)\n",
"\n",
"runList = faspRunner.runQuery(3, 'Anvil GTEX DRS to DNAStack WES')"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2f73492e-d109-4e1a-b2be-9950deae9890 RUNNING\n",
"6c63ef08-e61b-43a8-ab07-7975a98bdbb8 RUNNING\n",
"1d764abd-5c8f-4c89-ad2b-26a43b2025f1 RUNNING\n"
]
}
],
"source": [
"for run in runList:\n",
" print(run['run_id'], wesClient.getTaskStatus(run['run_id']))"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[{'subject': 'GTEX-1GTWX-0001-SM-7J3A5.cram', 'run_id': '2f73492e-d109-4e1a-b2be-9950deae9890'}, {'subject': 'GTEX-14PQA-0003-SM-7DLH4.cram', 'run_id': '6c63ef08-e61b-43a8-ab07-7975a98bdbb8'}, {'subject': 'GTEX-1B98T-0004-SM-7J38T.cram', 'run_id': '1d764abd-5c8f-4c89-ad2b-26a43b2025f1'}]\n"
]
}
],
"source": [
"print (runList)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
26 changes: 14 additions & 12 deletions notebooks/wes/DNAStackWESTour.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -33,7 +33,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 11,
"metadata": {},
"outputs": [
{
Expand All @@ -49,7 +49,8 @@
"source": [
"from fasp.workflow import DNAStackWESClient\n",
"wesClient = DNAStackWESClient('~/.keys/dnastack_wes_credentials.json')\n",
"getMinimalRunLog('523abb68-44bd-4040-b7b0-bfc2164f8917')"
"run_id = '523abb68-44bd-4040-b7b0-bfc2164f8917'\n",
"getMinimalRunLog(wesClient, run_id)"
]
},
{
Expand All @@ -61,7 +62,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 8,
"metadata": {},
"outputs": [
{
Expand All @@ -76,6 +77,7 @@
}
],
"source": [
"rundetails = wesClient.GetRunLog(run_id)\n",
"log = rundetails['task_logs'][0]\n",
"for stdx in ['stdout','stderr']:\n",
" print('{} is at {}\\n'.format(stdx, log[stdx]))\n"
Expand All @@ -96,16 +98,16 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'0fcdbc2e-9990-4d7c-916a-41d363985aeb'"
"'eaf4ff6a-e229-47b9-9e4c-558dbb2c16be'"
]
},
"execution_count": 3,
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -116,21 +118,21 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0fcdbc2e-9990-4d7c-916a-41d363985aeb\n",
"COMPLETE\n",
"{'gwas.logistic': 'gs://workspaces-cromwell-execution/gwas/0fcdbc2e-9990-4d7c-916a-41d363985aeb/call-run_gwas/CCDG_13607_B01_GRM_WGS_2019-02-19_chr21.recalibrated_variants.assoc.logistic', 'gwas.manhattan_plot': 'gs://workspaces-cromwell-execution/gwas/0fcdbc2e-9990-4d7c-916a-41d363985aeb/call-create_plot/CCDG_13607_B01_GRM_WGS_2019-02-19_chr21.recalibrated_variants.png'}\n"
"eaf4ff6a-e229-47b9-9e4c-558dbb2c16be\n",
"RUNNING\n",
"{}\n"
]
}
],
"source": [
"getMinimalRunLog(wesClient, '0fcdbc2e-9990-4d7c-916a-41d363985aeb')"
"getMinimalRunLog(wesClient, 'eaf4ff6a-e229-47b9-9e4c-558dbb2c16be')"
]
},
{
Expand Down

0 comments on commit 63f1030

Please sign in to comment.