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')))])"
def test_entity_attribute(self): concentration = Attribute.create_from( name='concentration', unit=Unit( reference='http://purl.obolibrary.org/obo/UO_0000064' ) ) t1 = Treatment.create_from( entity=NamedEntity( name='IPTG', reference='https://hub.sd2e.org/user/sd2e/design/IPTG/1', attributes=[ concentration ]) ) assert not t1.is_bound() t2 = Treatment.create_from( entity=NamedEntity( name='IPTG', reference='https://hub.sd2e.org/user/sd2e/design/IPTG/1', attributes=[ concentration ]) ) assert t1 == t1 assert t1 == t2 assert t1 != {} assert repr( t1) == "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'))]))"
def test_entity(self): e1 = NamedEntity(name="one", reference="http://one.one") e2 = NamedEntity(name="one", reference="http://one.one") assert e1 == e2 assert e1 != {} assert repr( e1) == "NamedEntity(name='one', reference='http://one.one')" assert str(e1) == "NamedEntity(name='one', reference='http://one.one')"
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()
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) ]), ]))
def test_entity(self): t1 = Treatment.create_from(entity=NamedEntity( name='M9 Glucose CAA', reference='https://hub.sd2e.org/user/sd2e/design/M9_glucose_CAA/1' )) assert t1.is_bound() t2 = Treatment.create_from(entity=NamedEntity( name='M9 Glucose CAA', reference='https://hub.sd2e.org/user/sd2e/design/M9_glucose_CAA/1' )) assert t1 == t1 assert t1 == t2 assert t1 != {} assert repr( t1) == "EntityTreatment(entity=NamedEntity(name='M9 Glucose CAA', reference='https://hub.sd2e.org/user/sd2e/design/M9_glucose_CAA/1'))"
def test_entity_serialization(self): t1 = Treatment.create_from(entity=NamedEntity( name='M9 Glucose CAA', reference='https://hub.sd2e.org/user/sd2e/design/M9_glucose_CAA/1' )) t_json = json.dumps(t1, cls=TreatmentEncoder) t2 = json.loads(t_json, cls=TreatmentDecoder) assert t1 == t2
def iptg(): micromolar_unit = Unit( reference='http://purl.obolibrary.org/obo/UO_0000064') return 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) ]))
def kan(): microgram_per_milliliter_unit = Unit( reference='http://purl.obolibrary.org/obo/UO_0000274') return 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) ]))
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) ]))
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
def test_entity_attribute_serialization(self): concentration = Attribute.create_from( name='concentration', unit=Unit( reference='http://purl.obolibrary.org/obo/UO_0000064') ) t1 = Treatment.create_from( entity=NamedEntity( name='IPTG', reference='https://hub.sd2e.org/user/sd2e/design/IPTG/1', attributes=[ concentration ]) ) t_json = json.dumps(t1, cls=TreatmentEncoder) t2 = json.loads(t_json, cls=TreatmentDecoder) assert t1 == t2
def main(): base_library = NamedEntity( name='NODS4 in PetconV4 B1A2', reference='https://hub.sd2e.org/user/sd2e/design/NODS40x20in0x20PetconV40x20B1A2/1' ) ladder = NamedEntity( name='Protein Design Ladder 1 PetconV4 B1A2', reference='https://hub.sd2e.org/user/sd2e/design/Protein0x20Design0x20Ladder0x2010x20PetconV40x20B1A2/1' ) library = NamedEntity( name='NODS4 with Protein Design Ladder 1 in PetconV4 B1A2', reference='https://hub.sd2e.org/user/sd2e/design/NODS40x20with0x20Protein0x20Design0x20Ladder0x2010x20in0x20PetconV40x20B1A2/1' ) request = ExperimentalRequest( cp_name='PROTEIN_DESIGN', reference_name='', reference_url='', version=Version(major=1, minor=0, patch=0), subjects=[base_library, ladder, library], treatments=[ Treatment.create_from( entity=NamedEntity( name='SDO -His -Trp -Ura', reference='https://hub.sd2e.org/user/sd2e/design/SDO0x200x2DHis0x200x2DTrp0x200x2DUra/1' ) ), Treatment.create_from( entity=NamedEntity( name='SDO + 2% Galactose -His -Trp -Ura', reference='https://hub.sd2e.org/user/sd2e/design/SDO0x200x2B0x2020x250x20Galactose0x200x2DHis0x200x2DTrp0x200x2DUra/1' ) ), Treatment.create_from( entity=NamedEntity( name='Chymotrypsin', reference='https://hub.sd2e.org/user/sd2e/design/Chymotrypsin/1' ) ), Treatment.create_from( entity=NamedEntity( name='Anti-c-myc-FITC', reference='https://hub.sd2e.org/user/sd2e/design/Anti0x2Dc0x2Dmyc0x2DFITC/1' ) ), Treatment.create_from( entity=NamedEntity( name='TBS', reference='https://hub.sd2e.org/user/sd2e/design/Tris0x20Buffered0x20Saline/1' ) ), Treatment.create_from( entity=NamedEntity( name='TBSF', reference='https://hub.sd2e.org/user/sd2e/design/Tris0x20Buffered0x20Saline0x200x2B0x2010x250x20BSA/1' ) ), Treatment.create_from( entity=NamedEntity( name='PBS', reference='https://hub.sd2e.org/user/sd2e/design/pbs/1' ) ), Treatment.create_from( entity=NamedEntity( name='PBSF', reference='https://hub.sd2e.org/user/sd2e/design/Phosphate0x20Buffered0x20Saline0x200x2B0x2010x250x20BSA/1' ) ), Treatment.create_from( entity=NamedEntity( name='Trypsin', reference='https://hub.sd2e.org/user/sd2e/design/Trypsin/1' ) ), Treatment.create_from( entity=NamedEntity( name='AMA1-best', reference='https://hub.sd2e.org/user/sd2e/design/UWBF_21171/1' ) ), Treatment.create_from( entity=NamedEntity( name='EBY100 + PETCONv3_baker', reference='https://hub.sd2e.org/user/sd2e/design/UWBF_21535/1' ))], designs=[], measurements=[] ) with open('nc_titration_generated.json', 'w') as file: json.dump(request, file, cls=ExperimentEncoder, indent=2)
def empty_landing_pads(): ref = "https://hub.sd2e.org/user/sd2e/design/MG1655_empty_landing_pads/1" return NamedEntity(name="MG1655_empty_landing_pads", reference=ref)
def nand_circuit(): return NamedEntity( name="MG1655_NAND_Circuit", reference="https://hub.sd2e.org/user/sd2e/design/MG1655_NAND_Circuit/1" )
def test_serialization(self): e1 = NamedEntity(name="one", reference="http://one.one") e_json = json.dumps(e1, cls=NamedEntityEncoder) e2 = json.loads(e_json, cls=NamedEntityDecoder) assert e1 == e2
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)