Ejemplo n.º 1
0
 def test_generate_block_serialization(self, iptg,
                                       dummy_definition_decoder):
     b1 = GenerateBlock(
         treatment=iptg,
         attribute_name='concentration',
         values=[
             Value(value=0,
                   unit=Unit(
                       reference='http://purl.obolibrary.org/obo/UO_0000064'
                   )),
             Value(value=0.25,
                   unit=Unit(
                       reference='http://purl.obolibrary.org/obo/UO_0000064'
                   )),
             Value(value=2.5,
                   unit=Unit(
                       reference='http://purl.obolibrary.org/obo/UO_0000064'
                   )),
             Value(value=25,
                   unit=Unit(
                       reference='http://purl.obolibrary.org/obo/UO_0000064'
                   )),
             Value(
                 value=250,
                 unit=Unit(
                     reference='http://purl.obolibrary.org/obo/UO_0000064'))
         ])
     b_json = json.dumps(b1, cls=BlockDefinitionEncoder)
     b2 = json.loads(b_json, cls=dummy_definition_decoder)
     assert b1 == b2
Ejemplo n.º 2
0
    def test_simple_treatment(self):
        t1 = Treatment.create_from(
            attribute=Attribute.create_from(
                name='temperature',
                value=Value(
                    value=1,
                    unit=Unit(
                        reference='http://purl.obolibrary.org/obo/UO_0000027')
                ))
        )
        assert t1.is_bound()

        t2 = Treatment.create_from(
            attribute=Attribute.create_from(
                name='temperature',
                value=Value(
                    value=1,
                    unit=Unit(
                        reference='http://purl.obolibrary.org/obo/UO_0000027')
                ))
        )
        assert t1 == t1
        assert t1 == t2
        assert t1 != {}

        assert repr(
            t1) == "AttributeTreatment(attribute=BoundAttribute(name='temperature', value=Value(value=1, unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000027'))))"
Ejemplo n.º 3
0
 def test_control_serialization(self, nand_circuit, timepoint, iptg,
                                dummy_control_decoder):
     c1 = Control(
         name='positive_gfp',
         sample=Sample(
             subject=nand_circuit,
             treatments=[
                 TreatmentReference.create_from(
                     treatment=timepoint,
                     value=Value(
                         value=18,
                         unit=Unit(
                             reference=
                             'http://purl.obolibrary.org/obo/UO_0000032'))),
                 TreatmentReference.create_from(
                     treatment=iptg,
                     value=Value(
                         value=0,
                         unit=Unit(
                             reference=
                             'http://purl.obolibrary.org/obo/UO_0000064')))
             ]))
     c_json = json.dumps(c1, cls=ControlEncoder)
     c2 = json.loads(c_json, cls=dummy_control_decoder)
     assert c1 == c2
Ejemplo n.º 4
0
    def test_generate_block(self, iptg):
        b1 = GenerateBlock(
            treatment=iptg,
            attribute_name='concentration',
            values=[
                Value(value=0,
                      unit=Unit(
                          reference='http://purl.obolibrary.org/obo/UO_0000064'
                      )),
                Value(value=0.25,
                      unit=Unit(
                          reference='http://purl.obolibrary.org/obo/UO_0000064'
                      )),
                Value(value=2.5,
                      unit=Unit(
                          reference='http://purl.obolibrary.org/obo/UO_0000064'
                      )),
                Value(value=25,
                      unit=Unit(
                          reference='http://purl.obolibrary.org/obo/UO_0000064'
                      )),
                Value(
                    value=250,
                    unit=Unit(
                        reference='http://purl.obolibrary.org/obo/UO_0000064'))
            ])
        b2 = GenerateBlock(
            treatment=iptg,
            attribute_name='concentration',
            values=[
                Value(value=0,
                      unit=Unit(
                          reference='http://purl.obolibrary.org/obo/UO_0000064'
                      )),
                Value(value=0.25,
                      unit=Unit(
                          reference='http://purl.obolibrary.org/obo/UO_0000064'
                      )),
                Value(value=2.5,
                      unit=Unit(
                          reference='http://purl.obolibrary.org/obo/UO_0000064'
                      )),
                Value(value=25,
                      unit=Unit(
                          reference='http://purl.obolibrary.org/obo/UO_0000064'
                      )),
                Value(
                    value=250,
                    unit=Unit(
                        reference='http://purl.obolibrary.org/obo/UO_0000064'))
            ])
        assert b1 == b1
        assert b1 == b2
        assert b1 != {}

        assert repr(
            b1
        ) == "GenerateBlock(treatment=EntityTreatment(entity=NamedEntity(name='IPTG', reference='https://hub.sd2e.org/user/sd2e/design/IPTG/1', attributes=[UnboundAttribute(name='concentration', unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000064'))])), attribute_name='concentration', values=[Value(value=0, unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000064')), Value(value=0.25, unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000064')), Value(value=2.5, unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000064')), Value(value=25, unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000064')), Value(value=250, unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000064'))])"
