diff --git a/src/buildcompiler/buildcompiler.py b/src/buildcompiler/buildcompiler.py index 3cb05ac..c127eeb 100644 --- a/src/buildcompiler/buildcompiler.py +++ b/src/buildcompiler/buildcompiler.py @@ -1,5 +1,5 @@ import sbol2 -from typing import Union, List +from typing import Union import zipfile from .abstract_translator import translate_abstract_to_plasmids from .sbol2build import golden_gate_assembly_plan @@ -38,7 +38,10 @@ def assembly_compiler(abstract_design: Union[sbol2.Component, sbol2.Combinatoria document= document) # Generate build specifications JSON - build_specs_JSON = assembly_plan_RDF_to_JSON(assembly_plan) + assembly_plan_RDF_to_JSON( + assembly_plan, + output_path=f"{files_path}/assemblyplan_output.json", + ) # Create zip file with required files zip_file = run_opentrons_script_with_json_to_zip(opentrons_script_path= files_path + "/run_sbol2assembly_libre.py", diff --git a/src/buildcompiler/robotutils.py b/src/buildcompiler/robotutils.py index 241bbb4..cab7543 100644 --- a/src/buildcompiler/robotutils.py +++ b/src/buildcompiler/robotutils.py @@ -7,8 +7,8 @@ import zipfile from pathlib import Path -def assembly_plan_RDF_to_JSON(file): - if type(file)==sbol2.Document: +def assembly_plan_RDF_to_JSON(file, output_path: str | Path | None = None): + if isinstance(file, sbol2.Document): doc = file else: sbol2.Config.setOption('sbol_typed_uris', False) @@ -77,7 +77,8 @@ def assembly_plan_RDF_to_JSON(file): for entry in product_dicts: entry['Restriction Enzyme'] = globalEnzyme - with open('output.json', 'w') as json_file: + json_output_path = Path(output_path) if output_path is not None else Path("output.json") + with json_output_path.open('w', encoding='utf-8') as json_file: json.dump(product_dicts, json_file, indent=4) return product_dicts @@ -148,4 +149,4 @@ def run_opentrons_script_with_json_to_zip( if p.is_file(): z.write(p, arcname=p.relative_to(tmpdir)) - return out_zip \ No newline at end of file + return out_zip diff --git a/src/sbol2build/robotutils.py b/src/sbol2build/robotutils.py index d078cdc..63d19f7 100644 --- a/src/sbol2build/robotutils.py +++ b/src/sbol2build/robotutils.py @@ -2,7 +2,7 @@ import json def assembly_plan_RDF_to_JSON(file): - if type(file)==sbol2.Document: + if isinstance(file, sbol2.Document): doc = file else: sbol2.Config.setOption('sbol_typed_uris', False)