Accessing Consonance via http request.

Import libraries

Basic library to do POST, GET & DELETE http methods.


In [1]:
import requests
import time

Function to read parametrized json file.


In [2]:
def read_file(file_name):
    file_r = open(file_name,'r')
    return file_r.read()

Defining main server endpoint & auth header


In [3]:
endpoint = "http://172.31.19.48:8080/ga4gh/wes/v1"
get_service_info = "/service-info"
headers = {"Authorization":"Bearer 0000000000000000000"}

GET /service-info request


In [4]:
ga4gh_wes_service_info_response = requests.get(endpoint+get_service_info,headers=headers).json()

GET /service-info response


In [5]:
for element in ga4gh_wes_service_info_response:
    print "\t {}:\n\t\t{}\n".format(element, ga4gh_wes_service_info_response[element])


	 workflow_type_versions:
		{u'wdl': {u'workflow_type_version': [u'1.0']}, u'cwl': {u'workflow_type_version': [u'1.0']}}

	 supported_wes_versions:
		[u'v1.0']

	 supported_filesystem_protocols:
		[u'http', u'https', u'sftp', u's3', u'gs', u'synapse']

	 system_state_counts:
		{u'Complete': 1, u'Error': 2}

	 engine_versions:
		{u'dockstore': u'1.3.0', u'cwltool': u'1.0.20171107133715'}

	 key_values:
		{u'flavour': u'e.g. (r2.medium), instance type descriptor for AWS'}

POST /workflows

Setting up the body for the request. Contains parameter required by the schema and enforced by the system.


In [6]:
# Endpoint
post_run_workflow = "/workflows" 

# Dockstore tool id.
descriptor= "quay.io/collaboratory/dockstore-tool-bamstats:1.25-6_1.0" 

# File in local path.
params = read_file("bams.json") 

workflow_type ="cwl"
workflow_type_version="1.0"
key_values = {'flavour' : 'c4.xlarge'} # Consonance specific key value.

Content of the bams.json file


In [7]:
print params


{
  "bam_input": {
        "class": "File",
        "format": "http://edamontology.org/format_2572",
        "path": "https://s3-us-west-2.amazonaws.com/achave11-redwood-storage/consonance-outputs/rna.SRR948778.bam"
    },
    "bamstats_report": {
        "class": "File",
        "path": "/tmp/bamstats_report.zip"
    }
}


In [8]:
# Defining the body of the request.
body = {"workflow_descriptor":descriptor, "workflow_params" : params, "workflow_type": workflow_type,
        "workflow_type_version": workflow_type_version, "key_values" : key_values}

POST /workflows request


In [40]:
run_workflow_response = requests.post(endpoint+post_run_workflow,headers=headers, json=body).json()

POST /workflows response


In [41]:
for id in run_workflow_response:
    print "\t{}:\n\t\t{}".format(id, run_workflow_response[id])


	workflow_id:
		2

GET /workflows request

Define parameters


In [9]:
get_list_workflows = "/workflows"
body2 = {"page_size": 100, "page_token": 0}

In [10]:
list_workflows_response = requests.get(endpoint+get_list_workflows,headers=headers).json()

GET /workflows response


In [11]:
for elem in list_workflows_response:
    if type(list_workflows_response[elem]) == list:
        print "\t{}:".format(elem)
        for e in list_workflows_response[elem]:
            for workflow in e:
                print "\t\t{}:\t{}\n\t\t".format(workflow, e[workflow])
    else:
        print "\t{}:\n\t\t".format(elem, list_workflows_response[elem])


	next_page_token:
		
	workflows:
		workflow_id:	1
		
		state:	Queued
		
		workflow_id:	2
		
		state:	Error
		
		workflow_id:	3
		
		state:	Complete
		

GET /{workflow_id}/status request


In [12]:
workflow_id = 1 # Define id
get_workflow_status = "/workflows/{}/status".format(workflow_id) # Define endpoint

get_workflow_status_response = requests.get(endpoint+get_workflow_status, headers=headers).json()

GET /{workflow_id}/status response


In [13]:
for element in get_workflow_status_response:
    print "{}:\n\t{}".format(element, get_workflow_status_response[element])


workflow_id:
	1
state:
	Queued

GET /workflows/{workflow_id} request


In [25]:
workflow_id_log = 1 # Define id
get_workflow_log = "/workflows/{}".format(workflow_id_log) # Endpoint path

In [26]:
get_workflow_log_response = requests.get(endpoint+get_workflow_log, headers=headers).json()

GET /workflows/{workflow_id} response


In [27]:
print time.asctime()+"\n\n"
for element in get_workflow_log_response:
    print "{}:\n\t{}\n\n".format(element, get_workflow_log_response[element])


Sun Mar 18 02:25:25 2018


workflow_log:
	None


outputs:
	[{u'type': None, u'name': None, u'value': None, u'location': None}]