Ejemplo n.º 5
0
 def test_value(self):
     v1 = Value(
         value=37,
         unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000027'))
     v2 = Value(
         value=37,
         unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000027'))
     assert v1 == v1
     assert v1 == v2
     assert v1 != {}
     assert repr(
         v1
     ) == "Value(value=37, unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000027'))"
Ejemplo n.º 6
0
 def test_value_serialization(self):
     v1 = Value(
         value=37,
         unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000027'))
     v_json = json.dumps(v1, cls=ValueEncoder)
     v2 = json.loads(v_json, cls=ValueDecoder)
     assert v1 == v2
Ejemplo n.º 7
0
    def test_entity_attributes(self):
        concentration = Attribute.create_from(
            name='concentration',
            value=Value(
                value=0.25,
                unit=Unit(
                    reference='http://purl.obolibrary.org/obo/UO_0000064')))
        e1 = NamedEntity(name="one",
                         reference="http://one.one",
                         attributes=[concentration])
        assert e1.is_bound()

        e2 = NamedEntity(name="one",
                         reference="http://one.one",
                         attributes=[concentration])
        assert e1 == e1
        assert e1 == e2
        assert e1 != {}

        assert repr(
            e1
        ) == "NamedEntity(name='one', reference='http://one.one', attributes=[BoundAttribute(name='concentration', value=Value(value=0.25, unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000064')))])"
        assert str(
            e1
        ) == "NamedEntity(name='one', reference='http://one.one', attributes=[BoundAttribute(name='concentration', value=Value(value=0.25, unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000064')))])"
Ejemplo n.º 8
0
 def test_control(self, nand_circuit, timepoint, iptg):
     c1 = Control(
         name='positive_gfp',
         sample=Sample(
             subject=nand_circuit,
             treatments=[
                 TreatmentReference.create_from(
                     treatment=timepoint,
                     value=Value(
                         value=18,
                         unit=Unit(
                             reference=
                             'http://purl.obolibrary.org/obo/UO_0000032'))),
                 TreatmentReference.create_from(
                     treatment=iptg,
                     value=Value(
                         value=0,
                         unit=Unit(
                             reference=
                             'http://purl.obolibrary.org/obo/UO_0000064')))
             ]))
     c2 = Control(
         name='positive_gfp',
         sample=Sample(
             subject=nand_circuit,
             treatments=[
                 TreatmentReference.create_from(
                     treatment=timepoint,
                     value=Value(
                         value=18,
                         unit=Unit(
                             reference=
                             'http://purl.obolibrary.org/obo/UO_0000032'))),
                 TreatmentReference.create_from(
                     treatment=iptg,
                     value=Value(
                         value=0,
                         unit=Unit(
                             reference=
                             'http://purl.obolibrary.org/obo/UO_0000064')))
             ]))
     assert c1 == c1
     assert c1 == c2
     assert c1 != {}
     assert repr(
         c1
     ) == "Control(name='positive_gfp', sample=Sample(subject=NamedEntity(name='MG1655_NAND_Circuit', reference='https://hub.sd2e.org/user/sd2e/design/MG1655_NAND_Circuit/1'), treatments=[TreatmentValueReference(treatment=AttributeTreatment(attribute=UnboundAttribute(name='timepoint', unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000032'))), value=Value(value=18, unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000032'))), TreatmentValueReference(treatment=EntityTreatment(entity=NamedEntity(name='IPTG', reference='https://hub.sd2e.org/user/sd2e/design/IPTG/1', attributes=[UnboundAttribute(name='concentration', unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000064'))])), value=Value(value=0, unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000064')))]))"
Ejemplo n.º 9
0
 def test_bound_attribute_serialization(self):
     a1 = Attribute.create_from(
         name='temperature',
         value=Value(
             value='',
             unit=Unit(
                 reference='http://purl.obolibrary.org/obo/UO_0000027')))
     a_json = json.dumps(a1, cls=AttributeEncoder)
     a2 = json.loads(a_json, cls=AttributeDecoder)
     assert a1 == a2
Ejemplo n.º 10
0
 def test_treatment_attribute_value_reference_serialization(
         self, iptg, dummy_definition_decoder):
     r1 = TreatmentReference.create_from(
         treatment=iptg,
         value=Value(
             value=0,
             unit=Unit(
                 reference='http://purl.obolibrary.org/obo/UO_0000064')))
     r_json = json.dumps(r1, cls=BlockDefinitionEncoder)
     r2 = json.loads(r_json, cls=dummy_definition_decoder)
     assert r1 == r2
Ejemplo n.º 11
0
    def test_treatment_attribute_value_reference(self, iptg):
        r1 = TreatmentReference.create_from(
            treatment=iptg,
            value=Value(
                value=0,
                unit=Unit(
                    reference='http://purl.obolibrary.org/obo/UO_0000064')))
        r2 = TreatmentReference.create_from(
            treatment=iptg,
            value=Value(
                value=0,
                unit=Unit(
                    reference='http://purl.obolibrary.org/obo/UO_0000064')))
        assert r1 == r1
        assert r1 == r2
        assert r1 != {}

        assert repr(
            r1
        ) == "TreatmentValueReference(treatment=EntityTreatment(entity=NamedEntity(name='IPTG', reference='https://hub.sd2e.org/user/sd2e/design/IPTG/1', attributes=[UnboundAttribute(name='concentration', unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000064'))])), value=Value(value=0, unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000064')))"
Ejemplo n.º 12
0
def experiment_block(strain_block, temperature_block, condition_block,
                     timepoint):
    hour_unit = Unit(reference='http://purl.obolibrary.org/obo/UO_0000032')
    return DesignBlock(
        label='experiment',
        definition=ProductBlock(block_list=[
            ReplicateBlock(count=4,
                           block=ProductBlock(block_list=[
                               BlockReference(block=strain_block),
                               BlockReference(block=temperature_block),
                               BlockReference(block=condition_block)
                           ])),
            GenerateBlock(treatment=timepoint,
                          attribute_name='timepoint',
                          values=[
                              Value(value=5, unit=hour_unit),
                              Value(value=6.5, unit=hour_unit),
                              Value(value=8, unit=hour_unit),
                              Value(value=18, unit=hour_unit)
                          ]),
        ]))
Ejemplo n.º 13
0
 def test_entity_attribute_serialization(self):
     concentration = Attribute.create_from(
         name='concentration',
         value=Value(
             value=0.25,
             unit=Unit(
                 reference='http://purl.obolibrary.org/obo/UO_0000064')))
     e1 = NamedEntity(name="one",
                      reference="http://one.one",
                      attributes=[concentration])
     e_json = json.dumps(e1, cls=NamedEntityEncoder)
     e2 = json.loads(e_json, cls=NamedEntityDecoder)
     assert e1 == e2
Ejemplo n.º 14
0
 def test_simple_treatment_serialization(self):
     t1 = Treatment.create_from(
         attribute=Attribute.create_from(
             name='temperature',
             value=Value(
                 value=1,
                 unit=Unit(
                     reference='http://purl.obolibrary.org/obo/UO_0000027')
             ))
     )
     t_json = json.dumps(t1, cls=TreatmentEncoder)
     t2 = json.loads(t_json, cls=TreatmentDecoder)
     assert t1 == t2
Ejemplo n.º 15
0
def temperature_block():
    temperature_unit = Unit(
        reference='http://purl.obolibrary.org/obo/UO_0000027')
    media = Treatment.create_from(entity=NamedEntity(
        name="M9 Glucose CAA",
        reference="https://hub.sd2e.org/user/sd2e/design/M9_glucose_CAA/1"))
    temperature = Treatment.create_from(attribute=Attribute.create_from(
        name='temperature', value=Value(value=37.0, unit=temperature_unit)))
    return DesignBlock(label='temperature-media',
                       definition=ProductBlock(block_list=[
                           TreatmentReference(treatment=temperature),
                           TreatmentReference(treatment=media)
                       ]))
Ejemplo n.º 16
0
    def test_bound_attribute(self):
        a1 = Attribute.create_from(
            name='temperature',
            value=Value(
                value=37.2,
                unit=Unit(
                    reference='http://purl.obolibrary.org/obo/UO_0000027')))
        assert a1.is_bound()

        a2 = Attribute.create_from(
            name='temperature',
            value=Value(
                value=37.2,
                unit=Unit(
                    reference='http://purl.obolibrary.org/obo/UO_0000027')))
        assert a1 == a1
        assert a1 == a2
        assert a1 != {}

        assert repr(
            a1
        ) == "BoundAttribute(name='temperature', value=Value(value=37.2, unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000027')))"
Ejemplo n.º 17
0
 def test_sample_serialization(self, nand_circuit, timepoint, iptg,
                               dummy_sample_decoder):
     s1 = Sample(
         subject=nand_circuit,
         treatments=[
             TreatmentReference.create_from(
                 treatment=timepoint,
                 value=Value(
                     value=18,
                     unit=Unit(
                         reference=
                         'http://purl.obolibrary.org/obo/UO_0000032'))),
             TreatmentReference.create_from(
                 treatment=iptg,
                 value=Value(
                     value=0,
                     unit=Unit(
                         reference=
                         'http://purl.obolibrary.org/obo/UO_0000064')))
         ])
     s_json = json.dumps(s1, cls=SampleEncoder)
     s2 = json.loads(s_json, cls=dummy_sample_decoder)
     assert s1 == s2
Ejemplo n.º 18
0
    def test_entity_unbound_attributes(self):
        concentration = Attribute.create_from(
            name='concentration',
            value=Value(
                value=0.25,
                unit=Unit(
                    reference='http://purl.obolibrary.org/obo/UO_0000064')))
        timepoint = Attribute.create_from(
            name='timepoint',
            unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000027'))

        e1 = NamedEntity(name="one",
                         reference="http://one.one",
                         attributes=[concentration, timepoint])
        assert not e1.is_bound()
Ejemplo n.º 19
0
 def test_measurement_serialization(self, nand_circuit, timepoint, iptg,
                                    empty_landing_pads, experiment_block,
                                    dummy_measurement_decoder):
     m1 = Measurement(
         type='FLOW',
         block=BlockReference(block=experiment_block),
         controls=[
             Control(
                 name='positive_gfp',
                 sample=Sample(
                     subject=nand_circuit,
                     treatments=[
                         TreatmentReference.create_from(
                             treatment=timepoint,
                             value=Value(
                                 value=18,
                                 unit=Unit(
                                     reference=
                                     'http://purl.obolibrary.org/obo/UO_0000032'
                                 ))),
                         TreatmentReference.create_from(
                             treatment=iptg,
                             value=Value(
                                 value=0,
                                 unit=Unit(
                                     reference=
                                     'http://purl.obolibrary.org/obo/UO_0000064'
                                 )))
                     ])),
             Control(name='negative_gfp',
                     sample=Sample(subject=empty_landing_pads))
         ],
         performers=['Ginkgo'])
     m_json = json.dumps(m1, cls=MeasurementEncoder)
     m2 = json.loads(m_json, cls=dummy_measurement_decoder)
     assert m1 == m2
Ejemplo n.º 20
0
def condition_block(iptg):
    micromolar_unit = Unit(
        reference='http://purl.obolibrary.org/obo/UO_0000064')
    l_arabinose = Treatment.create_from(entity=NamedEntity(
        name='L-arabinose',
        reference='https://hub.sd2e.org/user/sd2e/design/Larabinose/1',
        attributes=[
            Attribute.create_from(name='concentration', unit=micromolar_unit)
        ]))
    return DesignBlock(
        label='conditions',
        definition=ProductBlock(block_list=[
            GenerateBlock(treatment=iptg,
                          attribute_name='concentration',
                          values=[
                              Value(value=0, unit=micromolar_unit),
                              Value(value=0.25, unit=micromolar_unit),
                              Value(value=2.5, unit=micromolar_unit),
                              Value(value=25, unit=micromolar_unit),
                              Value(value=250, unit=micromolar_unit)
                          ]),
            GenerateBlock(treatment=l_arabinose,
                          attribute_name='concentration',
                          values=[
                              Value(value=0, unit=micromolar_unit),
                              Value(value=5, unit=micromolar_unit),
                              Value(value=50, unit=micromolar_unit),
                              Value(value=500, unit=micromolar_unit),
                              Value(value=5000, unit=micromolar_unit),
                              Value(value=25000, unit=micromolar_unit)
                          ]),
        ]))
Ejemplo n.º 21
0
def temperature():
    temperature_unit = Unit(
        reference='http://purl.obolibrary.org/obo/UO_0000027')
    return Treatment.create_from(attribute=Attribute.create_from(
        name='temperature', value=Value(value=37.0, unit=temperature_unit)))
Ejemplo n.º 22
0
 def test_measurement(self, nand_circuit, iptg, timepoint,
                      empty_landing_pads, experiment_block):
     m1 = Measurement(
         type='FLOW',
         block=BlockReference(block=experiment_block),
         controls=[
             Control(
                 name='positive_gfp',
                 sample=Sample(
                     subject=nand_circuit,
                     treatments=[
                         TreatmentReference.create_from(
                             treatment=timepoint,
                             value=Value(
                                 value=18,
                                 unit=Unit(
                                     reference=
                                     'http://purl.obolibrary.org/obo/UO_0000032'
                                 ))),
                         TreatmentReference.create_from(
                             treatment=iptg,
                             value=Value(
                                 value=0,
                                 unit=Unit(
                                     reference=
                                     'http://purl.obolibrary.org/obo/UO_0000064'
                                 )))
                     ])),
             Control(name='negative_gfp',
                     sample=Sample(subject=empty_landing_pads))
         ],
         performers=['Ginkgo'])
     m2 = Measurement(
         type='FLOW',
         block=BlockReference(block=experiment_block),
         controls=[
             Control(
                 name='positive_gfp',
                 sample=Sample(
                     subject=nand_circuit,
                     treatments=[
                         TreatmentReference.create_from(
                             treatment=timepoint,
                             value=Value(
                                 value=18,
                                 unit=Unit(
                                     reference=
                                     'http://purl.obolibrary.org/obo/UO_0000032'
                                 ))),
                         TreatmentReference.create_from(
                             treatment=iptg,
                             value=Value(
                                 value=0,
                                 unit=Unit(
                                     reference=
                                     'http://purl.obolibrary.org/obo/UO_0000064'
                                 )))
                     ])),
             Control(name='negative_gfp',
                     sample=Sample(subject=empty_landing_pads))
         ],
         performers=['Ginkgo'])
     assert m1 == m1
     assert m1 == m2
     assert m1 != {}
     # TODO: figure out why this fails
     assert repr(
         m1
     ) == "Measurement(type='FLOW', block=BlockReference(block=DesignBlock(label='experiment', definition=ProductBlock(block_list=[ReplicateBlock(count=4, block=ProductBlock(block_list=[BlockReference(block=DesignBlock(label='strains', definition=SumBlock(block_list=[ProductBlock(block_list=[SubjectReference(entity=NamedEntity(name='MG1655_NAND_Circuit', reference='https://hub.sd2e.org/user/sd2e/design/MG1655_NAND_Circuit/1')), TreatmentReference(treatment=EntityTreatment(entity=NamedEntity(name='Kan', reference='https://hub.sd2e.org/user/sd2e/design/Kan/1', attributes=[UnboundAttribute(name='concentration', unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000274'))])))]), SubjectReference(entity=NamedEntity(name='MG1655_empty_landing_pads', reference='https://hub.sd2e.org/user/sd2e/design/MG1655_empty_landing_pads/1'))]))), BlockReference(block=DesignBlock(label='temperature-media', definition=ProductBlock(block_list=[TreatmentReference(treatment=AttributeTreatment(attribute=BoundAttribute(name='temperature', value=Value(value=37.0, unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000027'))))), TreatmentReference(treatment=EntityTreatment(entity=NamedEntity(name='M9 Glucose CAA', reference='https://hub.sd2e.org/user/sd2e/design/M9_glucose_CAA/1')))]))), BlockReference(block=DesignBlock(label='conditions', definition=ProductBlock(block_list=[GenerateBlock(treatment=EntityTreatment(entity=NamedEntity(name='IPTG', reference='https://hub.sd2e.org/user/sd2e/design/IPTG/1', attributes=[UnboundAttribute(name='concentration', unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000064'))])), attribute_name='concentration', values=[Value(value=0, unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000064')), Value(value=0.25, unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000064')), Value(value=2.5, unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000064')), Value(value=25, unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000064')), Value(value=250, unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000064'))]), GenerateBlock(treatment=EntityTreatment(entity=NamedEntity(name='L-arabinose', reference='https://hub.sd2e.org/user/sd2e/design/Larabinose/1', attributes=[UnboundAttribute(name='concentration', unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000064'))])), attribute_name='concentration', values=[Value(value=0, unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000064')), Value(value=5, unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000064')), Value(value=50, unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000064')), Value(value=500, unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000064')), Value(value=5000, unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000064')), Value(value=25000, unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000064'))])])))])), GenerateBlock(treatment=AttributeTreatment(attribute=UnboundAttribute(name='timepoint', unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000032'))), attribute_name='timepoint', values=[Value(value=5, unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000032')), Value(value=6.5, unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000032')), Value(value=8, unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000032')), Value(value=18, unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000032'))])]))), controls=[Control(name='positive_gfp', sample=Sample(subject=NamedEntity(name='MG1655_NAND_Circuit', reference='https://hub.sd2e.org/user/sd2e/design/MG1655_NAND_Circuit/1'), treatments=[TreatmentValueReference(treatment=AttributeTreatment(attribute=UnboundAttribute(name='timepoint', unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000032'))), value=Value(value=18, unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000032'))), TreatmentValueReference(treatment=EntityTreatment(entity=NamedEntity(name='IPTG', reference='https://hub.sd2e.org/user/sd2e/design/IPTG/1', attributes=[UnboundAttribute(name='concentration', unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000064'))])), value=Value(value=0, unit=Unit(reference='http://purl.obolibrary.org/obo/UO_0000064')))])), Control(name='negative_gfp', sample=Sample(subject=NamedEntity(name='MG1655_empty_landing_pads', reference='https://hub.sd2e.org/user/sd2e/design/MG1655_empty_landing_pads/1'), treatments=[]))], performers=['Ginkgo'])"
Ejemplo n.º 23
0
def main():
    temperature_unit = Unit(
        reference='http://purl.obolibrary.org/obo/UO_0000027')
    hour_unit = Unit(reference='http://purl.obolibrary.org/obo/UO_0000032')
    micromolar_unit = Unit(
        reference='http://purl.obolibrary.org/obo/UO_0000064')
    microgram_per_milliliter_unit = Unit(
        reference='http://purl.obolibrary.org/obo/UO_0000274')
    nand_circuit = NamedEntity(
        name="MG1655_NAND_Circuit",
        reference="https://hub.sd2e.org/user/sd2e/design/MG1655_NAND_Circuit/1"
    )
    empty_landing_pads = NamedEntity(
        name="MG1655_empty_landing_pads",
        reference="https://hub.sd2e.org/user/sd2e/design/MG1655_empty_landing_pads/1"
    )
    temperature = Treatment.create_from(
        attribute=Attribute.create_from(
            name='temperature',
            value=Value(
                value=37.0,
                unit=temperature_unit
            )))
    timepoint = Treatment.create_from(
        attribute=Attribute.create_from(
            name='timepoint',
            unit=hour_unit)
    )
    media = Treatment.create_from(
        entity=NamedEntity(
            name="M9 Glucose CAA",
            reference="https://hub.sd2e.org/user/sd2e/design/M9_glucose_CAA/1"
        ))
    iptg = Treatment.create_from(
        entity=NamedEntity(
            name='IPTG',
            reference='https://hub.sd2e.org/user/sd2e/design/IPTG/1',
            attributes=[
                Attribute.create_from(
                    name='concentration', unit=micromolar_unit)
            ])
    )
    l_arabinose = Treatment.create_from(
        entity=NamedEntity(
            name='L-arabinose',
            reference='https://hub.sd2e.org/user/sd2e/design/Larabinose/1',
            attributes=[
                Attribute.create_from(
                    name='concentration', unit=micromolar_unit)
            ])
    )
    kan = Treatment.create_from(
        entity=NamedEntity(
            name='Kan',
            reference='https://hub.sd2e.org/user/sd2e/design/Kan/1',
            attributes=[
                Attribute.create_from(
                    name='concentration', unit=microgram_per_milliliter_unit)
            ])
    )

    strain_block = DesignBlock(
        label='strains',
        definition=SumBlock(block_list=[
            ProductBlock(block_list=[
                SubjectReference(entity=nand_circuit),
                TreatmentReference(treatment=kan)
            ]),
            SubjectReference(entity=empty_landing_pads)
        ])
    )
    temperature_block = DesignBlock(
        label='temperature-media',
        definition=ProductBlock(block_list=[
            TreatmentReference(treatment=temperature),
            TreatmentReference(treatment=media)
        ])
    )
    condition_block = DesignBlock(
        label='conditions',
        definition=ProductBlock(block_list=[
            GenerateBlock(
                treatment=iptg,
                attribute_name='concentration',
                values=[
                    Value(
                        value=0,
                        unit=micromolar_unit),
                    Value(
                        value=0.25,
                        unit=micromolar_unit),
                    Value(
                        value=2.5,
                        unit=micromolar_unit),
                    Value(
                        value=25,
                        unit=micromolar_unit),
                    Value(
                        value=250,
                        unit=micromolar_unit)
                ]),
            GenerateBlock(
                treatment=l_arabinose,
                attribute_name='concentration',
                values=[
                    Value(
                        value=0,
                        unit=micromolar_unit),
                    Value(
                        value=5,
                        unit=micromolar_unit),
                    Value(
                        value=50,
                        unit=micromolar_unit),
                    Value(
                        value=500,
                        unit=micromolar_unit),
                    Value(
                        value=5000,
                        unit=micromolar_unit),
                    Value(
                        value=25000,
                        unit=micromolar_unit)
                ]),
        ])
    )
    experiment_block = DesignBlock(
        label='experiment',
        definition=ProductBlock(block_list=[
            ReplicateBlock(
                count=4,
                block=ProductBlock(block_list=[
                    BlockReference(block=strain_block),
                    BlockReference(block=temperature_block),
                    BlockReference(block=condition_block)
                ])
            ),
            GenerateBlock(
                treatment=timepoint,
                attribute_name='timepoint',
                values=[
                    Value(
                        value=5,
                        unit=hour_unit),
                    Value(
                        value=6.5,
                        unit=hour_unit),
                    Value(
                        value=8,
                        unit=hour_unit),
                    Value(
                        value=18,
                        unit=hour_unit)
                ]
            ),
        ])
    )

    flow_measurement = Measurement(
        type='FLOW',
        block=BlockReference(block=experiment_block),
        controls=[
            Control(
                name='positive_gfp',
                sample=Sample(
                    subject=nand_circuit,
                    treatments=[
                        TreatmentReference.create_from(
                            treatment=timepoint,
                            value=Value(
                                value=18,
                                unit=hour_unit)),
                        TreatmentReference.create_from(
                            treatment=iptg,
                            value=Value(
                                value=0,
                                unit=micromolar_unit))
                    ]
                )
            ),
            Control(
                name='negative_gfp',
                sample=Sample(subject=empty_landing_pads)
            )
        ],
        performers=['Ginkgo']
    )
    plate_reader_measurement = Measurement(
        type='PLATE_READER',
        block=BlockReference(block=experiment_block),
        performers=['Ginkgo']
    )
    rnaseq_measurement = Measurement(
        type='RNA_SEQ',
        block=BlockReference(block=experiment_block),
        performers=['Ginkgo']
    )
    proteomic_measurement = Measurement(
        type='PROTEOMICS',
        block=BlockReference(block=experiment_block),
        performers=['Ginkgo']
    )

    request = ExperimentalRequest(
        cp_name='NOVEL_CHASSIS',
        reference_name='NovelChassis-NAND-Ecoli-Titration',
        reference_url='https://docs.google.com/document/d/1oMC5VM3XcFn6zscxLKLUe4U-TXbBsz8H6OQwHal1h4g',
        version=Version(major=1, minor=0, patch=0),
        subjects=[
            nand_circuit,
            empty_landing_pads
        ],
        treatments=[
            iptg,
            kan,
            l_arabinose,
            media,
            temperature,
            timepoint
        ],
        designs=[
            strain_block,
            temperature_block,
            condition_block,
            experiment_block
        ],
        measurements=[
            flow_measurement,
            plate_reader_measurement,
            rnaseq_measurement,
            proteomic_measurement
        ]
    )

    with open('nc_titration_generated.json', 'w') as file:
        json.dump(request, file, cls=ExperimentEncoder, indent=2)