dimedbpy provides a quick and easy way to interact with the DIMEdb web service through Python. It provides metabolite queries by name, structure, and isotope information.
DIMEpy requires Python 3+ and is unfortunately not compatible with Python 2. If you are still using Python 2, a clever workaround is to install Python 3 and use that instead.
You can install it through pypi using pip:
pip install dimedbpy
If you want the 'bleeding edge' version, you can also install directly from this repository using git - but beware of dragons:
pip install git+https://www.github.com/AberystwythSystemsBiology/dimedbpy
Here's a quick example, showing how to retrieve metabolites by name. Note that name
is the namespace and Sucrose
is the search value:
from dimedbpy import get_metabolites
metabolites = get_metabolites("name", "Sucrose")
for metabolite in metabolites:
print(metabolite.name)
The following namespaces are supported:
Namespace | API Translation | Descripton | Example |
---|---|---|---|
inchikey |
"Identification Information.Name" |
Compiled InChIKey | CZMRCDWAGMRECN-UGDNZRGBSA-N |
name |
"Identification Information.Name" |
Common name | Sucrose |
molecular_formula |
"Identification Information.Molecular Formula" |
Textual description of elemental composition | C12H22O11 |
smiles |
"Identification Information.SMILES" |
Isometric SMILES | Too long. |
inchi |
"Identification Information.InChI" |
Unique InChI identifier | Too long. |
kegg |
"External Sources.KEGG Compound" |
KEGG Compound Identifier | C00089 |
pubchem |
"External Sources.PubChem" |
PubChem Identifier | 5988 |
cas |
"External Sources.CAS" |
CAS Registry Number | 57-50-1 |
hmdb |
"External Sources.HMDB Accession" |
HMDB Accession Number | HMDB00258 |
chemspider |
"External Sources.Chemspider" |
Chemspider Identifier | 5768 |
biocyc |
"External Sources.BioCyc" |
Bio/MetaCyc Identifier | SUCROSE |
chebi |
"External Sources.ChEBI" |
ChEBI Identifier | 17992 |
You can search for metabolites easily through the mass_search
method.
Here's a simplified example:
import dimedbpy
metabolites = = dimedbpy.mass_search(
mass=420.69,
polarity="positive",
tolerance=0.25,
isotopic_distributions=[
"[M-H]1-", "[M+Cl]1-", "[M+Br]1-"
]
)
This is pretty self-explanatory.
There's a as_dataframe
parameter you can use to output it as a pandas dataframe.
Note: If nothing is passed to the
isotopic_distributions
parameter, then sane defaults are used (Negative: [M-H]1-, [M+Cl]1-, M+Br]1 and Positive: [M+H]1+, [M+K]1+, [M+Na]1+)
As noted previously, both the get_metabolites()
and mass_search()
methods returns a list of Metabolite
objects.
If you already know the InChIKey of the metabolite you're interested in - it is possible to instantiate a Metabolite instantly using the from_inchikey
method.
from dimedbpy import Metabolite
metabolite = Metabolite.from_inchikey("DOUMFZQKYFQNTF-WUTVXBCWSA-N")
In addition to this, For ease of access Metabolite
contains a _record
property which represents a Python dictionary that contains all of the data about the Metabolite.
Moreover, the to_dict()
class method returns a simplified dictionary representation of the aforementioned data. Through this method it is also possible to list the desired properties to obtain, for example:
from dimedbpy import Metabolite
metabolite = Metabolite.from_inchikey("DOUMFZQKYFQNTF-WUTVXBCWSA-N")
metabolite.to_dict(properties=["Name", "Synonyms", "Molecular Formula"])
Please report all bugs or feature suggestions to the issues tracker. Please do not email me directly.
We welcome all sorts of contribution, so please be as candid as you want(!)
dimedbpy is released under the terms of the permissive MIT license.