request:
	{u'key_values': None, u'workflow_descriptor': u'#!/usr/bin/env cwl-runner\n\nclass: CommandLineTool\nid: "BAMStats"\nlabel: "BAMStats tool"\ncwlVersion: v1.0 \ndescription: |\n    ![build_status](https://quay.io/repository/collaboratory/dockstore-tool-bamstats/status)\n    A Docker container for the BAMStats command. See the [BAMStats](http://bamstats.sourceforge.net/) website for more information.\n\ndct:creator:\n  "@id": "http://orcid.org/0000-0002-7681-6415"\n  foaf:name: Brian O\'Connor\n  foaf:mbox: "mailto:briandoconnor@gmail.com"\n\nrequirements:\n  - class: DockerRequirement\n    dockerPull: "quay.io/collaboratory/dockstore-tool-bamstats:1.25-6_1.0"\n\nhints:\n  - class: ResourceRequirement\n    coresMin: 1\n    ramMin: 4092\n    outdirMin: 512000\n    doc: "the process requires at least 4G of RAM"\n\ninputs:\n  mem_gb:\n    type: int\n    default: 4\n    doc: "The memory, in GB, for the reporting tool"\n    inputBinding:\n      position: 1\n\n  bam_input:\n    type: File\n    doc: "The BAM file used as input, it must be sorted."\n    format: "http://edamontology.org/format_2572" \n    inputBinding:\n      position: 2\n\noutputs:\n  bamstats_report:\n    type: File\n    format: "http://edamontology.org/format_3615"\n    outputBinding:\n      glob: bamstats_report.zip\n    doc: "A zip file that contains the HTML report and various graphics."\n\nbaseCommand: ["bash", "/usr/local/bin/bamstats"]\n', u'workflow_params': u'{\n  "bam_input": {\n        "class": "File",\n        "format": "http://edamontology.org/format_2572",\n        "path": "https://s3-us-west-2.amazonaws.com/achave11-redwood-storage/consonance-outputs/rna.SRR948778.bam"\n    },\n    "bamstats_report": {\n        "class": "File",\n        "path": "https://s3-us-west-2.amazonaws.com/achave11-redwood-storage/consonance-outputs/out/bamstats_report.zip"\n    }\n}\n', u'workflow_type_version': u'1.0', u'workflow_type': u'cwl'}


state:
	Queued


workflow_id:
	1


task_logs:
	[{u'name': u'cwl', u'stdout': None, u'startTime': u'2018-03-18 02:23:57.342', u'cmd': None, u'stderr': None, u'endTime': u'2018-03-18 02:23:58.457772', u'exitCode': None}]



In [32]:
get_workflow_log_response = requests.get(endpoint+get_workflow_log, headers=headers).json()

In [33]:
print time.asctime()+"\n\n"
for element in get_workflow_log_response:
    print "{}:\n\t{}\n\n".format(element, get_workflow_log_response[element])


Sun Mar 18 02:32:34 2018


workflow_log:
	None


outputs:
	[{u'type': None, u'name': None, u'value': None, u'location': None}]


request:
	{u'key_values': None, u'workflow_descriptor': u'#!/usr/bin/env cwl-runner\n\nclass: CommandLineTool\nid: "BAMStats"\nlabel: "BAMStats tool"\ncwlVersion: v1.0 \ndescription: |\n    ![build_status](https://quay.io/repository/collaboratory/dockstore-tool-bamstats/status)\n    A Docker container for the BAMStats command. See the [BAMStats](http://bamstats.sourceforge.net/) website for more information.\n\ndct:creator:\n  "@id": "http://orcid.org/0000-0002-7681-6415"\n  foaf:name: Brian O\'Connor\n  foaf:mbox: "mailto:briandoconnor@gmail.com"\n\nrequirements:\n  - class: DockerRequirement\n    dockerPull: "quay.io/collaboratory/dockstore-tool-bamstats:1.25-6_1.0"\n\nhints:\n  - class: ResourceRequirement\n    coresMin: 1\n    ramMin: 4092\n    outdirMin: 512000\n    doc: "the process requires at least 4G of RAM"\n\ninputs:\n  mem_gb:\n    type: int\n    default: 4\n    doc: "The memory, in GB, for the reporting tool"\n    inputBinding:\n      position: 1\n\n  bam_input:\n    type: File\n    doc: "The BAM file used as input, it must be sorted."\n    format: "http://edamontology.org/format_2572" \n    inputBinding:\n      position: 2\n\noutputs:\n  bamstats_report:\n    type: File\n    format: "http://edamontology.org/format_3615"\n    outputBinding:\n      glob: bamstats_report.zip\n    doc: "A zip file that contains the HTML report and various graphics."\n\nbaseCommand: ["bash", "/usr/local/bin/bamstats"]\n', u'workflow_params': u'{\n  "bam_input": {\n        "class": "File",\n        "format": "http://edamontology.org/format_2572",\n        "path": "https://s3-us-west-2.amazonaws.com/achave11-redwood-storage/consonance-outputs/rna.SRR948778.bam"\n    },\n    "bamstats_report": {\n        "class": "File",\n        "path": "https://s3-us-west-2.amazonaws.com/achave11-redwood-storage/consonance-outputs/out/bamstats_report.zip"\n    }\n}\n', u'workflow_type_version': u'1.0', u'workflow_type': u'cwl'}


