def test_two_behaviors(self): ############################################# # set up the document print('Setting up document') doc = sbol3.Document() sbol3.set_namespace('https://bbn.com/scratch/') ############################################# # Create the behavior and constraints print('Creating Constraints') a = paml.Primitive("a") b = paml.Primitive("b") # Constrain start of b to follow end of a by [10, 15] follows_constraint = pamlt.precedes(a, [10, 15], b, units=tyto.OM.hour) doc.add(a) # doc.add(follows_constraint) ######################################## # Validate and write the document print('Validating and writing time') v = doc.validate() assert not v.errors and not v.warnings, "".join( str(e) for e in doc.validate().errors)
def test_single_behavior(self): ############################################# # set up the document print('Setting up document') doc = sbol3.Document() sbol3.set_namespace('https://bbn.com/scratch/') ############################################# # Create the behavior and constraints print('Creating Constraints') a = paml.Primitive("a") # Constrain start time of a to [0, 10] start_a = pamlt.startTime(a, [0, 10], units=tyto.OM.hour) # Constrain end time of a to [10, 15] end_a = pamlt.endTime(a, [10, 15], units=tyto.OM.hour) # Constrain duration of a to [1, 5] duration_a = pamlt.duration(a, [1, 5], units=tyto.OM.hour) constraint = pamlt.And([start_a, end_a, duration_a]) time_constraints = pamlt.TimeConstraints("small_protocol_constraints", constraints=[constraint]) doc.add(a) doc.add(time_constraints) ######################################## # Validate and write the document print('Validating and writing time') v = doc.validate() assert not v.errors and not v.warnings, "".join( str(e) for e in doc.validate().errors)
def test_expressions(self): ############################################# # set up the document print('Setting up document') doc = sbol3.Document() sbol3.set_namespace('https://bbn.com/scratch/') ############################################# # Create the Expressions print('Creating Protocol') # expression e1: 60s * duration(a1) a1 = paml.Primitive("a1") d1 = uml.Duration(observation=uml.DurationObservation(event=[a1])) m1 = pamlt.TimeMeasure(expr=sbol3.Measure(60, tyto.OM.second)) e1 = uml.Expression(symbol="*", is_ordered=False, operand=[m1, d1]) #doc.add(e1) # expression lt1: e1 < e2 e2 = pamlt.TimeMeasure(expr=sbol3.Measure(120, tyto.OM.second)) lt1 = uml.Expression(symbol="<", is_ordered=True, operand=[e1, e2]) #doc.add(lt1) # c1: Not(lt1) c1 = pamlt.Not(constrained_elements=lt1) # doc.add(c1) ######################################## # Validate and write the document print('Validating and writing time') v = doc.validate() assert not v.errors and not v.warnings, "".join( str(e) for e in doc.validate().errors)
def test_two_element_library(self): ############################################# # Set up the document doc = sbol3.Document() sbol3.set_namespace('https://example.org/test') ############################################# # Create the primitives print('Making primitives for test library') p = paml.Primitive('Provision') p.description = 'Place a measured amount (mass or volume) of a specified component into a location.' p.add_input('resource', sbol3.SBOL_COMPONENT) p.add_input('destination', 'http://bioprotocols.org/paml#Location') p.add_input('amount', sbol3.OM_MEASURE) # Can be mass or volume p.add_input('dispenseVelocity', sbol3.OM_MEASURE, True) p.add_output('samples', 'http://bioprotocols.org/paml#LocatedSamples') doc.add(p) p = paml.Primitive('Transfer') p.description = 'Move a measured volume taken from a collection of source samples to a location' p.add_input('source', 'http://bioprotocols.org/paml#LocatedSamples') p.add_input('destination', 'http://bioprotocols.org/paml#Location') p.add_input('amount', sbol3.OM_MEASURE) # Must be volume p.add_input('dispenseVelocity', sbol3.OM_MEASURE, True) p.add_output('samples', 'http://bioprotocols.org/paml#LocatedSamples') doc.add(p) print('Library construction complete') ######################################## # Validate and write the document print('Validating and writing protocol') v = doc.validate() assert len(v) == 0, "".join(f'\n {e}' for e in v) temp_name = os.path.join(tempfile.gettempdir(), 'mini_library.nt') doc.write(temp_name, sbol3.SORTED_NTRIPLES) print(f'Wrote file as {temp_name}') comparison_file = os.path.join( os.path.dirname(os.path.realpath(__file__)), 'testfiles', 'mini_library.nt') print(f'Comparing against {comparison_file}') assert filecmp.cmp(temp_name, comparison_file), "Files are not identical" print('File identical with test file')
import sbol3 import paml ############################################# # Set up the document doc = sbol3.Document() LIBRARY_NAME = 'spectrophotometry' sbol3.set_namespace('https://bioprotocols.org/paml/primitives/' + LIBRARY_NAME) ############################################# # Create the primitives print('Making primitives for ' + LIBRARY_NAME) p = paml.Primitive('MeasureAbsorbance') p.description = 'Measure absorbance at a given wavelength from a set of samples' p.add_input('samples', 'http://bioprotocols.org/paml#SampleCollection') p.add_input('wavelength', sbol3.OM_MEASURE) p.add_input('numFlashes', 'http://www.w3.org/2001/XMLSchema#integer', True) p.add_output('measurements', 'http://bioprotocols.org/paml#SampleData') doc.add(p) p = paml.Primitive('MeasureFluorescence') p.description = 'Measure fluorescence intensity from a set of samples stimulated by a given wavelength, with an optional bandpass or lowpass filter' p.add_input('samples', 'http://bioprotocols.org/paml#SampleCollection') p.add_input('excitationWavelength', sbol3.OM_MEASURE) p.add_input('emissionBandpassWavelength', sbol3.OM_MEASURE, True) p.add_input( 'emissionBandpassWidth', sbol3.OM_MEASURE, True ) # measured in total range, e.g., 450nm wavelength, 50nm width = 425nm - 475nm p.add_input('emissionLowpassCutoff', sbol3.OM_MEASURE, True) # e.g., 750LP p.add_input('numFlashes', 'http://www.w3.org/2001/XMLSchema#integer', True)
import sbol3 import paml ############################################# # Set up the document doc = sbol3.Document() LIBRARY_NAME = 'liquid_handling' sbol3.set_namespace('https://bioprotocols.org/paml/primitives/' + LIBRARY_NAME) ############################################# # Create the primitives print('Making primitives for ' + LIBRARY_NAME) p = paml.Primitive('Provision') p.description = 'Place a measured amount (mass or volume) of a specified component into a location, where it may then be used in executing the protocol.' p.add_input('resource', sbol3.SBOL_COMPONENT) p.add_input( 'destination', 'http://bioprotocols.org/paml#SampleCollection' ) # TODO: change these URIs to constants on resolution of pySBOL issue #228 p.add_input('amount', sbol3.OM_MEASURE) # Can be mass or volume p.add_input('dispenseVelocity', sbol3.OM_MEASURE, True) doc.add(p) p = paml.Primitive('Dispense') p.description = 'Move a measured volume of liquid from one source sample to create samples at multiple destination locations' p.add_input('source', 'http://bioprotocols.org/paml#SampleCollection') p.add_input('destination', 'http://bioprotocols.org/paml#SampleCollection') p.add_input('amount', sbol3.OM_MEASURE) # Must be volume p.add_input('dispenseVelocity', sbol3.OM_MEASURE, True) doc.add(p)
import sbol3 import paml ############################################# # Set up the document doc = sbol3.Document() LIBRARY_NAME = 'culturing' sbol3.set_namespace('https://bioprotocols.org/paml/primitives/'+LIBRARY_NAME) ############################################# # Create the primitives print('Making primitives for '+LIBRARY_NAME) p = paml.Primitive('Transform') p.description = 'Transform competent cells.' p.add_input('host', sbol3.SBOL_COMPONENT) p.add_input('dna', sbol3.SBOL_COMPONENT) p.add_input('amount', sbol3.OM_MEASURE, True) # Can be mass or volume p.add_input('selection_medium', sbol3.SBOL_COMPONENT) p.add_output('transformants', 'http://bioprotocols.org/paml#SampleArray') doc.add(p) p = paml.Primitive('Culture') p.description = 'Inoculate and grow cells in a growth medium.' p.add_input('inoculum', sbol3.SBOL_COMPONENT) p.add_input('replicates', 'http://bioprotocols.org/uml#ValueSpecification', optional=True) p.add_input('growth_medium', sbol3.SBOL_COMPONENT) p.add_input('volume', sbol3.OM_MEASURE, True) p.add_input('duration', sbol3.OM_MEASURE) p.add_input('orbital_shake_speed', sbol3.OM_MEASURE, True) # Should be rpm
import sbol3 import paml ############################################# # Set up the document doc = sbol3.Document() LIBRARY_NAME = 'sample_arrays' sbol3.set_namespace('https://bioprotocols.org/paml/primitives/' + LIBRARY_NAME) ############################################# # Create the primitives print('Making primitives for ' + LIBRARY_NAME) p = paml.Primitive('EmptyContainer') p.description = 'Allocate a sample array with size and type based on an empty container' p.add_input('specification', sbol3.SBOL_IDENTIFIED) p.add_output('samples', 'http://bioprotocols.org/paml#SampleArray') doc.add(p) p = paml.Primitive('PlateCoordinates') p.description = 'Select only the samples with specified row/column combination from a sample collection' p.add_input('source', 'http://bioprotocols.org/paml#SampleCollection') p.add_input('coordinates', 'http://bioprotocols.org/uml#ValueSpecification') p.add_output('samples', 'http://bioprotocols.org/paml#SampleCollection') doc.add(p) p = paml.Primitive('Rows') p.description = 'Select only the samples with specified rows from a sample collection' p.add_input('source', 'http://bioprotocols.org/paml#SampleCollection') p.add_input('row', 'http://bioprotocols.org/uml#ValueSpecification') p.add_output('samples', 'http://bioprotocols.org/paml#SampleCollection')
import sbol3 import paml ############################################# # Set up the document doc = sbol3.Document() LIBRARY_NAME = 'plate_handling' sbol3.set_namespace('https://bioprotocols.org/paml/primitives/'+LIBRARY_NAME) ############################################# # Create the primitives print('Making primitives for '+LIBRARY_NAME) # Note: plate handling primitives operate on whole arrays only, not just fragments p = paml.Primitive('Cover') p.description = 'Cover a set of samples to keep materials from entering or exiting' p.add_input('location', 'http://bioprotocols.org/paml#SampleArray') p.add_input('type', 'http://www.w3.org/2001/XMLSchema#anyURI') doc.add(p) p = paml.Primitive('Seal') p.description = 'Seal a collection of samples fixing the seal using a user-selected method, in order to guarantee isolation from the external environment' p.add_input('location', 'http://bioprotocols.org/paml#SampleArray') p.add_input('type', 'http://www.w3.org/2001/XMLSchema#anyURI') # e.g., breathable vs. non-breathable doc.add(p) p = paml.Primitive('AdhesiveSeal') p.description = 'Seal a collection of samples using adhesive to fix the seal, in order to guarantee isolation from the external environment' p.add_input('location', 'http://bioprotocols.org/paml#SampleArray') p.add_input('type', 'http://www.w3.org/2001/XMLSchema#anyURI') # e.g., breathable vs. non-breathable