Skip to content

Commit

Permalink
setup protocol harness
Browse files Browse the repository at this point in the history
  • Loading branch information
danbryce committed Oct 19, 2023
1 parent 10cea23 commit 558ebc8
Show file tree
Hide file tree
Showing 79 changed files with 4,839 additions and 4,164 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ container-ontology
.coverage
cov.xml
site/*
**/artifacts/*
2 changes: 1 addition & 1 deletion challenging-interlab-growth-curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import labop
import uml
from labop.execution_engine import ExecutionEngine
from labop.execution.execution_engine import ExecutionEngine
from labop_convert.markdown.markdown_specialization import MarkdownSpecialization

doc = sbol3.Document()
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/library.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
::: labop.data
::: labop.lab_interface
::: labop.library
::: labop.execution_engine
::: labop.execution_engine_utils
::: labop.execution.execution_engine
::: labop.execution.execution_engine_utils
::: labop.execution_context
::: uml.uml_graphviz
::: uml.utils
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,10 @@
import sys

import sbol3
from pint import Measurement
from tyto import OM

import labop
from labop.utils.harness import (
ProtocolArtifact,
ProtocolDiagram,
ProtocolExecutionDiagram,
ProtocolHarness,
ProtocolNTuples,
ProtocolSampleTrace,
ProtocolSpecialization,
)
from labop.execution.harness import ProtocolHarness, ProtocolSpecialization
from labop_convert.markdown.markdown_specialization import MarkdownSpecialization

NAMESPACE = "http://igem.org/engineering/"
Expand Down Expand Up @@ -126,38 +117,14 @@ def generate_prepare_reagents_subprotocol(doc: sbol3.Document):
import labop

solution_subprotocol = generate_solution_subprotocol(doc)

# Define buffers
ddh2o = sbol3.Component(
"ddH2O", "https://identifiers.org/pubchem.substance:24901740"
)
ddh2o.name = "Water, sterile-filtered, BioReagent, suitable for cell culture"

pbs = sbol3.Component("pbs", "https://pubchem.ncbi.nlm.nih.gov/compound/24978514")
pbs.name = "Phosphate Buffered Saline"

# Define calibrants
silica_beads = sbol3.Component(
"silica_beads",
"https://nanocym.com/wp-content/uploads/2018/07/NanoCym-All-Datasheets-.pdf",
)
silica_beads.name = "NanoCym 950 nm monodisperse silica nanoparticles"
silica_beads.description = "3e9 NanoCym microspheres" # where does this go?

fluorescein = sbol3.Component(
"fluorescein", "https://pubchem.ncbi.nlm.nih.gov/substance/329753341"
)
fluorescein.name = "Fluorescein"

cascade_blue = sbol3.Component(
"cascade_blue", "https://pubchem.ncbi.nlm.nih.gov/substance/57269662"
from labop.constants import (
cascade_blue,
ddh2o,
fluorescein,
pbs,
silica_beads,
sulforhodamine,
)
cascade_blue.name = "Cascade Blue"

sulforhodamine = sbol3.Component(
"sulforhodamine", "https://pubchem.ncbi.nlm.nih.gov/compound/139216224"
)
sulforhodamine.name = "Sulforhodamine"

doc.add(ddh2o)
doc.add(silica_beads)
Expand Down Expand Up @@ -332,8 +299,9 @@ def generate_prepare_reagents_subprotocol(doc: sbol3.Document):
return subprotocol


def generate_protocol(doc: sbol3.Document, protocol: labop.Protocol):
def generate_protocol(doc: sbol3.Document, protocol: labop.Protocol) -> labop.Protocol:
import labop
from labop.constants import ddh2o, pbs

prepare_reagents_subprotocol = generate_prepare_reagents_subprotocol(doc)
prepare_reagents = protocol.primitive_step(prepare_reagents_subprotocol)
Expand Down Expand Up @@ -561,6 +529,8 @@ def generate_protocol(doc: sbol3.Document, protocol: labop.Protocol):
samples=dilution_series1.output_pin("samples"),
amount=sbol3.Measure(100, OM.microlitre),
direction=labop.Strings.ROW_DIRECTION,
diluent=pbs,
dilution_factor=2,
)
serial_dilution1.description = "For each 100.0 microliter transfer, pipette up and down 3X to ensure the dilution is mixed homogeneously."

Expand All @@ -580,6 +550,8 @@ def generate_protocol(doc: sbol3.Document, protocol: labop.Protocol):
samples=dilution_series2.output_pin("samples"),
amount=sbol3.Measure(100, OM.microlitre),
direction=labop.Strings.ROW_DIRECTION,
diluent=pbs,
dilution_factor=2,
)
serial_dilution2.description = "For each 100.0 microliter transfer, pipette up and down 3X to ensure the dilution is mixed homogeneously."

Expand All @@ -588,6 +560,8 @@ def generate_protocol(doc: sbol3.Document, protocol: labop.Protocol):
samples=dilution_series3.output_pin("samples"),
amount=sbol3.Measure(100, OM.microlitre),
direction=labop.Strings.ROW_DIRECTION,
diluent=pbs,
dilution_factor=2,
)
serial_dilution3.description = "For each 100.0 microliter transfer, pipette up and down 3X to ensure the dilution is mixed homogeneously."

Expand All @@ -596,6 +570,8 @@ def generate_protocol(doc: sbol3.Document, protocol: labop.Protocol):
samples=dilution_series4.output_pin("samples"),
amount=sbol3.Measure(100, OM.microlitre),
direction=labop.Strings.ROW_DIRECTION,
diluent=pbs,
dilution_factor=2,
)
serial_dilution4.description = "For each 100.0 microliter transfer, pipette up and down 3X to ensure the dilution is mixed homogeneously."

Expand All @@ -604,6 +580,8 @@ def generate_protocol(doc: sbol3.Document, protocol: labop.Protocol):
samples=dilution_series5.output_pin("samples"),
amount=sbol3.Measure(100, OM.microlitre),
direction=labop.Strings.ROW_DIRECTION,
diluent=ddh2o,
dilution_factor=2,
)
serial_dilution5.description = "For each 100.0 microliter transfer, pipette up and down 3X to ensure the dilution is mixed homogeneously."

Expand All @@ -612,6 +590,8 @@ def generate_protocol(doc: sbol3.Document, protocol: labop.Protocol):
samples=dilution_series6.output_pin("samples"),
amount=sbol3.Measure(100, OM.microlitre),
direction=labop.Strings.ROW_DIRECTION,
diluent=ddh2o,
dilution_factor=2,
)
serial_dilution6.description = "For each 100.0 microliter transfer, pipette up and down 3X to ensure the dilution is mixed homogeneously."

Expand All @@ -620,6 +600,8 @@ def generate_protocol(doc: sbol3.Document, protocol: labop.Protocol):
samples=dilution_series7.output_pin("samples"),
amount=sbol3.Measure(100, OM.microlitre),
direction=labop.Strings.ROW_DIRECTION,
diluent=ddh2o,
dilution_factor=2,
)
serial_dilution7.description = "For each 100.0 microliter transfer, pipette up and down 3X to ensure the dilution is mixed homogeneously."

Expand All @@ -628,6 +610,8 @@ def generate_protocol(doc: sbol3.Document, protocol: labop.Protocol):
samples=dilution_series8.output_pin("samples"),
amount=sbol3.Measure(100, OM.microlitre),
direction=labop.Strings.ROW_DIRECTION,
diluent=ddh2o,
dilution_factor=2,
)
serial_dilution8.description = "For each 100.0 microliter transfer, pipette up and down 3X to ensure the dilution is mixed homogeneously."

Expand Down Expand Up @@ -812,12 +796,12 @@ def generate_protocol(doc: sbol3.Document, protocol: labop.Protocol):
print(f"Saving protocol [{protocol_file}].")
f.write(doc.write_string(sbol3.SORTED_NTRIPLES).strip())

return protocol, doc
return protocol


def compute_sample_trajectory(protocol, doc):
import labop
from labop.execution_engine import ExecutionEngine
from labop.execution.execution_engine import ExecutionEngine
from labop.strings import Strings
from labop_convert import DefaultBehaviorSpecialization

Expand All @@ -844,7 +828,7 @@ def compute_sample_trajectory(protocol, doc):

def generate_markdown_specialization(protocol, doc):
import labop
from labop.execution_engine import ExecutionEngine
from labop.execution.execution_engine import ExecutionEngine
from labop.strings import Strings
from labop_convert import MarkdownSpecialization

Expand Down Expand Up @@ -894,7 +878,7 @@ def generate_markdown_specialization(protocol, doc):

def generate_ecl_specialization(protocol, doc):
import labop
from labop.execution_engine import ExecutionEngine
from labop.execution.execution_engine import ExecutionEngine
from labop.strings import Strings
from labop_convert import ECLSpecialization

Expand Down Expand Up @@ -925,7 +909,7 @@ def generate_ecl_specialization(protocol, doc):
def generate_autoprotocol_specialization(protocol, doc):
blockPrint()
import labop
from labop.execution_engine import ExecutionEngine
from labop.execution.execution_engine import ExecutionEngine
from labop_convert.autoprotocol.autoprotocol_specialization import (
AutoprotocolSpecialization,
)
Expand Down Expand Up @@ -1028,7 +1012,7 @@ def generate_autoprotocol_specialization(protocol, doc):
def generate_emeraldcloud_specialization(protocol, doc, stock_solutions=None):
blockPrint()
import labop
from labop.execution_engine import ExecutionEngine
from labop.execution.execution_engine import ExecutionEngine
from labop_convert.emeraldcloud.ecl_specialization import ECLSpecialization

ecl_output = os.path.join(OUT_DIR, f"{filename}-emeraldcloud.nb")
Expand Down Expand Up @@ -1121,34 +1105,30 @@ def enablePrint():
sys.stdout = sys.__stdout__


harness = ProtocolHarness(
entry_point=generate_protocol,
artifacts=[
ProtocolNTuples(),
ProtocolDiagram(),
ProtocolExecutionDiagram(),
ProtocolSampleTrace(),
ProtocolSpecialization(specialization=MarkdownSpecialization()),
],
namespace="http://igem.org/engineering/",
protocol_name="interlab",
protocol_long_name="Multicolor fluorescence per bacterial particle calibration",
protocol_version="1.2",
protocol_description="""
Plate readers report fluorescence values in arbitrary units that vary widely from instrument to instrument. Therefore absolute fluorescence values cannot be directly compared from one instrument to another. In order to compare fluorescence output of biological devices, it is necessary to create a standard fluorescence curve. This variant of the protocol uses two replicates of three colors of dye, plus beads.
Adapted from [https://dx.doi.org/10.17504/protocols.io.bht7j6rn](https://dx.doi.org/10.17504/protocols.io.bht7j6r) and [https://dx.doi.org/10.17504/protocols.io.6zrhf56](https://dx.doi.org/10.17504/protocols.io.6zrhf56)
""",
output_dir="".join(__file__.split(".py")[0].split("/")[-1:]),
libraries=[
"liquid_handling",
"plate_handling",
"spectrophotometry",
"sample_arrays",
],
)


if __name__ == "__main__":
harness = ProtocolHarness(
entry_point=generate_protocol,
artifacts=[
ProtocolSpecialization(
specialization=MarkdownSpecialization(filename + ".md")
),
],
namespace="http://igem.org/engineering/",
protocol_name="interlab",
protocol_long_name="Multicolor fluorescence per bacterial particle calibration",
protocol_version="1.2",
protocol_description="""
Plate readers report fluorescence values in arbitrary units that vary widely from instrument to instrument. Therefore absolute fluorescence values cannot be directly compared from one instrument to another. In order to compare fluorescence output of biological devices, it is necessary to create a standard fluorescence curve. This variant of the protocol uses two replicates of three colors of dye, plus beads.
Adapted from [https://dx.doi.org/10.17504/protocols.io.bht7j6rn](https://dx.doi.org/10.17504/protocols.io.bht7j6r) and [https://dx.doi.org/10.17504/protocols.io.6zrhf56](https://dx.doi.org/10.17504/protocols.io.6zrhf56)
""",
output_dir="".join(__file__.split(".py")[0].split("/")[-1:]),
libraries=[
"liquid_handling",
"plate_handling",
"spectrophotometry",
"sample_arrays",
],
)
harness.run()
parser = argparse.ArgumentParser()
parser.add_argument(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import labop
from labop import SampleArray, SampleMask
from labop.execution_engine import ExecutionEngine
from labop.execution.execution_engine import ExecutionEngine
from labop.strings import Strings
from labop_convert.emeraldcloud.ecl_specialization import ECLSpecialization
from labop_convert.markdown.markdown_specialization import MarkdownSpecialization
Expand Down Expand Up @@ -196,6 +196,7 @@
samples=dilution_series1.output_pin("samples"),
direction=labop.Strings.COLUMN_DIRECTION,
amount=sbol3.Measure(100, OM.microlitre),
diluent=pbs,
)
serial_dilution1.description = "For each 100.0 microliter transfer, pipette up and down 3X to ensure the dilution is mixed homogeneously."

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def generate_protocol():

def compute_sample_trajectory(protocol, doc):
import labop
from labop.execution_engine import ExecutionEngine
from labop.execution.execution_engine import ExecutionEngine
from labop.strings import Strings
from labop_convert import DefaultBehaviorSpecialization

Expand All @@ -400,12 +400,11 @@ def compute_sample_trajectory(protocol, doc):

def generate_markdown_specialization(protocol, doc):
import labop
from labop.execution_engine import ExecutionEngine
from labop.execution.execution_engine import ExecutionEngine
from labop.strings import Strings
from labop_convert import MarkdownSpecialization

if REGENERATE_ARTIFACTS:

dataset_file = f"{filename}_template" # name of xlsx
md_file = filename + ".md"
else:
Expand Down Expand Up @@ -450,7 +449,7 @@ def generate_markdown_specialization(protocol, doc):

def generate_ecl_specialization(protocol, doc):
import labop
from labop.execution_engine import ExecutionEngine
from labop.execution.execution_engine import ExecutionEngine
from labop.strings import Strings
from labop_convert import ECLSpecialization

Expand Down Expand Up @@ -481,7 +480,7 @@ def generate_ecl_specialization(protocol, doc):
def generate_autoprotocol_specialization(protocol, doc):
blockPrint()
import labop
from labop.execution_engine import ExecutionEngine
from labop.execution.execution_engine import ExecutionEngine
from labop_convert.autoprotocol.autoprotocol_specialization import (
AutoprotocolSpecialization,
)
Expand Down Expand Up @@ -553,7 +552,9 @@ def generate_autoprotocol_specialization(protocol, doc):
)

ee = ExecutionEngine(
specializations=[autoprotocol_specialization], out_dir=OUT_DIR, failsafe=False
specializations=[autoprotocol_specialization],
out_dir=OUT_DIR,
failsafe=False,
)
execution = ee.execute(
protocol,
Expand Down Expand Up @@ -587,7 +588,7 @@ def generate_emeraldcloud_specialization(protocol, doc, stock_solutions=None):
blockPrint()
import labop
import uml
from labop.execution_engine import ExecutionEngine
from labop.execution.execution_engine import ExecutionEngine
from labop_convert.emeraldcloud.ecl_specialization import ECLSpecialization

ddh2o = doc.find(f"{NAMESPACE}ddH2O")
Expand Down
Loading

0 comments on commit 558ebc8

Please sign in to comment.