Skip to content

axp-knickei/netpharmpy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

40 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

netpharmpy

Python Version License: MIT DOI

Network pharmacology pipeline for drug discovery and target prediction. Integrates Reactome pathway analysis, STRING protein-protein interaction networks, and multi-omics enrichment (GO/KEGG/Reactome). User-friendly Python framework for computational biologists with guided workflows and publication-ready outputs.

pathway enrichment

string interaction


๐Ÿ“‹ Table of Contents


Overview

netpharmpy is a comprehensive Python toolkit for network pharmacology analysis, designed to facilitate drug discovery and target prediction research. It automates the workflow described in recent network pharmacology studies, providing a reproducible and user-friendly pipeline for:

  • Target Prediction: Identifying potential protein targets for small molecules
  • Pathway Analysis: Mapping targets to biological pathways
  • Network Construction: Building protein-protein interaction networks
  • Functional Enrichment: Discovering biological significance

Key Applications:

  • Drug repurposing studies
  • Natural product pharmacology
  • Mechanism of action elucidation
  • Multi-target drug discovery
  • Systems pharmacology research

Inspired by: Limsakul et al. (2025) - Immunomodulatory Effects of Curcumin on CAR T-Cell Therapy

Motivation and design rationale

Pharmacological effects often emerge from interactions across complex biological networks rather than from modulation of single molecular targets. While numerous databases and tools exist for drugโ€“target and proteinโ€“protein interaction analysis, many available solutions are tightly coupled to specific data sources, impose rigid analytical pipelines, or obscure intermediate computational steps.

netpharmpy was developed to address these limitations by offering a minimal and extensible software layer that allows researchers to:

  1. Represent pharmacological data explicitly as networks,
  2. Apply graph-based analyses using familiar Python workflows, and
  3. Integrate custom data sources and downstream analyses without vendor or database lock-in.

The software prioritizes methodological clarity over automation and is intentionally agnostic to specific biological interpretations or predictive claims.

Core functionality

At its core, netpharmpy provides utilities for:

  • Constructing network representations of drugโ€“target interactions and related biological relationships
  • Manipulating and querying these networks using graph-based abstractions
  • Performing basic network analyses suitable for exploratory systems pharmacology research

The package is designed to interoperate seamlessly with the broader scientific Python ecosystem, allowing users to extend analyses using external libraries for statistics, visualization, or downstream biological interpretation.

Intended use cases

netpharmpy is suitable for a range of research-oriented applications, including:

  • Exploratory analysis of drugโ€“target interaction networks
  • Investigation of polypharmacology and multi-target drug effects
  • Integration of pharmacological data with proteinโ€“protein interaction networks
  • Identification of subnetworks or pathways potentially perturbed by drug intervention
  • Rapid prototyping of network pharmacology workflows prior to large-scale or production-level analyses

The software is intended for use by computational biologists, bioinformaticians, and systems pharmacology researchers with basic familiarity in Python programming.


Features

  • โœ… Automated Pipeline: Five-step workflow from compound to network visualization
  • โœ… Multi-Database Integration: SwissTargetPrediction, SuperPred, Reactome, STRING, g:Profiler
  • โœ… Reproducible Research: Configuration files and detailed logging
  • โœ… Publication-Ready Outputs: High-quality network visualizations (PNG, HTML)
  • โœ… User-Friendly: Interactive prompts and clear instructions
  • โœ… Flexible: Command-line and Python API access
  • โœ… Well-Documented: Comprehensive examples and tutorials

๐Ÿ“ฆ Installation

Prerequisites

  • Python 3.8 or higher
  • Internet connection (for API access)

Using pip (coming soon)

pip install netpharmpy

From Source

# Clone the repository
git clone https://github.com/axp-knickei/netpharmpy.git
cd netpharmpy

# Create virtual environment (recommended)
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Install in editable mode
pip install -e .

Using uv (faster alternative)

git clone https://github.com/axp-knickei/netpharmpy.git
cd netpharmpy

# Create and activate environment
uv venv
source .venv/bin/activate

# Install dependencies
uv pip install -r requirements.txt

# Install package
uv pip install -e .

Quick Start

Simple Example

from netpharm import NetworkPharmacology

# Initialize with curcumin (PubChem CID: 969516)
npharma = NetworkPharmacology(cid=969516)

# Run complete analysis
npharma.run_full_pipeline()

Command Line

# Interactive mode
python main.py

# With configuration file
python main.py --config examples/config_example.yaml

Usage

Interactive Mode

The simplest way to use netpharmpy - the tool will guide you through each step:

python main.py

