def section2_3_6_singular_annotations(self): """Example of how to create singular annotations""" # Create a combine archive called MichaelisMenten1.omex that contains a MichaelisMenten1.sbml file combine_archive_filename = create_combine_archive( SBML_STRING, name="SingularAnnotations") # we extract the sbml from the combine archive sbml = extract_sbml_from_combine_archive(combine_archive_filename) # sbml is a list of all sbml files in archive. We know there is only 1, so get the string if len(sbml) != 1: raise ValueError( "Something is wrong - you should only have 1 sbml file in the combine archive" ) sbml = sbml[0] # create an RDF object. Its empty. rdf = RDF() rdf.set_model_uri("SingularAnnotations") # here we turn off semantic extraction to make output clearer editor = rdf.to_editor(sbml, generate_new_metaids=False, sbml_semantic_extraction=False) with editor.new_singular_annotation( ) as example_using_bqbiol_pred_and_uri_resource: example_using_bqbiol_pred_and_uri_resource.about("S") \ .predicate("bqbiol", "is") \ .resource_uri("uniprot/Q15796") with editor.new_singular_annotation( ) as example_using_bqmodel_pred_and_literal_resource: example_using_bqmodel_pred_and_literal_resource.about("MichaelisMenten") \ .predicate("bqmodel", "isDescribedBy") \ .resource_literal("Anything can go here. It is a string literal.") # recreate the combine archive fname = create_combine_archive(sbml, "SingularAnnotations", str(rdf)) return fname
def section2_3_4_personal_information(self): """Example of how to use the PersonalInformation class""" # Create a combine archive called MichaelisMenten1.omex that contains a MichaelisMenten1.sbml file combine_archive_filename = create_combine_archive( SBML_STRING, name="PersonalInformation") # we extract the sbml from the combine archive sbml = extract_sbml_from_combine_archive(combine_archive_filename) # sbml is a list of all sbml files in archive. We know there is only 1, so get the string if len(sbml) != 1: raise ValueError( "Something is wrong - you should only have 1 sbml file in the combine archive" ) sbml = sbml[0] # create an RDF object. Its empty. rdf = RDF() rdf.set_model_uri("PersonalInformation") # create an editor. Note these are the default arguments - but shown here for completeness editor = rdf.to_editor(sbml, generate_new_metaids=False, sbml_semantic_extraction=True) # Here we use a "with" block. # internally, the "with" block will always execute a piece of code before # exiting the with block. In this case, it calls "Editor.add_personal_information()" # so that the user cannot forget to do it. # Note that in C or C++, the user must remember to add a newly created annotation to the editor. with editor.new_personal_information() as information: information.add_creator("orcid:0000-0001-8254-4957") \ .add_name("Robin hood") \ .add_mbox("*****@*****.**") \ .add_account_name("stolen_goods") \ .add_account_service_homepage("https://get-your-free-stuff-here.com") fname = create_combine_archive(sbml, "PersonalInformation", str(rdf)) return fname
def section2_3_7_3_energy_diff(self): """Example of how to create EnergyDiff type composite annotations""" # Create a combine archive called MichaelisMenten1.omex that contains a MichaelisMenten1.sbml file combine_archive_filename = create_combine_archive(SBML_STRING, name="EnergyDiff") # we extract the sbml from the combine archive sbml = extract_sbml_from_combine_archive(combine_archive_filename) # sbml is a list of all sbml files in archive. We know there is only 1, so get the string if len(sbml) != 1: raise ValueError( "Something is wrong - you should only have 1 sbml file in the combine archive" ) sbml = sbml[0] # create an RDF object. Its empty. rdf = RDF() rdf.set_model_uri("EnergyDiff") # sbml semantic extraction will automatically create these physical entities for us. # here, we turn it off so we can create them manually editor = rdf.to_editor(sbml, generate_new_metaids=False, sbml_semantic_extraction=False) # OPB:OPB_00378 = chemical potential with editor.new_energy_diff() as physcial_force: physcial_force.about("S") \ .has_property("OPB:OPB_00378") \ .add_source(1.0, "EntityProperty0002") \ .add_sink(1.0, "EntityProperty0001") fname = create_combine_archive(sbml, "EnergyDiff", str(rdf)) return fname
def section2_3_4_model_level_annotations(self): """Example of how to create model level annotations""" # Create a combine archive called MichaelisMenten1.omex that contains a MichaelisMenten1.sbml file combine_archive_filename = create_combine_archive( SBML_STRING, name="ModelLevelAnnotations") # we extract the sbml from the combine archive sbml = extract_sbml_from_combine_archive(combine_archive_filename) # sbml is a list of all sbml files in archive. We know there is only 1, so get the string if len(sbml) != 1: raise ValueError( "Something is wrong - you should only have 1 sbml file in the combine archive" ) sbml = sbml[0] # create an RDF object. Its empty. rdf = RDF() rdf.set_model_uri("ModelLevelAnnotations") # create an editor. Note these are the default arguments - but shown here for completeness editor = rdf.to_editor(sbml, generate_new_metaids=False, sbml_semantic_extraction=True) editor.add_creator("orcid:0000-0001-8254-4957")\ .add_curator("orcid:0000-0001-8254-4958")\ .add_taxon("taxon/9895")\ .add_pubmed("pubmed/12334")\ .add_description("My supercool model")\ .add_date_created("18-09-2020")\ .add_parent_model("pubmed/123456") fname = create_combine_archive(sbml, "ModelLevelAnnotations", str(rdf)) return fname
<math xmlns="http://www.w3.org/1998/Math/MathML"> <apply> <times/> <ci> k2 </ci> <ci> B </ci> </apply> </math> </kineticLaw> </reaction> </listOfReactions> </model> </sbml>""" # create an empty RDF object rdf = RDF() editor = rdf.to_editor(sbml, generate_new_metaids=True) with editor.new_singular_annotation() as singular_annotation: singular_annotation \ .about('species0001') \ .predicate("bqbiol", "is") \ .resource_uri("uniprot/P01137") # In python, the singular annotation gets committed to the model # automatically after the current context manager looses scope (i.e. # at the end of the current with block). But serializing (printing) # here does so without adding to the current RDF graph. # This features makes more sense in C/C++ print(singular_annotation)
<kineticLaw> <math xmlns="http://www.w3.org/1998/Math/MathML"> <apply> <times/> <ci> k4 </ci> <ci> D </ci> </apply> </math> </kineticLaw> </reaction> </listOfReactions> </model> </sbml> """ # create an empty RDF object rdf = RDF() editor = rdf.to_editor(sbml, generate_new_metaids=True, sbml_semantic_extraction=False) # Property: Osmotic Pressure with editor.new_energy_diff() as energy_diff: energy_diff \ .about("R1", eUriType.MODEL_URI) \ .add_source(physical_entity_reference="SpeciesA", uri_type=eUriType.MODEL_URI) \ .add_sink(physical_entity_reference="SpeciesB", uri_type=eUriType.MODEL_URI) \ .has_property( property_about="k1", about_uri_type=eUriType.LOCAL_URI, is_version_of="opb:OPB_01058") print(rdf)
</reaction> <reaction id="r2" metaid="react2" reversible="false" fast="false"> <listOfReactants> <speciesReference species="Ca" stoichiometry="1" constant="true"/> <speciesReference species="A" stoichiometry="1" constant="true"/> </listOfReactants> <listOfProducts> <speciesReference species="PlasmaCa" stoichiometry="1" constant="true"/> </listOfProducts> <listOfModifiers> <modifierSpeciesReference species="Enzyme"/> </listOfModifiers> <kineticLaw> <math xmlns="http://www.w3.org/1998/Math/MathML"> <apply> <times/> <ci>k2</ci> <ci>Ca</ci> </apply> </math> </kineticLaw> </reaction> </listOfReactions> </model> </sbml>""" rdf = RDF() editor = rdf.to_editor(sbml, False) print(editor.strip_annotations())
def section2_3_7_2_physical_process(self): """Example of how to create PhysicalProcess type composite annotations""" # Create a combine archive called MichaelisMenten1.omex that contains a MichaelisMenten1.sbml file combine_archive_filename = create_combine_archive( SBML_STRING, name="PhysicalProcess") # we extract the sbml from the combine archive sbml = extract_sbml_from_combine_archive(combine_archive_filename) # sbml is a list of all sbml files in archive. We know there is only 1, so get the string if len(sbml) != 1: raise ValueError( "Something is wrong - you should only have 1 sbml file in the combine archive" ) sbml = sbml[0] # create an RDF object. Its empty. rdf = RDF() rdf.set_model_uri("PhysicalProcess") # sbml semantic extraction will automatically create these physical entities for us. # here, we turn it off so we can create them manually editor = rdf.to_editor(sbml, generate_new_metaids=False, sbml_semantic_extraction=False) # physical process composite annotations use references to physical entities. # therefore we build on the content from OmexMetaSpec1_1.section2_3_7_1_physical_entity() with editor.new_physical_entity() as substrate_entity: substrate_entity.about("S") \ .has_property("OPB:OPB_00340") \ .identity("uniprot/Q15796") \ .is_part_of("FMA:66836") \ .is_part_of("FMA:63877") with editor.new_physical_entity() as product_entity: product_entity.about("P") \ .has_property("OPB:OPB_00340") \ .identity("uniprot/smad2-p") \ .is_part_of("FMA:66836") \ .is_part_of("FMA:63877") with editor.new_physical_entity() as enzyme_entity: enzyme_entity.about("E") \ .has_property("OPB:OPB_00340") \ .identity("uniprot/P37173") \ .is_part_of("FMA:66836") \ .is_part_of("FMA:63877") with editor.new_physical_entity() as complex_entity: complex_entity.about("ES") \ .has_property("OPB:OPB_00340") \ .identity("uniprot/SmadReceptorComplex") \ .is_part_of("FMA:66836") \ .is_part_of("FMA:63877") ## optionally print out xml to look at the metaids # print(editor.get_xml()) # print(editor.get_metaids()) # We now create annotations for three reactions (physical processes) # that are simulated in the sbml model with editor.new_physical_process() as substrate_bind_enzyme: substrate_bind_enzyme.about("R1") \ .has_property("OPB:OPB_00593") \ .add_source(1.0, "EntityProperty0000") \ .add_source(1.0, "EntityProperty0003") \ .add_sink(1.0, "EntityProperty0000") \ .is_version_of() with editor.new_physical_process() as substrate_unbind_enzyme: substrate_unbind_enzyme.about("R2") \ .has_property("OPB:OPB_00593") \ .add_sink(1.0, "EntityProperty0000") \ .add_sink(1.0, "EntityProperty0003") \ .add_source(1.0, "EntityProperty0000") with editor.new_physical_process() as product_formation: product_formation.about("R3") \ .has_property("OPB:OPB_00593") \ .add_sink(1.0, "EntityProperty0002") \ .add_sink(1.0, "EntityProperty0001") \ .add_source(1.0, "EntityProperty0003") fname = create_combine_archive(sbml, "PhysicalProcess", str(rdf)) return fname
def section2_3_7_1_physical_entity(self): """Example of how to create physical entity type composite annotations""" # Create a combine archive called MichaelisMenten1.omex that contains a MichaelisMenten1.sbml file combine_archive_filename = create_combine_archive( SBML_STRING, name="PhysicalEntity") # we extract the sbml from the combine archive sbml = extract_sbml_from_combine_archive(combine_archive_filename) # sbml is a list of all sbml files in archive. We know there is only 1, so get the string if len(sbml) != 1: raise ValueError( "Something is wrong - you should only have 1 sbml file in the combine archive" ) sbml = sbml[0] # create an RDF object. Its empty. rdf = RDF() rdf.set_model_uri("PhysicalEntity") # sbml semantic extraction will automatically create these physical entities for us. # here, we turn it off so we can create them manually editor = rdf.to_editor(sbml, generate_new_metaids=False, sbml_semantic_extraction=False) # note: the syntax "fma:fma_12345" == "fma/fma_12345" # OPB:OPB_00340 = concentration of chemical # FMA:66836 = part of cytosol # FMA:63877 = fibroblast with editor.new_physical_entity() as substrate_entity: substrate_entity.about("S") \ .has_property("OPB:OPB_00340") \ .identity("uniprot/Q15796") \ .is_part_of("FMA:66836") \ .is_part_of("FMA:63877") with editor.new_physical_entity() as product_entity: product_entity.about("P") \ .has_property("OPB:OPB_00340") \ .identity("uniprot/smad2-p") \ .is_part_of("FMA:66836") \ .is_part_of("FMA:63877") with editor.new_physical_entity() as enzyme_entity: enzyme_entity.about("E") \ .has_property("OPB:OPB_00340") \ .identity("uniprot/P37173") \ .is_part_of("FMA:66836") \ .is_part_of("FMA:63877") with editor.new_physical_entity() as complex_entity: complex_entity.about("ES") \ .has_property("OPB:OPB_00340") \ .identity("uniprot/P37173") \ .is_part_of("FMA:66836") \ .is_part_of("FMA:63877") fname = create_combine_archive(sbml, "PhysicalEntity", str(rdf)) return fname
</listOfReactants> <listOfProducts> <speciesReference species="A" stoichiometry="1" constant="true"/> </listOfProducts> <kineticLaw> <math xmlns="http://www.w3.org/1998/Math/MathML"> <apply> <times/> <ci> k2 </ci> <ci> B </ci> </apply> </math> </kineticLaw> </reaction> </listOfReactions> </model> </sbml>""" # create an empty RDF object rdf = RDF() editor = rdf.to_editor(sbml, "sbml") print(editor.get_metaids()) # prints out model metaids with editor.new_singular_annotation() as singular_annotation: singular_annotation \ .about('ToyModel') \ .predicate("dc", "description") \ .resource_literal("This is a toy model for demonstration purposes") print(rdf)