Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/buildcompiler/buildcompiler.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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",
Expand Down
9 changes: 5 additions & 4 deletions src/buildcompiler/robotutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
return out_zip
2 changes: 1 addition & 1 deletion src/sbol2build/robotutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down