You'll be prompted for:

  • Compound input (CID or SMILES)
  • Target prediction thresholds
  • Pathway keywords or IDs
  • Network parameters
  • Enrichment method

Configuration File

For reproducible research, use a YAML configuration file:

# config.yaml
compound:
  cid: 969516  # Curcumin

target_prediction:
  swiss_threshold: 0.0
  superpred_threshold: 0.5

pathways:
  search_terms:
    - "R-HSA-1280218"  # Adaptive Immune System
    - "R-HSA-1280215"  # Cytokine Signaling

string:
  confidence: 0.700

enrichment:
  method: "gprofiler"  # or "david"

output:
  directory: "./results"

Run with:

python main.py --config config.yaml

Python API

For integration into your own scripts:

from netpharm import NetworkPharmacology

# Initialize
npharma = NetworkPharmacology(
    cid=969516,
    output_base='./my_analysis'
)

# Step-by-step execution
npharma.get_compound_info()
npharma.predict_targets(swiss_threshold=0.0, superpred_threshold=0.5)
npharma.analyze_pathways(['R-HSA-1280218', 'R-HSA-1280215'])
npharma.build_network(confidence=0.700)
npharma.enrichment_analysis(method='gprofiler')

๐Ÿ” Pipeline Logic & Interpretation

The pipeline is organized as a sequence of steps, but each step serves a different purpose.

Step Purpose Question Answered
1-2. Target Prediction Data Retrieval What are the potential targets?
3. Pathway Analysis Biological Filtering Which targets are relevant to my specific system?
4. Network Analysis Systems Context How do these proteins interact?
5. Enrichment Statistical Interpretation What functions are statistically over-represented?

Key Distinctions:

  • Step 3 is not a statistical test โ€” it is a biologically informed filter to reduce noise.
  • Step 4 does not identify drug targets โ€” it reveals the connectivity and structure of the system.
  • Step 5 provides statistical support โ€” it tests for over-representation of functional themes.

Pipeline Steps

Step 1: Compound Information Retrieval

Retrieves molecular properties from PubChem:

  • Canonical SMILES
  • Molecular formula and weight
  • IUPAC name

Database: PubChem

Step 2: Target Prediction

Predicts potential protein targets using:

  • SwissTargetPrediction: Similarity-based predictions
  • SuperPred: Known strong binders + predicted targets

Manual workflow with clear instructions for downloading results.

Step 3: Pathway Analysis (Biological Filtering)

Uses curated biological pathways to filter predicted targets to those relevant to the biological system of interest:

  • Searches user-defined Reactome pathways
  • Extracts all proteins involved in those pathways
  • Retains only predicted targets that overlap with pathway proteins

Database: Reactome (used as a source of curated biological pathway knowledge)

Step 4: Network Construction

Builds protein-protein interaction networks:

  • Queries STRING database
  • Analyzes network topology
  • Identifies hub proteins
  • Creates three visualization types:
    • Basic (publication-ready PNG)
    • Colored (degree-based)
    • Interactive (HTML)

Database: STRING

Step 5: Functional Enrichment (Statistical Interpretation)

Performs statistical enrichment analysis on biologically filtered targets:

  • Gene Ontology (Biological Process, Molecular Function, Cellular Component)
  • KEGG pathway annotations
  • Reactome pathway annotations

Tools: g:Profiler or DAVID (used for over-representation analysis)

The pipeline intentionally separates biological filtering (Step 3), network context (Step 4), and statistical interpretation (Step 5). Step 3 determines biological relevance using curated pathway knowledge, while Step 5 statistically describes functional patterns within that biologically constrained gene set. This separation avoids conflating mechanistic reasoning with statistical enrichment.


๐Ÿ“‚ Output Structure

outputs/
โ””โ”€โ”€ compound_969516_20251213_123456/
    โ”œโ”€โ”€ step1_compound_info/
    โ”‚   โ””โ”€โ”€ compound_info.csv
    โ”œโ”€โ”€ step2_targets/
    โ”‚   โ”œโ”€โ”€ swiss_targets.csv
    โ”‚   โ””โ”€โ”€ superpred_targets.csv
    โ”œโ”€โ”€ step3_pathways/
    โ”‚   โ”œโ”€โ”€ pathways_searched.csv
    โ”‚   โ”œโ”€โ”€ pathway_proteins.csv
    โ”‚   โ””โ”€โ”€ overlapping_targets.csv
    โ”œโ”€โ”€ step4_network/
    โ”‚   โ”œโ”€โ”€ string_interactions.csv
    โ”‚   โ”œโ”€โ”€ network_metrics.csv
    โ”‚   โ”œโ”€โ”€ network_basic.png
    โ”‚   โ”œโ”€โ”€ network_colored.png
    โ”‚   โ””โ”€โ”€ network_interactive.html
    โ”œโ”€โ”€ step5_enrichment/
    โ”‚   โ”œโ”€โ”€ gprofiler_all_results.csv
    โ”‚   โ”œโ”€โ”€ gprofiler_go_bp.csv
    โ”‚   โ”œโ”€โ”€ gprofiler_kegg.csv
    โ”‚   โ””โ”€โ”€ gprofiler_reac.csv
    โ””โ”€โ”€ 969516_20251213_123456.log

