Graphein
repository·master·Indexed 22 days ago
https://github.com/a-r-j/grapheinA specialized library for generating geometric graph representations of biological structures, including proteins, RNA, and molecules, for use in deep learning workflows. It features support for AlphaFold2 data, molecular graphs from SMILES, RNA graphs from dotbracket notation, and protein mesh generation. Graphein includes integrated PyTorch Geometric dataloaders and provides worked datasets for tasks such as Protein-Protein Interaction Site Prediction (PPISP) and the Protein Structural Change Database (PSCDB).
What's inside Graphein
- Graphein is a Python library designed for constructing graph and surface-mesh representations of protein structures for computational analysis. It is built to support feature engineering in machine learning workflows by providing flexible, scalable graph construction and pre-processing tools for experimental structure files. The library is optimized for high-throughput network-based and graph-theoretic analyses of protein structures.
Overview of Graphein's graph representations
masterGraphein is a Python package designed to produce various graph-based representations of biomolecular structures. It provides compatibility with standard geometric deep learning library formats, allowing you to export graphs to:
NetworkX(nx.Graph)PyTorch Geometric(pytorch_geometric.data.Data)DGL(dgl.DGLGraph)
It also provides specialized graph objects optimized for use with popular deep learning libraries.
Overview of Graphein worked datasets
masterGraphein provides several worked examples of creating graph datasets from protein structures. These datasets are designed for various machine learning tasks, including node classification (e.g., predicting interaction sites), edge prediction (e.g., predicting bound conformations), and graph classification (e.g., predicting structural rearrangement classes).
Key dataset categories include:
- PPISP: Protein-Protein Interaction Site Prediction (node-classification).
- PSCDB: Protein Structural Change Database (edge-prediction or graph-classification).
- PROTEINS_{LIGANDS / METAL / NUCLEOTIDES / NUCLEIC}: Collections of non-redundant protein interactions sourced from ccPDB.
Construct Protein-Protein Interaction (PPI) graphs
masterThegraphein.ppimodule provides tools for constructing graphs representing Protein-Protein Interactions. You can build these graphs using high-level graph construction functions, define specific edges, and extract graph or node features. The module also supports parsing interaction data from databases like BioGrid and STRINGDB.Graphein Release History and New Features
masterGraphein has introduced several major capabilities across its versions:
- Datasets & PDB Integration: Support for FoldComp Datasets and creating datasets directly from the PDB (v1.7.0).
- Protein Tensors: A dedicated Protein Tensor Module (v1.6.0).
- AlphaFold2 Support: Ability to create protein graphs from AlphaFold2 data (v1.5.0).
- RNA & Molecular Graphs: RNA graph construction from dotbracket notation (v1.5.0) and molecular graph construction (v1.4.0).
- Deep Learning Integration: Ready-to-go Dataloaders for PyTorch Geometric (v1.3.0).
- Graph Manipulation: Extracting subgraphs from protein graphs (v1.2.0) and performing protein graph analytics (v1.2.0).
- Visualization & CLI: Interactive Plotly visualization and a dedicated CLI (v1.2.0).
- Interactomics: Support for Protein-Protein Interaction (PPI) networks using AlphaFold2 (v1.1.0).
Supported Geometric Deep Learning Libraries
masterGraphein interfaces with several popular geometric deep learning libraries to facilitate downstream machine learning tasks. Supported libraries include:
- DGL (Deep Graph Library)
- DGL-LifeSci
- PyTorch Geometric
- PyTorch3D
Define protein graph edges
masterEdges in protein graphs can be defined using several different criteria through the
graphein.protein.edgessubmodules:- Distance: Edges based on spatial proximity between atoms or residues (
graphein.protein.edges.distance). - Intramolecular: Edges representing intramolecular interactions (
graphein.protein.edges.intramolecular). - Atomic: Edges defined at the atomic level (
graphein.protein.edges.atomic).
- Distance: Edges based on spatial proximity between atoms or residues (
Install Graphein via Conda environment
masterYou can set up a complete development environment using the provided Conda YAML files. This is recommended if you need specific GPU builds (CUDA 11.1) for integrated deep learning libraries.
# For a full dev environment (includes GPU builds) git clone https://www.github.com/a-r-j/graphein cd graphein conda env create -f environment-dev.yml pip install -e . # For a lighter install git clone https://www.github.com/a-r-j/graphein cd graphein conda env create -f environment.yml pip install -e .Install Graphein for Development
masterIf you intend to contribute to Graphein or need a development environment that includes GPU builds (CUDA 11.1) for geometric deep learning libraries, use the following methods.
Pip installation:
- Dev dependencies:
pip install graphein[dev] - All dependencies:
pip install graphein[all]
Conda installation:
- Clone the repository.
- Create the environment using
environment-dev.yml. - Install in editable mode using
pip install -e ..
A
devcontaineris also provided for running the development environment in a lightweight container via VS Code.# Pip pip install graphein[dev] # For dev dependencies pip install graphein[all] # To get the lot # Conda git clone https://www.github.com/a-r-j/graphein cd graphein conda env create -f environment-dev.yml pip install -e .- Dev dependencies:
Explore PROTEINS_LIGANDS dataset
masterThe
PROTEINS_LIGANDSdataset contains protein-ligand interactions. It is a collection of non-redundant PDB chains of ligand-interacting protein chains.Dataset Properties:
- Source: ccPDB
- Redundancy Reduction: Blastclust (25% identity) and LPC
- Selection Criteria: PDB resolution $\le$ 3 $\AA$, chain length $\ge$ 80 amino acids, and interaction distance (SO4 - amino acid) between 0-4.0 $\AA$.
Available Subsets:
PDB Ligand Ligand Name # Proteins Dataset SO4 Sulphate 3312 SO4_3312 PO4 Phosphate 1299 PO4_1299 NAG N-Acetylglucosamine 727 NAG_727 HEM Heme 176 HEM176 BME Beta-Mercaptoethanol 191 BME191 EDO Ethylene Glycol 1507 EDO1507 PLP Vitamin B6 Phosphate 65 PLP65 For a full walkthrough on how to parse this dataset, use the provided Colab notebook.
https://colab.research.google.com/research/urls?urls=https://github.com/a-r-j/graphein/blob/master/datasets/proteins_ligands/parse_dataset.ipynbInstall Deep Learning Libraries
masterGraphein supports various deep learning configurations. While the Conda dev environment includes CUDA 11.1 and PyTorch, you can manually install these libraries via Conda:
pytorchpytorch3d(requiresfvcoreandiopath)dgl(viadglteamchannel)pytorch-geometric(viarusty1sandconda-forgechannels)
conda install -c pytorch pytorch conda install -c pytorch3d pytorch3d conda install -c dglteam dgl conda install pytorch-geometric -c rusty1s -c conda-forgeInstall optional utilities (DSSP, PyMol, GetContacts)
masterSome Graphein features require external utilities not available via PyPI.
- DSSP: Required for computing secondary structural features.
- PyMol: Required for PyMol visualisations & mesh generation.
- GetContacts: An alternative way to compute intramolecular interactions.
Use the following commands to install them via Conda or manual setup:
conda install -c salilab dssp # Required for computing secondary structural features conda install -c schrodinger pymol # Required for PyMol visualisations & mesh generation # GetContacts setup conda install -c conda-forge vmd-python git clone https://github.com/getcontacts/getcontacts echo "export PATH=$PATH:`pwd`/getcontacts" >> ~/.bashrc source ~/.bashrc