state:
	Running


workflow_id:
	1


task_logs:
	[{u'name': u'cwl', u'stdout': u'', u'startTime': u'2018-03-18 02:23:57.342', u'cmd': None, u'stderr': u'', u'endTime': u'2018-03-18 02:32:33.476353', u'exitCode': None}]



In [38]:
get_workflow_log_response = requests.get(endpoint+get_workflow_log, headers=headers).json()

In [39]:
print time.asctime()+"\n\n"
for element in get_workflow_log_response:
    print "{}:\n\t{}\n\n".format(element, get_workflow_log_response[element])


Sun Mar 18 02:34:47 2018


workflow_log:
	None


outputs:
	[{u'type': None, u'name': None, u'value': None, u'location': None}]


request:
	{u'key_values': None, u'workflow_descriptor': u'#!/usr/bin/env cwl-runner\n\nclass: CommandLineTool\nid: "BAMStats"\nlabel: "BAMStats tool"\ncwlVersion: v1.0 \ndescription: |\n    ![build_status](https://quay.io/repository/collaboratory/dockstore-tool-bamstats/status)\n    A Docker container for the BAMStats command. See the [BAMStats](http://bamstats.sourceforge.net/) website for more information.\n\ndct:creator:\n  "@id": "http://orcid.org/0000-0002-7681-6415"\n  foaf:name: Brian O\'Connor\n  foaf:mbox: "mailto:briandoconnor@gmail.com"\n\nrequirements:\n  - class: DockerRequirement\n    dockerPull: "quay.io/collaboratory/dockstore-tool-bamstats:1.25-6_1.0"\n\nhints:\n  - class: ResourceRequirement\n    coresMin: 1\n    ramMin: 4092\n    outdirMin: 512000\n    doc: "the process requires at least 4G of RAM"\n\ninputs:\n  mem_gb:\n    type: int\n    default: 4\n    doc: "The memory, in GB, for the reporting tool"\n    inputBinding:\n      position: 1\n\n  bam_input:\n    type: File\n    doc: "The BAM file used as input, it must be sorted."\n    format: "http://edamontology.org/format_2572" \n    inputBinding:\n      position: 2\n\noutputs:\n  bamstats_report:\n    type: File\n    format: "http://edamontology.org/format_3615"\n    outputBinding:\n      glob: bamstats_report.zip\n    doc: "A zip file that contains the HTML report and various graphics."\n\nbaseCommand: ["bash", "/usr/local/bin/bamstats"]\n', u'workflow_params': u'{\n  "bam_input": {\n        "class": "File",\n        "format": "http://edamontology.org/format_2572",\n        "path": "https://s3-us-west-2.amazonaws.com/achave11-redwood-storage/consonance-outputs/rna.SRR948778.bam"\n    },\n    "bamstats_report": {\n        "class": "File",\n        "path": "https://s3-us-west-2.amazonaws.com/achave11-redwood-storage/consonance-outputs/out/bamstats_report.zip"\n    }\n}\n', u'workflow_type_version': u'1.0', u'workflow_type': u'cwl'}


state:
	Error


workflow_id:
	1


