Handle lipid names in Python.
Project description
Work with lipid names in Python
LipidHandler is a Python package build to work with common abbreviations for lipids such as CE(20:2)
or
PG(18:2/20:2)
. Those lipid names are used in publications, data reports and data analysis tools.
The main goal of LipidHandler is to parse those lipid names, provide facilities to translate them into other represantations and map them to official identifiers.
LipidHandler does not replace toolkits to work with molecules and chemical structures.
:warning: LipidHandler was built for a specific research project and is not able to solve every use case about lipid names. It overlaps with other projects such as liputils.
:warning: The developer is not an expert on lipidomics, some of the naming might not make sense from a chemistry perspective.
:mailbox: Feedback through GitHub issues is appreciated.
Getting started
Work with lipid names
The Lipid class
Parse a lipid name:
from lipidhandler import Lipid
mylipid = Lipid.parse('CE 20:2')
The Lipid
has a LipidClass
print(mylipid.lipidclass)
>>> CE
The Lipid
contains a ResidueList
which holds the Residues
.
# iterate the ResidueList
for residue in mylipid.residueslist:
print(residue.carbon_atoms)
print(residue.double_bonds)
>>> 20
>>> 0
Multiple residues and different formats are possible:
mylipid = Lipid.parse("CE(20:2/18:2)")
mylipid = Lipid.parse("CE 20:2/18:2")
mylipid = Lipid.parse("CE(20:2_18:0)")
The Reside class
Next to the core attributes (C and double bonds) the Residue
has an oxidation state, a generic
chemical modification descriptor and details on the isomer.
Oxidation state
mylipid = Lipid.parse("CE(16:1;0)")
print(mylipid.residues[0].oxidation)
>>> 0
chemical modification
mylipid = Lipid.parse("PE(O-16:1)")
print(mylipid.residues[0].modification)
>>> O-
isomer
mylipid = Lipid.parse("CE(16:1(6Z))")
print(mylipid.residues[0].zstatelist[0]
>>> 6Z
The ResidueList
has functions to aggregate over the residues:
mylipid = Lipid.parse("CE(20:2/18:2)")
print(mylipid.residuelist.sum().carbon_atoms) # the .sum() functions returns a Residue instancte
Connect to external databases
LipidHandler can query external sources to search for terms or get identifiers from external databases. Right now LipidHandler only works with SwissLipids but the underliying interface is generic and can be extended.
from lipidhandler.externalapis import SwissLipids
lipids = SwissLipids.search("CE 20:2")
for l in lipids:
print(l)
>>> CE(20:2)
The output of the .search()
function is a LipidList
which contains Lipid
instances. If you
search for more generic terms you get a list with multiple results.
from lipidhandler.externalapis import SwissLipids
lipids = SwissLipids.search("CE 20")
for l in lipids:
print(l)
>>> CE(20:1)
>>> CE(20:2)
>>> CE(20:5)
>>> CE(20:0)
>>> CE(20:4)
>>> CE(20:3)
>>> CE(20:4)
>>> CE(20:3)
You can also ask for the SwissLipds ID for a specific Lipid
instance:
from lipidhandler.externalapis import SwissLipids
mylipid = Lipid.parse("CE(20:2)")
db_xrefs = SwissLipids.get_xrefs(mylipid)
for xref in db_xrefs:
print(xref.target_db, xref.target_id)
>>> SwissLipids SLM:00050028
install
pip install lipidhandler
develop
run tests
Install project and test dependencies
pip install -r requirements.txt
pip install -r test_requirements.txt
Run test suite on sources
python -m pytest
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file lipidhandler-0.0.6.tar.gz
.
File metadata
- Download URL: lipidhandler-0.0.6.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 551d76069f3c542e17a4a51a68644f7008a1fe55aecc4a355dec30bc01189c9c |
|
MD5 | 4464ad57cf1b471bd5f8ff2717b44469 |
|
BLAKE2b-256 | 2ee4a360f3c790fdef072b646bff719cb937f829773afd2324f785066c781f0c |
File details
Details for the file lipidhandler-0.0.6-py3-none-any.whl
.
File metadata
- Download URL: lipidhandler-0.0.6-py3-none-any.whl
- Upload date:
- Size: 13.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7862e8b31a77a0e3d970dc7de6c0529e352816a0f89c6b0e13c473837a2c4431 |
|
MD5 | 48b746efb47c4ab3645894ffc21d8d34 |
|
BLAKE2b-256 | 7729c729476adda6fc99c003d8f6ac12a5b225f14625c7e4375ab583e4a03563 |