Package: graphein
Documentation|Paper|Tutorials|InstallationProtein & Interactomic Graph LibraryThis package provides functionality for producing geometric representations of protein and RNA structures, and biological interaction networks. We provide compatibility with standard PyData formats, as well as graph objects designed for ease of use with popular deep learning libraries.What's New?1.7.0FoldComp Datasets1.7.0Creating Datasets from the PDB1.6.0Protein Tensor Module1.5.0Protein Graph Creation from AlphaFold2!1.5.0RNA Graph Construction from Dotbracket notation1.4.0Constructing molecular graphs1.3.0Ready-to-go Dataloaders for PyTorch Geometric1.2.0Extracting subgraphs from protein graphs1.2.0Protein Graph Analytics1.2.0Graphein CLI1.2.0Protein Graph Visualisation!1.1.0Protein - Protein Interaction Network Support & Structural Interactomics (Using AlphaFold2!)1.0.0High and Low-level API for massive flexibility - create your own bespoke workflows!Example usageGraphein provides both a programmatic API and a command-line interface for constructing graphs.CLIGraphein configs can be specified as.yamlfiles to batch process graphs from the commandline.Docsgraphein-cconfig.yaml-ppath/to/pdbs-opath/to/outputCreating a Protein GraphTutorial (Residue-level)Tutorial (Atomic)Docsfromgraphein.protein.configimportProteinGraphConfigfromgraphein.protein.graphsimportconstruct_graphconfig=ProteinGraphConfig()g=construct_graph(config=config,pdb_code="3eiy")Creating a Protein Graph from the AlphaFold Protein Structure DatabaseTutorialDocsfromgraphein.protein.configimportProteinGraphConfigfromgraphein.protein.graphsimportconstruct_graphfromgraphein.protein.utilsimportdownload_alphafold_structureconfig=ProteinGraphConfig()fp=download_alphafold_structure("Q5VSL9",aligned_score=False)g=construct_graph(config=config,path=fp)Creating a Protein MeshTutorialDocsfromgraphein.protein.configimportProteinMeshConfigfromgraphein.protein.meshesimportcreate_meshverts,faces,aux=create_mesh(pdb_code="3eiy",config=config)Creating Molecular GraphsGraphein can create molecular graphs from smiles strings as well as.sdf,.mol2, and.pdbfilesTutorialDocsfromgraphein.molecule.configimportMoleculeGraphConfigfromgraphein.molecule.graphsimportconstruct_graphg=create_graph(smiles="CC(=O)OC1=CC=CC=C1C(=O)O",config=config)Creating an RNA GraphTutorialDocsfromgraphein.rna.graphsimportconstruct_rna_graph# Build the graph from a dotbracket & optional sequencerna=construct_rna_graph(dotbracket='..(((((..(((...)))..)))))...',sequence='UUGGAGUACACAACCUGUACACUCUUUC')Creating a Protein-Protein Interaction GraphTutorialDocsfromgraphein.ppi.configimportPPIGraphConfigfromgraphein.ppi.graphsimportcompute_ppi_graphfromgraphein.ppi.edgesimportadd_string_edges,add_biogrid_edgesconfig=PPIGraphConfig()protein_list=["CDC42","CDK1","KIF23","PLK1","RAC2","RACGAP1","RHOA","RHOB"]g=compute_ppi_graph(config=config,protein_list=protein_list,edge_construction_funcs=[add_string_edges,add_biogrid_edges])Creating a Gene Regulatory Network GraphTutorialDocsfromgraphein.grn.configimportGRNGraphConfigfromgraphein.grn.graphsimportcompute_grn_graphfromgraphein.grn.edgesimportadd_regnetwork_edges,add_trrust_edgesconfig=GRNGraphConfig()gene_list=["AATF","MYC","USF1","SP1","TP53","DUSP1"]g=compute_grn_graph(gene_list=gene_list,edge_construction_funcs=[partial(add_trrust_edges,trrust_filtering_funcs=config.trrust_config.filtering_functions),partial(add_regnetwork_edges,regnetwork_filtering_funcs=config.regnetwork_config.filtering_functions),],)InstallationPipThe simplest install is via pip.N.B this does not install ML/DL libraries which are required for conversion to their data formats and for generating protein structure meshes with PyTorch 3D.Further detailspipinstallgraphein# For base installpipinstallgraphein[extras]# For additional featurisation dependenciespipinstallgraphein[dev]# For dev dependenciespipinstallgraphein[all]# To get the lotHowever, there are a number of (optional) utilities (DSSP,PyMol,GetContacts) that are not available via PyPI:conda install -c salilab dssp # Required for computing secondary structural features
conda install -c schrodinger pymol # Required for PyMol visualisations & mesh generation

# GetContacts - used as an alternative way to compute intramolecular interactions
conda install -c conda-forge vmd-python
git clone https://github.com/getcontacts/getcontacts

# Add folder to PATH
echo "export PATH=\$PATH:`pwd`/getcontacts" >> ~/.bashrc
source ~/.bashrc
To test the installation, run:

cd getcontacts/example/5xnd
get_dynamic_contacts.py --topology 5xnd_topology.pdb \
                        --trajectory 5xnd_trajectory.dcd \
                        --itypes hb \
                        --output 5xnd_hbonds.tsvConda environmentThe dev environment includes GPU Builds (CUDA 11.1) for each of the deep learning libraries integrated into graphein.gitclonehttps://www.github.com/a-r-j/grapheincdgraphein
condaenvcreate-fenvironment-dev.yml
pipinstall-e.A lighter install can be performed with:gitclonehttps://www.github.com/a-r-j/grapheincdgraphein
condaenvcreate-fenvironment.yml
pipinstall-e.DockerfileWe provide twodocker-composefiles for CPU (docker-compose.cpu.yml) and GPU usage (docker-compose.yml) locally. For GPU usage please ensure that you haveNVIDIA Container Toolkitinstalled. Ensure that you install the locally mounted volume after entering the container (pip install -e .). This will also setup the dev environment locally.To build (GPU) run:docker-compose up -d --build # start the container
docker-compose down # stop the containerCiting GrapheinPlease consider citing graphein if it proves useful in your work.@inproceedings{jamasb2022graphein,title={Graphein - a Python Library for Geometric Deep Learning and Network Analysis on Biomolecular Structures and Interaction Networks},author={Arian Rokkum Jamasb and Ramon Vi{\~n}as Torn{\'e} and Eric J Ma and Yuanqi Du and Charles Harris and Kexin Huang and Dominic Hall and Pietro Lio and Tom Leon Blundell},booktitle={Advances in Neural Information Processing Systems},editor={Alice H. Oh and Alekh Agarwal and Danielle Belgrave and Kyunghyun Cho},year={2022},url={https://openreview.net/forum?id=9xRZlV6GfOX}}