task_logs:
	[{u'name': u'cwl', u'stdout': u"/usr/local/bin/cwltool 1.0.20160712154127\n['docker', 'pull', 'quay.io/collaboratory/dockstore-tool-bamstats:1.25-6_1.0']\n1.25-6_1.0: Pulling from collaboratory/dockstore-tool-bamstats\n3f992ab3df53: Pulling fs layer\n0aa0bd28396f: Pulling fs layer\ndb7bb15088de: Pulling fs layer\n1b6d2bb5ddaa: Pulling fs layer\na2bc8c956e6b: Pulling fs layer\na3ed95caeb02: Pulling fs layer\n8490c37475e2: Pulling fs layer\n1cb104d5dc15: Pulling fs layer\n145feb45c0fa: Pulling fs layer\n0b48f67a56f8: Pulling fs layer\n0afaeb20bbb7: Pulling fs layer\n7da63344ae10: Pulling fs layer\na2bc8c956e6b: Waiting\na3ed95caeb02: Waiting\n8490c37475e2: Waiting\n1cb104d5dc15: Waiting\n145feb45c0fa: Waiting\n0b48f67a56f8: Waiting\n0afaeb20bbb7: Waiting\n7da63344ae10: Waiting\n1b6d2bb5ddaa: Waiting\n0aa0bd28396f: Verifying Checksum\n0aa0bd28396f: Download complete\ndb7bb15088de: Verifying Checksum\ndb7bb15088de: Download complete\n1b6d2bb5ddaa: Verifying Checksum\n1b6d2bb5ddaa: Download complete\na2bc8c956e6b: Download complete\na3ed95caeb02: Verifying Checksum\na3ed95caeb02: Download complete\n1cb104d5dc15: Download complete\n145feb45c0fa: Verifying Checksum\n145feb45c0fa: Download complete\n0b48f67a56f8: Verifying Checksum\n0b48f67a56f8: Download complete\n0afaeb20bbb7: Verifying Checksum\n0afaeb20bbb7: Download complete\n7da63344ae10: Verifying Checksum\n7da63344ae10: Download complete\n3f992ab3df53: Verifying Checksum\n3f992ab3df53: Download complete\n3f992ab3df53: Pull complete\n0aa0bd28396f: Pull complete\ndb7bb15088de: Pull complete\n1b6d2bb5ddaa: Pull complete\na2bc8c956e6b: Pull complete\na3ed95caeb02: Pull complete\n8490c37475e2: Verifying Checksum\n8490c37475e2: Download complete\n8490c37475e2: Pull complete\n1cb104d5dc15: Pull complete\n145feb45c0fa: Pull complete\n0b48f67a56f8: Pull complete\n0afaeb20bbb7: Pull complete\n7da63344ae10: Pull complete\nDigest: sha256:8472101666cda2a29be9abe8184ec2c7cae4360b75e712706921476b6b537679\nStatus: Downloaded newer image for quay.io/collaboratory/dockstore-tool-bamstats:1.25-6_1.0\n[job image-descriptor.cwl] /datastore$ docker \\\n    run \\\n    -i \\\n    --volume=/var/run/docker.sock:/var/run/docker.sock:rw \\\n    --volume=/datastore:/datastore:rw \\\n    --volume=/datastore/./datastore/launcher-70566a2b-53a5-4536-9c73-51bb145abf34/inputs/633bd5c0-e5ad-443c-8654-0842c6895fef/rna.SRR948778.bam:/var/lib/cwl/stga690dbb7-b70d-4cc2-9612-10151b3206e7/rna.SRR948778.bam:ro \\\n    --volume=/datastore/datastore/launcher-70566a2b-53a5-4536-9c73-51bb145abf34:/tmp:rw \\\n    --workdir=/datastore \\\n    --read-only=true \\\n    --user=0 \\\n    --rm \\\n    --env=TMPDIR=/datastore/datastore/launcher-70566a2b-53a5-4536-9c73-51bb145abf34 \\\n    --env=HOME=/datastore \\\n    quay.io/collaboratory/dockstore-tool-bamstats:1.25-6_1.0 \\\n    bash \\\n    /usr/local/bin/bamstats \\\n    4 \\\n    /var/lib/cwl/stga690dbb7-b70d-4cc2-9612-10151b3206e7/rna.SRR948778.bam\nTotal time: 1 minute 20 seconds\n  adding: bamstats_report.html (deflated 83%)\n  adding: bamstats_report.html.data/ (stored 0%)\n  adding: bamstats_report.html.data/chr9_Coverage_histogram.png (deflated 22%)\n  adding: bamstats_report.html.data/chr5_Coverage_histogram.png (deflated 22%)\n  adding: bamstats_report.html.data/chr16_Coverage_boxAndWhisker.png (deflated 18%)\n  adding: bamstats_report.html.data/chr2_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr17_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr10_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr2_Coverage_histogram.png (deflated 21%)\n  adding: bamstats_report.html.data/chr2_Coverage_boxAndWhisker.png (deflated 18%)\n  adding: bamstats_report.html.data/chr12_Coverage_histogram.png (deflated 21%)\n  adding: bamstats_report.html.data/chr1_Coverage_boxAndWhisker.png (deflated 18%)\n  adding: bamstats_report.html.data/chr14_Coverage_cumulativeHistogram.png (deflated 24%)\n  adding: bamstats_report.html.data/chr18_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr13_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr6_Coverage_histogram.png (deflated 22%)\n  adding: bamstats_report.html.data/chr16_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr5_Coverage_cumulativeHistogram.png (deflated 24%)\n  adding: bamstats_report.html.data/chr4_Coverage_boxAndWhisker.png (deflated 18%)\n  adding: bamstats_report.html.data/chr15_Coverage_boxAndWhisker.png (deflated 18%)\n  adding: bamstats_report.html.data/chr1_Coverage_histogram.png (deflated 20%)\n  adding: bamstats_report.html.data/chrM_Coverage_boxAndWhisker.png (deflated 14%)\n  adding: bamstats_report.html.data/chrX_Coverage.html (deflated 59%)\n  adding: bamstats_report.html.data/chr4_Coverage_histogram.png (deflated 21%)\n  adding: bamstats_report.html.data/chr11_Coverage_boxAndWhisker.png (deflated 17%)\n  adding: bamstats_report.html.data/chr13_Coverage_histogram.png (deflated 22%)\n  adding: bamstats_report.html.data/chr7_Coverage_histogram.png (deflated 21%)\n  adding: bamstats_report.html.data/chr3_Coverage.html (deflated 59%)\n  adding: bamstats_report.html.data/chr13_Coverage_cumulativeHistogram.png (deflated 25%)\n  adding: bamstats_report.html.data/chr7_Coverage_cumulativeHistogram.png (deflated 23%)\n  adding: bamstats_report.html.data/chr11_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr1_Coverage_cumulativeHistogram.png (deflated 24%)\n  adding: bamstats_report.html.data/chr11_Coverage_histogram.png (deflated 21%)\n  adding: bamstats_report.html.data/chr11_Coverage_cumulativeHistogram.png (deflated 24%)\n  adding: bamstats_report.html.data/chr13_Coverage_boxAndWhisker.png (deflated 19%)\n  adding: bamstats_report.html.data/chr1_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr7_Coverage_boxAndWhisker.png (deflated 18%)\n  adding: bamstats_report.html.data/chrM_Coverage_cumulativeHistogram.png (deflated 15%)\n  adding: bamstats_report.html.data/Coverage_boxAndWhisker.png (deflated 39%)\n  adding: bamstats_report.html.data/chr19_Coverage_histogram.png (deflated 21%)\n  adding: bamstats_report.html.data/chrM_Coverage_histogram.png (deflated 16%)\n  adding: bamstats_report.html.data/chr12_Coverage_boxAndWhisker.png (deflated 18%)\n  adding: bamstats_report.html.data/chr9_Coverage_boxAndWhisker.png (deflated 17%)\n  adding: bamstats_report.html.data/chr8_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr12_Coverage_cumulativeHistogram.png (deflated 24%)\n  adding: bamstats_report.html.data/chr16_Coverage_cumulativeHistogram.png (deflated 24%)\n  adding: bamstats_report.html.data/chr18_Coverage_cumulativeHistogram.png (deflated 24%)\n  adding: bamstats_report.html.data/chr18_Coverage_boxAndWhisker.png (deflated 17%)\n  adding: bamstats_report.html.data/chr5_Coverage_boxAndWhisker.png (deflated 17%)\n  adding: bamstats_report.html.data/chr8_Coverage_boxAndWhisker.png (deflated 18%)\n  adding: bamstats_report.html.data/chr10_Coverage_histogram.png (deflated 21%)\n  adding: bamstats_report.html.data/chrY_Coverage.html (deflated 60%)\n  adding: bamstats_report.html.data/chr14_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr14_Coverage_histogram.png (deflated 22%)\n  adding: bamstats_report.html.data/chr8_Coverage_cumulativeHistogram.png (deflated 24%)\n  adding: bamstats_report.html.data/chr19_Coverage_cumulativeHistogram.png (deflated 25%)\n  adding: bamstats_report.html.data/chr17_Coverage_cumulativeHistogram.png (deflated 23%)\n  adding: bamstats_report.html.data/chr17_Coverage_boxAndWhisker.png (deflated 17%)\n  adding: bamstats_report.html.data/chr9_Coverage_cumulativeHistogram.png (deflated 23%)\n  adding: bamstats_report.html.data/chr10_Coverage_boxAndWhisker.png (deflated 17%)\n  adding: bamstats_report.html.data/chr17_Coverage_histogram.png (deflated 20%)\n  adding: bamstats_report.html.data/chr19_Coverage_boxAndWhisker.png (deflated 18%)\n  adding: bamstats_report.html.data/chr4_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr16_Coverage_histogram.png (deflated 22%)\n  adding: bamstats_report.html.data/chr6_Coverage_boxAndWhisker.png (deflated 18%)\n  adding: bamstats_report.html.data/chr15_Coverage_cumulativeHistogram.png (deflated 24%)\n  adding: bamstats_report.html.data/chr8_Coverage_histogram.png (deflated 22%)\n  adding: bamstats_report.html.data/chr9_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr15_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr14_Coverage_boxAndWhisker.png (deflated 18%)\n  adding: bamstats_report.html.data/chr6_Coverage_cumulativeHistogram.png (deflated 24%)\n  adding: bamstats_report.html.data/chr19_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr12_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr10_Coverage_cumulativeHistogram.png (deflated 24%)\n  adding: bamstats_report.html.data/chr2_Coverage_cumulativeHistogram.png (deflated 24%)\n  adding: bamstats_report.html.data/chrM_Coverage.html (deflated 59%)\n  adding: bamstats_report.html.data/chr7_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr15_Coverage_histogram.png (deflated 22%)\n  adding: bamstats_report.html.data/chr4_Coverage_cumulativeHistogram.png (deflated 24%)\n  adding: bamstats_report.html.data/chr6_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr5_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr18_Coverage_histogram.png (deflated 22%)\nFinal process status is success", u'startTime': u'2018-03-18 02:23:57.342', u'cmd': None, u'stderr': u'no stderr', u'endTime': u'2018-03-18 02:34:37.163973', u'exitCode': None}]



