Creating packages#
from enviPath_python import enviPath
from enviPath_python.objects import *
On this tutorial we will create a package and try to replicate the 1[(4-chlorophenyl)phenylmethyl]piperazine (CPP) Pathway.
We start by defining the enviPath class and using https://envipath.org/ as INSTANCE_HOST. In order to create Package we need to assign a Group to it, we browse over all groups available on enviPath and return the “Anonymous” group.
eP = enviPath("https://envipath.org/")
anonymous_group = [group for group in eP.get_groups() if "Anonymous" in group.get_name()][0]
pkg = eP.create_package(
name="Test Package", group=anonymous_group,
description="This package is created as a tutorial for enviPath-python documentation!")
pkg.get_id()
'https://envipath.org/package/94e29a28-ba4e-4443-ba58-dd75a3536bbc'
The pathway in question has 3 Nodes and 2 Edges, we add all the necessary information for the nodes and edges on lists of dictionaries and then we will loop over them to add them in the correct order. When we create the Pathway, the label root_node_only=True indicates that we want to add the Pathway manually, indicating as False would trigger a Pathway prediction.
node_list = [{"smiles": "C1=CC=C(C=C1)C(C2=CC=C(C=C2)Cl)N3CCNCC3",
"name": "1[(4-chlorophenyl)phenylmethyl]piperazine", "confidence": 1},
{"smiles": "CC(=O)N1CCN(CC1)C(C2=CC=CC=C2)C3=CC=C(C=C3)Cl",
"name": "CPP_TP_M329", "confidence": 3},
{"smiles": "C1=CC=C(C=C1)C(C2=CC=C(C=C2)Cl)N3CCN(CC3)C(=O)CCC(=O)O",
"name": "CPP_TP_M387", "confidence": 3}]
edge_list = [{"smirks": "C1=CC=C(C=C1)C(C2=CC=C(C=C2)Cl)N3CCNCC3>>CC(=O)N1CCN(CC1)C(C2=CC=CC=C2)C3=CC=C(C=C3)Cl"},
{"smirks": "C1=CC=C(C=C1)C(C2=CC=C(C=C2)Cl)N3CCNCC3>>C1=CC=C(C=C1)C(C2=CC=C(C=C2)Cl)N3CCN(CC3)C(=O)CCC(=O)O"}]
pw = Pathway.create(pkg, smiles=node_list[0]["smiles"],
name=node_list[0]["name"], root_node_only=True)
for node_info in node_list:
pw.add_node(smiles=node_info["smiles"],
name=node_info["name"])
for edge_info in edge_list:
pw.add_edge(smirks=edge_info["smirks"])
Next we want to create the scenario associated with this Pathway, and to do that we have to create a list of all the relevant AdditionalInformation objects. This part might look a bit tedious, but can be easily automatized when your experimental data comes from a flat file.
[<enviPath_python.objects.AcidityAdditionalInformation at 0x71a7ed7e7760>,
<enviPath_python.objects.BiologicalTreatmentTechnologyAdditionalInformation at 0x71a7ed7e76a0>,
<enviPath_python.objects.BioreactorAdditionalInformation at 0x71a7ed7e7700>,
<enviPath_python.objects.FinalCompoundConcentrationAdditionalInformation at 0x71a7ed7e7640>,
<enviPath_python.objects.OriginalSludgeAmountAdditionalInformation at 0x71a7ed7e75e0>,
<enviPath_python.objects.InoculumSourceAdditionalInformation at 0x71a7ed7e7520>,
<enviPath_python.objects.LocationAdditionalInformation at 0x71a7ed7e7580>,
<enviPath_python.objects.PurposeOfWWTPAdditionalInformation at 0x71a7ed7e74c0>,
<enviPath_python.objects.RedoxAdditionalInformation at 0x71a7ed7e7460>,
<enviPath_python.objects.SludgeRetentionTimeAdditionalInformation at 0x71a7ed7e7400>,
<enviPath_python.objects.SolventForCompoundSolutionAdditionalInformation at 0x71a7ed7e7340>,
<enviPath_python.objects.SourceOfLiquidMatrixAdditionalInformation at 0x71a7ed7e73a0>,
<enviPath_python.objects.TemperatureAdditionalInformation at 0x71a7ed7e7280>,
<enviPath_python.objects.TSSAdditionalInformation at 0x71a7ed7e7220>,
<enviPath_python.objects.TypeOfAerationAdditionalInformation at 0x71a7ed7e72b0>,
<enviPath_python.objects.AerationTypeAdditionalInformation at 0x71a7ed7e72e0>,
<enviPath_python.objects.TypeOfAdditionAdditionalInformation at 0x71a7ee343070>]
Eventually we create a main Scenario, where all the common information will be added to and create 3 ReferringScenarioAdditionalInformation that point to the main one. This will copy all the additional information objects from the main scenario and we will only have to change the ConfidenceLevelAdditionalInformation object and append those to the corresponding node of the pathway.
main_scenario = Scenario.create(pkg, additional_information=additional_info_list)
for node_info in node_list:
node = [n for n in pw.get_nodes() if (node_info["smiles"] == n.get_smiles())][0]
ai = ConfidenceLevelAdditionalInformation()
ai.set_radioconfidence(node_info["confidence"])
referral_scenario = Scenario.create(pkg, referring_scenario_id=main_scenario.get_id(), additional_information=[])
referral_scenario.update_scenario(additional_information=[ai])
node.add_scenario(referral_scenario)
To finish and data cleaness purposes, we delete the package. If you download this notebook, you can comment the line below to see the generated pathway, but please make sure to delete the package once you are finished with this tutorial.
pkg.delete()