Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPatrie committed Aug 19, 2024
1 parent 8cd83a7 commit b1f8a1c
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 12 deletions.
2 changes: 1 addition & 1 deletion bio_compose/_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.2
0.2.3
18 changes: 18 additions & 0 deletions bio_compose/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,24 @@ def run_utc_simulation(self, sbml_filepath: str, start: int, end: int, steps: in
headers = {'Content-Type': multidata.content_type}

return self._execute_request(endpoint=endpoint, headers=headers, multidata=multidata, query_params=query_params)

def generate_simularium_file(self, smoldyn_output_filepath: str, box_size: float, filename: str = None):
endpoint = self._format_endpoint(f'generate-simularium-file')

# multipart
input_fp = (smoldyn_output_filepath.split('/')[-1], open(smoldyn_output_filepath, 'rb'), 'application/octet-stream')
encoder_fields = {'uploaded_file': input_fp}
multidata = MultipartEncoder(fields=encoder_fields)

# query
query_params = {'box_size': str(box_size)}
if filename is not None:
query_params['filename'] = filename

# headers
headers = {'Content-Type': multidata.content_type}

return self._execute_request(endpoint=endpoint, headers=headers, multidata=multidata, query_params=query_params)



Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/smoldyn/modelouttxt-simulation.simularium

Large diffs are not rendered by default.

44 changes: 34 additions & 10 deletions tests/tests.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -11,7 +11,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 2,
"metadata": {},
"outputs": [
{
Expand All @@ -28,18 +28,44 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'status': 'PENDING',\n",
" 'job_id': 'files-generate-simularium-file75d8bdc8-0bca-4dd4-8983-561a178fecf4',\n",
" 'timestamp': '2024-08-19 12:49:43.291403',\n",
" 'path': 'file_uploads/files-generate-simularium-file75d8bdc8-0bca-4dd4-8983-561a178fecf4/modelout.txt',\n",
" 'filename': 'simulation',\n",
" 'box_size': 10.0,\n",
" 'translate_output': True,\n",
" 'validate_output': True,\n",
" 'agent_parameters': {}}"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"simularium_job = runner.generate_simularium_file(smoldyn_output_filepath='./fixtures/smoldyn/modelout.txt', box_size=10.0)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"smoldyn_job_id = 'simulation-execution-smoldyn5624b470-ce90-4144-849c-8da896ab1147'\n",
"\n",
"output = runner.get_output(job_id=smoldyn_job_id, download_dest='./fixtures/smoldyn')"
"simularium_job_id = simularium_job['job_id']"
]
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 5,
"metadata": {},
"outputs": [
{
Expand All @@ -48,16 +74,14 @@
"True"
]
},
"execution_count": 12,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import os\n",
"\n",
"\n",
"simularium_job_id = 'files-generate-simularium-filee58f06f8-98f3-403e-afc2-e34cb86f4151'\n",
"simularium_output = runner.get_output(job_id=simularium_job_id, download_dest='./fixtures/smoldyn')\n",
"\n",
"os.path.exists(simularium_output['results_file'])"
Expand Down

0 comments on commit b1f8a1c

Please sign in to comment.