In [45]:
#File in local path.
params = read_file("bams.json") 
print params
body = {"workflow_descriptor":descriptor, "workflow_params" : params, "workflow_type": workflow_type,
        "workflow_type_version": workflow_type_version, "key_values" : key_values}
run_workflow_response = requests.post(endpoint+post_run_workflow,headers=headers, json=body).json()
for id in run_workflow_response:
    print "\t{}:\n\t\t{}".format(id, run_workflow_response[id])


{
  "bam_input": {
        "class": "File",
        "format": "http://edamontology.org/format_2572",
        "path": "https://s3-us-west-2.amazonaws.com/achave11-redwood-storage/consonance-outputs/rna.SRR948778.bam"
    },
    "bamstats_report": {
        "class": "File",
        "path": "/tmp/bamstats_report.zip"
    }
}

	workflow_id:
		3

In [48]:
workflow_id_log = 3
get_workflow_log = "/workflows/{}".format(workflow_id_log)
get_workflow_log_response = requests.get(endpoint+get_workflow_log, headers=headers).json()
print time.asctime()+"\n\n"
for element in get_workflow_log_response:
    print "{}:\n\t{}\n\n".format(element, get_workflow_log_response[element])


Sun Mar 18 03:47:52 2018


workflow_log:
	None


outputs:
	[{u'type': None, u'name': None, u'value': None, u'location': None}]


