Attaching Metadata
In this tutorial we provide an introduction to using PubChem.jl to attach chemical properties as metadata to species defined using the Catalyst package.
Basic Syntax
We first import the basic packages we'll need:
# If not already installed, first hit "]" within a Julia REPL. Then type:
# add PubChem Catalyst
using PubChem, Catalyst
We now start by defining our species using the @species
macro from Catalyst.
@variables t
@species HCl(t)
Now we attach the chemical properties fetched from PubChem using the attach_metadata
macro.
@attach_metadata HCl
The attach_metadata
macro queries the PubChem database and attaches the appropriate chemical properties to our species. We can now retrieve the chemical properties:
chemical_properties(HCl)
Dict{Any, Any} with 7 entries:
"IUPAC_Name_Preferred" => "chlorane"
"IUPAC_Name_Traditional" => "hydrogen chloride"
"Charge" => 0
"Molecular_formula" => "ClH"
"Molecular_mass" => 35.9767
"Molecular_weight" => 36.46
"Smiles" => "Cl"
In some cases, we may wish to assign chemical properties to a species with a custom name. In such cases, we can use the IUPAC name of the species.
using PubChem, Catalyst
@variables t
@species X(t)
@attach_metadata X "H2O"
The chemical properties of H2O
have now been attached to X
.
chemical_properties(X)
Dict{Any, Any} with 7 entries:
"IUPAC_Name_Preferred" => "oxidane"
"IUPAC_Name_Traditional" => "water"
"Charge" => 0
"Molecular_formula" => "H2O"
"Molecular_mass" => 18.0106
"Molecular_weight" => 18.015
"Smiles" => "O"
Similary, we can use the CID of the species when the name of the species is complex or difficult to work with.
using PubChem, Catalyst
@variables t
@species Y(t)
@attach_metadata Y 6506 #CID of triethyl 2-hydroxypropane-1,2,3-tricarboxylate
The chemical properties of triethyl 2-hydroxypropane-1,2,3-tricarboxylate
have now been attached to Y
.
chemical_properties(Y)
Dict{Any, Any} with 7 entries:
"IUPAC_Name_Preferred" => "triethyl 2-hydroxypropane-1,2,3-tricarboxylate"
"IUPAC_Name_Traditional" => "2-hydroxypropane-1,2,3-tricarboxylic acid trieth…
"Charge" => 0
"Molecular_formula" => "C12H20O7"
"Molecular_mass" => 276.121
"Molecular_weight" => 276.28
"Smiles" => "CCOC(=O)CC(CC(=O)OCC)(C(=O)OCC)O"