๐Ÿ“š Examples

Curcumin Analysis (Replicating Published Study)

python examples/curcumin_example.py

This example replicates the analysis from:

Limsakul, P., et al. (2025). Immunomodulatory Effects of Curcumin on CAR T-Cell Therapy. Antioxidants, 14(4), 454.

Custom Compound Analysis

from netpharm import NetworkPharmacology

# Example: Resveratrol (CID: 445154)
npharma = NetworkPharmacology(cid=445154)
npharma.run_full_pipeline()

Batch Analysis (Coming in v2.0)

Feature planned for future release.

๐Ÿ” Post-Pipeline Analysis (analysis.py)

What is analysis.py?

analysis.py is a post-pipeline analysis script designed to interpret, summarize, and extend the results generated by the main network pharmacology pipeline (main.py).

Importantly:

  • analysis.py does not run the pipeline
  • It does not modify any results
  • It only consumes outputs generated in the outputs/ directory

This strict separation ensures that data generation, visualization, and interpretation are not conflated, which is critical for reproducible and defensible scientific analysis.


Why is analysis.py separated from the core pipeline?

The pipeline is intentionally divided into conceptual layers:

Layer Purpose Scripts
Data generation Retrieve, filter, and construct biological networks main.py, core.py, network.py
Visualization Render network structure for inspection and figures visualize.py
Interpretation Quantitative reasoning and result summarization analysis.py

This design avoids common pitfalls such as:

  • Mixing statistical interpretation with network construction
  • Hard-coding analytical assumptions into the pipeline
  • Making figures depend on undocumented logic

What does analysis.py do?

analysis.py operates on pipeline outputs such as:

  • step4_network/network_metrics.csv
  • step4_network/string_interactions.csv
  • step3_pathways/overlapping_targets.csv
  • (optionally) enrichment results from Step 5

Typical analyses performed in analysis.py include:

  • Identifying and ranking hub proteins
  • Comparing centrality measures (degree, betweenness, closeness)
  • Inspecting connector nodes and local subnetworks
  • Supporting figure selection (e.g., top-N hubs)
  • Preparing tables or statistics for manuscripts

All analytical decisions are explicit and script-level, making them easy to review, revise, or justify.


How to use analysis.py

After running the pipeline with:

uv run python main.py --config config.yaml

Run post-analysis with:

uv run python analysis.py --output_dir ./outputs/compound_XXXX

analysis.py will read existing CSV files and produce summaries, reports, and publication-quality figures without re-running the pipeline.


Understanding Bipartite Network Figures

The analysis.py script generates two specialized bipartite networks connecting Hub Proteins (circles) to Reactome Pathways (squares). These figures use the Nature Publishing Group (NPG) color scheme and provide different topological perspectives:

1. Betweenness Centrality (hub_pathway_bipartite_betweenness.png)

  • Node Size โˆ Betweenness Centrality: Larger protein nodes represent strategic bottlenecks in the global interaction network.
  • Scientific Significance: These proteins act as critical bridges that control the flow of biological information. Targeting these "bottlenecks" often leads to the most significant disruption of the disease-related network.

2. Global Degree (hub_pathway_bipartite_global_degree.png)

  • Node Size โˆ Global Degree: Larger protein nodes represent major cellular hubs with the highest total number of interactions in the full STRING database.
  • Scientific Significance: These are the "promiscuous" proteins of the cell. While they are central to biology, high-degree hubs can sometimes be associated with a higher risk of off-target effects if inhibited.

Common Visual Elements:

  • Coloring: Dark Blue nodes are multi-pathway hubs (pleiotropic), while Light Blue nodes connect to a single pathway in the current view.
  • Edges: Smooth S-curves connect proteins to their respective pathways. Thicker lines highlight connections from multi-pathway proteins, emphasizing their functional versatility.

Reproducibility note

Because analysis.py only consumes saved outputs:

  • Results can be re-analyzed without re-querying external databases
  • Analytical choices can be changed without affecting raw data
  • Multiple analysis strategies can be tested on the same results

This makes the workflow suitable for iterative scientific reasoning, peer review, and long-term maintenance.