request:
	{u'key_values': None, u'workflow_descriptor': u'#!/usr/bin/env cwl-runner\n\nclass: CommandLineTool\nid: "BAMStats"\nlabel: "BAMStats tool"\ncwlVersion: v1.0 \ndescription: |\n    ![build_status](https://quay.io/repository/collaboratory/dockstore-tool-bamstats/status)\n    A Docker container for the BAMStats command. See the [BAMStats](http://bamstats.sourceforge.net/) website for more information.\n\ndct:creator:\n  "@id": "http://orcid.org/0000-0002-7681-6415"\n  foaf:name: Brian O\'Connor\n  foaf:mbox: "mailto:briandoconnor@gmail.com"\n\nrequirements:\n  - class: DockerRequirement\n    dockerPull: "quay.io/collaboratory/dockstore-tool-bamstats:1.25-6_1.0"\n\nhints:\n  - class: ResourceRequirement\n    coresMin: 1\n    ramMin: 4092\n    outdirMin: 512000\n    doc: "the process requires at least 4G of RAM"\n\ninputs:\n  mem_gb:\n    type: int\n    default: 4\n    doc: "The memory, in GB, for the reporting tool"\n    inputBinding:\n      position: 1\n\n  bam_input:\n    type: File\n    doc: "The BAM file used as input, it must be sorted."\n    format: "http://edamontology.org/format_2572" \n    inputBinding:\n      position: 2\n\noutputs:\n  bamstats_report:\n    type: File\n    format: "http://edamontology.org/format_3615"\n    outputBinding:\n      glob: bamstats_report.zip\n    doc: "A zip file that contains the HTML report and various graphics."\n\nbaseCommand: ["bash", "/usr/local/bin/bamstats"]\n', u'workflow_params': u'{\n  "bam_input": {\n        "class": "File",\n        "format": "http://edamontology.org/format_2572",\n        "path": "https://s3-us-west-2.amazonaws.com/achave11-redwood-storage/consonance-outputs/rna.SRR948778.bam"\n    },\n    "bamstats_report": {\n        "class": "File",\n        "path": "/tmp/bamstats_report.zip"\n    }\n}\n', u'workflow_type_version': u'1.0', u'workflow_type': u'cwl'}


state:
	Complete


workflow_id:
	3


task_logs:
	[{u'name': u'cwl', u'stdout': u'{\n    "bamstats_report": {\n        "format": "http://edamontology.org/format_3615", \n        "checksum": "sha1$afcfb2b1b3dbf676e86e39c3d8ded5c615277e2b", \n        "basename": "bamstats_report.zip", \n        "location": "file:///datastore/./datastore/launcher-d1bdfa30-aa9b-461b-adba-a2bb9c653a0f/outputs/bamstats_report.zip", \n        "path": "/datastore/./datastore/launcher-d1bdfa30-aa9b-461b-adba-a2bb9c653a0f/outputs/bamstats_report.zip", \n        "class": "File", \n        "size": 480574\n    }\n}', u'startTime': u'2018-03-18 03:37:08.137', u'cmd': None, u'stderr': u"/usr/local/bin/cwltool 1.0.20160712154127\n['docker', 'pull', 'quay.io/collaboratory/dockstore-tool-bamstats:1.25-6_1.0']\n1.25-6_1.0: Pulling from collaboratory/dockstore-tool-bamstats\n3f992ab3df53: Pulling fs layer\n0aa0bd28396f: Pulling fs layer\ndb7bb15088de: Pulling fs layer\n1b6d2bb5ddaa: Pulling fs layer\na2bc8c956e6b: Pulling fs layer\na3ed95caeb02: Pulling fs layer\n8490c37475e2: Pulling fs layer\n1cb104d5dc15: Pulling fs layer\n145feb45c0fa: Pulling fs layer\n0b48f67a56f8: Pulling fs layer\n0afaeb20bbb7: Pulling fs layer\n7da63344ae10: Pulling fs layer\n1cb104d5dc15: Waiting\n145feb45c0fa: Waiting\n0b48f67a56f8: Waiting\n0afaeb20bbb7: Waiting\n7da63344ae10: Waiting\n1b6d2bb5ddaa: Waiting\na2bc8c956e6b: Waiting\na3ed95caeb02: Waiting\n8490c37475e2: Waiting\n0aa0bd28396f: Verifying Checksum\n0aa0bd28396f: Download complete\n1b6d2bb5ddaa: Verifying Checksum\n1b6d2bb5ddaa: Download complete\ndb7bb15088de: Verifying Checksum\ndb7bb15088de: Download complete\na2bc8c956e6b: Verifying Checksum\na2bc8c956e6b: Download complete\na3ed95caeb02: Verifying Checksum\na3ed95caeb02: Download complete\n1cb104d5dc15: Verifying Checksum\n1cb104d5dc15: Download complete\n145feb45c0fa: Verifying Checksum\n145feb45c0fa: Download complete\n0b48f67a56f8: Verifying Checksum\n0b48f67a56f8: Download complete\n0afaeb20bbb7: Download complete\n7da63344ae10: Verifying Checksum\n7da63344ae10: Download complete\n3f992ab3df53: Verifying Checksum\n3f992ab3df53: Download complete\n3f992ab3df53: Pull complete\n0aa0bd28396f: Pull complete\ndb7bb15088de: Pull complete\n1b6d2bb5ddaa: Pull complete\na2bc8c956e6b: Pull complete\na3ed95caeb02: Pull complete\n8490c37475e2: Verifying Checksum\n8490c37475e2: Download complete\n8490c37475e2: Pull complete\n1cb104d5dc15: Pull complete\n145feb45c0fa: Pull complete\n0b48f67a56f8: Pull complete\n0afaeb20bbb7: Pull complete\n7da63344ae10: Pull complete\nDigest: sha256:8472101666cda2a29be9abe8184ec2c7cae4360b75e712706921476b6b537679\nStatus: Downloaded newer image for quay.io/collaboratory/dockstore-tool-bamstats:1.25-6_1.0\n[job image-descriptor.cwl] /datastore$ docker \\\n    run \\\n    -i \\\n    --volume=/var/run/docker.sock:/var/run/docker.sock:rw \\\n    --volume=/datastore:/datastore:rw \\\n    --volume=/datastore/./datastore/launcher-d1bdfa30-aa9b-461b-adba-a2bb9c653a0f/inputs/c0111d94-544b-4235-b9c7-6b2cb0bae2b5/rna.SRR948778.bam:/var/lib/cwl/stg370a49d5-53aa-4ce7-953d-cb0fc625f6c4/rna.SRR948778.bam:ro \\\n    --volume=/datastore/datastore/launcher-d1bdfa30-aa9b-461b-adba-a2bb9c653a0f:/tmp:rw \\\n    --workdir=/datastore \\\n    --read-only=true \\\n    --user=0 \\\n    --rm \\\n    --env=TMPDIR=/datastore/datastore/launcher-d1bdfa30-aa9b-461b-adba-a2bb9c653a0f \\\n    --env=HOME=/datastore \\\n    quay.io/collaboratory/dockstore-tool-bamstats:1.25-6_1.0 \\\n    bash \\\n    /usr/local/bin/bamstats \\\n    4 \\\n    /var/lib/cwl/stg370a49d5-53aa-4ce7-953d-cb0fc625f6c4/rna.SRR948778.bam\nTotal time: 1 minute 20 seconds\n  adding: bamstats_report.html (deflated 83%)\n  adding: bamstats_report.html.data/ (stored 0%)\n  adding: bamstats_report.html.data/chr9_Coverage_histogram.png (deflated 22%)\n  adding: bamstats_report.html.data/chr5_Coverage_histogram.png (deflated 22%)\n  adding: bamstats_report.html.data/chr16_Coverage_boxAndWhisker.png (deflated 18%)\n  adding: bamstats_report.html.data/chr2_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr17_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr10_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr2_Coverage_histogram.png (deflated 21%)\n  adding: bamstats_report.html.data/chr2_Coverage_boxAndWhisker.png (deflated 18%)\n  adding: bamstats_report.html.data/chr12_Coverage_histogram.png (deflated 21%)\n  adding: bamstats_report.html.data/chr1_Coverage_boxAndWhisker.png (deflated 18%)\n  adding: bamstats_report.html.data/chr14_Coverage_cumulativeHistogram.png (deflated 24%)\n  adding: bamstats_report.html.data/chr18_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr13_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr6_Coverage_histogram.png (deflated 22%)\n  adding: bamstats_report.html.data/chr16_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr5_Coverage_cumulativeHistogram.png (deflated 24%)\n  adding: bamstats_report.html.data/chr4_Coverage_boxAndWhisker.png (deflated 18%)\n  adding: bamstats_report.html.data/chr15_Coverage_boxAndWhisker.png (deflated 18%)\n  adding: bamstats_report.html.data/chr1_Coverage_histogram.png (deflated 20%)\n  adding: bamstats_report.html.data/chrM_Coverage_boxAndWhisker.png (deflated 14%)\n  adding: bamstats_report.html.data/chrX_Coverage.html (deflated 59%)\n  adding: bamstats_report.html.data/chr4_Coverage_histogram.png (deflated 21%)\n  adding: bamstats_report.html.data/chr11_Coverage_boxAndWhisker.png (deflated 17%)\n  adding: bamstats_report.html.data/chr13_Coverage_histogram.png (deflated 22%)\n  adding: bamstats_report.html.data/chr7_Coverage_histogram.png (deflated 21%)\n  adding: bamstats_report.html.data/chr3_Coverage.html (deflated 59%)\n  adding: bamstats_report.html.data/chr13_Coverage_cumulativeHistogram.png (deflated 25%)\n  adding: bamstats_report.html.data/chr7_Coverage_cumulativeHistogram.png (deflated 23%)\n  adding: bamstats_report.html.data/chr11_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr1_Coverage_cumulativeHistogram.png (deflated 24%)\n  adding: bamstats_report.html.data/chr11_Coverage_histogram.png (deflated 21%)\n  adding: bamstats_report.html.data/chr11_Coverage_cumulativeHistogram.png (deflated 24%)\n  adding: bamstats_report.html.data/chr13_Coverage_boxAndWhisker.png (deflated 19%)\n  adding: bamstats_report.html.data/chr1_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr7_Coverage_boxAndWhisker.png (deflated 18%)\n  adding: bamstats_report.html.data/chrM_Coverage_cumulativeHistogram.png (deflated 15%)\n  adding: bamstats_report.html.data/Coverage_boxAndWhisker.png (deflated 39%)\n  adding: bamstats_report.html.data/chr19_Coverage_histogram.png (deflated 21%)\n  adding: bamstats_report.html.data/chrM_Coverage_histogram.png (deflated 16%)\n  adding: bamstats_report.html.data/chr12_Coverage_boxAndWhisker.png (deflated 18%)\n  adding: bamstats_report.html.data/chr9_Coverage_boxAndWhisker.png (deflated 17%)\n  adding: bamstats_report.html.data/chr8_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr12_Coverage_cumulativeHistogram.png (deflated 24%)\n  adding: bamstats_report.html.data/chr16_Coverage_cumulativeHistogram.png (deflated 24%)\n  adding: bamstats_report.html.data/chr18_Coverage_cumulativeHistogram.png (deflated 24%)\n  adding: bamstats_report.html.data/chr18_Coverage_boxAndWhisker.png (deflated 17%)\n  adding: bamstats_report.html.data/chr5_Coverage_boxAndWhisker.png (deflated 17%)\n  adding: bamstats_report.html.data/chr8_Coverage_boxAndWhisker.png (deflated 18%)\n  adding: bamstats_report.html.data/chr10_Coverage_histogram.png (deflated 21%)\n  adding: bamstats_report.html.data/chrY_Coverage.html (deflated 60%)\n  adding: bamstats_report.html.data/chr14_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr14_Coverage_histogram.png (deflated 22%)\n  adding: bamstats_report.html.data/chr8_Coverage_cumulativeHistogram.png (deflated 24%)\n  adding: bamstats_report.html.data/chr19_Coverage_cumulativeHistogram.png (deflated 25%)\n  adding: bamstats_report.html.data/chr17_Coverage_cumulativeHistogram.png (deflated 23%)\n  adding: bamstats_report.html.data/chr17_Coverage_boxAndWhisker.png (deflated 17%)\n  adding: bamstats_report.html.data/chr9_Coverage_cumulativeHistogram.png (deflated 23%)\n  adding: bamstats_report.html.data/chr10_Coverage_boxAndWhisker.png (deflated 17%)\n  adding: bamstats_report.html.data/chr17_Coverage_histogram.png (deflated 20%)\n  adding: bamstats_report.html.data/chr19_Coverage_boxAndWhisker.png (deflated 18%)\n  adding: bamstats_report.html.data/chr4_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr16_Coverage_histogram.png (deflated 22%)\n  adding: bamstats_report.html.data/chr6_Coverage_boxAndWhisker.png (deflated 18%)\n  adding: bamstats_report.html.data/chr15_Coverage_cumulativeHistogram.png (deflated 24%)\n  adding: bamstats_report.html.data/chr8_Coverage_histogram.png (deflated 22%)\n  adding: bamstats_report.html.data/chr9_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr15_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr14_Coverage_boxAndWhisker.png (deflated 18%)\n  adding: bamstats_report.html.data/chr6_Coverage_cumulativeHistogram.png (deflated 24%)\n  adding: bamstats_report.html.data/chr19_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr12_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr10_Coverage_cumulativeHistogram.png (deflated 24%)\n  adding: bamstats_report.html.data/chr2_Coverage_cumulativeHistogram.png (deflated 24%)\n  adding: bamstats_report.html.data/chrM_Coverage.html (deflated 59%)\n  adding: bamstats_report.html.data/chr7_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr15_Coverage_histogram.png (deflated 22%)\n  adding: bamstats_report.html.data/chr4_Coverage_cumulativeHistogram.png (deflated 24%)\n  adding: bamstats_report.html.data/chr6_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr5_Coverage.html (deflated 61%)\n  adding: bamstats_report.html.data/chr18_Coverage_histogram.png (deflated 22%)\nFinal process status is success", u'endTime': u'2018-03-18 03:47:22.142894', u'exitCode': None}]