Pipeline Architecture Diagram


Documentation


Citation

If you use netpharmpy in your research, please cite:

@software{netpharmpy2025,
  author = {Alex Prima},
  title = {netpharmpy: Network Pharmacology Pipeline for Drug Discovery},
  year = {2025},
  url = {https://github.com/axp-knickei/netpharmpy},
  version = {0.1.0},
  doi={doi.org/10.5281/zenodo.18074031}
}

Citing the Methodology

This tool implements the methodology described in:

@article{limsakul2025immunomodulatory,
  title={Immunomodulatory Effects of Curcumin on CAR T-Cell Therapy},
  author={Limsakul, Praopim and Srifa, Pemikar and Huang, Ziliang and Zhu, Linshan and Wu, Yiqian and Charupanit, Krit},
  journal={Antioxidants},
  volume={14},
  number={4},
  pages={454},
  year={2025},
  publisher={MDPI},
  doi={10.3390/antiox14040454}
}

Credits & References

External Tools & Databases

netpharmpy integrates the following resources:

Chemical & Compound Databases

Target Prediction

  • SwissTargetPrediction - Daina, A., Michielin, O., & Zoete, V. (2019). SwissTargetPrediction: updated data and new features. Nucleic Acids Research, 47(W1), W357-W364. http://www.swisstargetprediction.ch/

  • SuperPred - Nickel, J., et al. (2014). SuperPred: update on drug classification and target prediction. Nucleic Acids Research, 42(W1), W26-W31. https://prediction.charite.de/

Pathway Databases

  • Reactome - Milacic, M., et al. (2024). The Reactome Pathway Knowledgebase 2024. Nucleic Acids Research, 52(D1), D672-D678. https://reactome.org/

Protein-Protein Interactions

  • STRING - Szklarczyk, D., et al. (2023). The STRING database in 2023: protein-protein association networks. Nucleic Acids Research, 51(D1), D638-D646. https://string-db.org/

Functional Enrichment

  • g:Profiler - Kolberg, L., et al. (2023). g:Profilerโ€”interoperable web service for functional enrichment analysis. Nucleic Acids Research, 51(W1), W207-W212. https://biit.cs.ut.ee/gprofiler/

  • DAVID - Sherman, B.T., et al. (2022). DAVID: a web server for functional enrichment analysis. Nucleic Acids Research, 50(W1), W216-W221. https://david.ncifcrf.gov/

Python Libraries


Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

Development Setup

git clone https://github.com/axp-knickei/netpharmpy.git
cd netpharmpy
pip install -e ".[dev]"
pytest tests/

Contribution Guidelines

  • Follow PEP 8 style guidelines
  • Add tests for new features
  • Update documentation as needed
  • Ensure all tests pass before submitting PR

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ“ง Contact


Acknowledgments

  • Inspired by the methodology of Limsakul et al. (2025)
  • Thanks to all the database and tool maintainers cited above
  • Built with support from the bioinformatics community

๐Ÿ“Š Project Status

Development Status Version DOI

Current Version: 0.1.2

Release Date: February 2026

Features

  • โœ… Target prediction (SwissTargetPrediction + SuperPred)
  • โœ… Pathway analysis (Reactome)
  • โœ… Network construction (STRING)
  • โœ… Enrichment analysis (g:Profiler + DAVID)
  • โœ… Multiple visualization formats
  • โœ… Configuration file support
  • โœ… Logging system
  • โœ… Basic unit tests

Roadmap

v1.1.0

  • Backup pathway data for offline analysis
  • Enhanced error recovery
  • Additional visualization options
  • Docker container support

Known Issues

netpharmpy is currently released as early-stage research software. Known limitations include:

  • APIs may evolve as the project matures
  • Reactome API may occasionally be unavailable (temporary server issues)
  • Manual downloads required for SwissTargetPrediction and SuperPred
  • Documentation and tutorials are intentionally minimal but under active development
  • Performance has not yet been optimized for very large-scale networks
  • Large networks (>100 proteins) may take longer to visualize
  • The package does not provide built-in visualization or clinical interpretation modules

Biological interpretation of results remains the responsibility of the user, and netpharmpy does not aim to provide clinical or predictive decision support.

Report bugs or request features: GitHub Issues


๐Ÿ“ˆ Statistics

GitHub stars GitHub forks GitHub issues GitHub pull requests


Last updated: January 31, 2026

About

A Python package for network-based pharmacology and systems-level drug analysis. Integrates Reactome pathway analysis, STRING protein-protein interaction networks, and multi-omics enrichment (GO/KEGG/Reactome).

Topics

Resources

License

Stars

Watchers

Forks

Packages