Skip to content

This Python script is designed to provide detailed information on interactions between drugs and genes using the Sydney module for natural language processing and the Drug Gene Interaction Database (DGIdb) API. Users can input the names of three drugs separated by commas and receive information on the interactions with the corresponding genes.

License

Notifications You must be signed in to change notification settings

DavidAI2024/DrugGeneExplorer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

45 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

DrugGeneExplorer

Version License: MIT Python Version litellm

Warning

Alpha Version This code is currently in an alpha phase and may contain bugs or instability. I am an evolving novice and learning during the development process. This tool was created in my spare time, fueled by a passion for knowledge and experimentation.

Required Changes: Since this is an alpha version, it is likely that changes or optimizations may be necessary to improve the efficiency and stability of the tool. You are encouraged to contribute, suggest improvements, or report issues. Your participation is crucial to make this tool more robust and functional.

Thanks to everyone who will use this tool and contribute to its evolution. Your collaboration is invaluable for the continuous improvement of the project.

Note

A special thanks to vsakkas for creating the Sydney-py library, and to all those who contributed to its inception and upkeep.

A DrugGeneExplorer robot based on Coopilot with no risk, very stable! ๐Ÿš€

Introduction

This Python bot is designed to gather interactions data from the Drug-Gene Interaction Database (DGIdb) and utilizes the sydney-py library to obtain more detailed information about specific interactions.

Important

Before using Sydney.py, it's essential to gather the necessary authentication cookies from the Copilot web page. These cookies will be utilized to authenticate your requests to the Copilot API.

To obtain the cookies, follow these steps using Microsoft Edge:

  1. Navigate to the Copilot web page.
  2. Open the developer tools in your browser (typically by pressing F12 or right-clicking on the chat dialog and selecting Inspect).
  3. Access the Network tab to observe all requests sent to Copilot.
  4. Write a message in the chat dialog on the web page.
  5. Identify a request named create?bundleVersion=XYZ and click on it.
  6. Scroll down to the requests headers section and copy the entire value after the Cookie: field.

Next, set the obtained value as an environment variable in your shell:

export BING_COOKIES=<your-cookies>

or, in your Python code:

os.environ["BING_COOKIES"] = "<your-cookies>"

Tip

  • citations: if set to True, the AI's response will include links to the sources from which it has extracted information. If set to False, the AI's response will not show citations. The default value is False.

  • search: if set to True, the AI will seek the answer through the internet, using Bing as the search engine. If set to False, the AI will only utilize its computational power, relying on its internal knowledge. The default value is False.

Example:

response = await sydney.ask(prompt, citations=False, search=False)

Features

  • Interaction with Sydney

    • Utilizes the Sydney module to acquire detailed and contextually informative responses concerning drug-gene interactions.
  • Command-Line Interface (CLI)

    • Offers an intuitive command-line interface, facilitating seamless interaction with scripts.
  • Graphical Gene Interactions Chart

    • Generates a bar chart illustrating gene interactions related to a user-selected gene, providing a visual representation of information.
  • Elegant Response in PyQt5 Box

    • Displays responses in a graphical box created with PyQt5, offering a visually pleasing and user-friendly experience.
  • Customizable Font:

    • Users can enhance personalization by changing the font. Simply install the preferred font locally and specify the TTF file path.
  • Rich Box Visualization

    • Presents drug-gene interactions in visually formatted Rich boxes for enhanced clarity.
  • Interaction Details

    • Exhibits crucial interaction details, including scores, interaction types, gene names, and more.
  • Minimum Requirements

    • Requires Python 3.9 - 3.11 as the execution environment.
    • External dependencies, such as rich, Sydney, PyQt5, requests, and matplotlib, can be effortlessly installed with the command pip install -r requirements.txt.
  • Simple Usage Instructions

    • Follow the provided instructions to install dependencies and run the script, ensuring a straightforward and immediate application usage.
  • Author Information

    • Includes a dedicated section for project authors.
  • Open Source License (MIT)

    • Distributed under the MIT license, ensuring transparent and clear management of usage conditions.
  • Reset Conversation Command

    • Introduces a new feature: users can reset the conversation with the AI using the command "!reset."

Getting Start

It is recommended that the Python version be between 3.9.X~3.10.X, version 3.10-3.11 is perfect

1. Clone repo

https://github.com/BlackDicky/DrugGeneExplorer.git

Dependencies

Make sure to install the following dependencies before running the project:

  • requests: HTTP library for making requests.
  • asyncio: Library for writing asynchronous code using coroutines.
  • sydney: SydneyClient - A library that interfaces with Copilot by Microsoft, leveraging the artificial intelligence of Bing and powered by GPT-4.
  • rich: Terminal rendering library for rich text and beautiful formatting.
  • matplotlib: Plotting library for creating visualizations.
  • PyQt5: Python bindings for the Qt application framework.
  • pandas: Data manipulation library for working with structured data.
  • kaleido: Static image export for Plotly charts.

To install the dependencies, you can use the provided requirements.txt file. Run the following command:

pip install -r requirements.txt

Start Script

Visit the Google Fonts website to explore the "Recursive" font. Remember to install Google's "Recursive" font locally.

  • Once all the steps are completed, you can launch the script by using the command:
 python3 DrugGeneExplorer.py

Warning

Important Note: This tool includes the display of emojis to enhance the user experience. Before using the tool, make sure that your terminal supports emoji rendering. Some terminals might not display emojis correctly, which could affect the appearance and understanding of the output.

If your terminal doesn't support emojis, you may encounter unexpected visualizations or unrecognized characters. To avoid this issue, we recommend using a terminal that is compatible with emojis or enabling emoji support in your environment.

Tip

Note for Handling Infinite Loop: ๐Ÿ”„ In the rare event that the tool enters an infinite loop without providing a response, you can interrupt the process by simultaneously pressing Ctrl + Z or Ctrl + C on your keyboard.

This keyboard shortcut combination will help you terminate the tool's execution and regain control of your terminal. If you experience persistent issues or have any questions, please consider opening an issue in the designated "Issues" section.

Your feedback is valuable to us, and we'll do our best to address and resolve any concerns you may have.

Dynamic Visualization of the Tool in Action

Start
Start
Drug-gene interaction research
Drug-Gene
Interaction results
Interactions
Graph of all genes interacting with the selected drug, highlighting the one with the most significant interference among them all.
Genes
Selection of the gene to be passed to artificial intelligence for a detailed analysis of the interaction between the drug and the gene.
Image#1
Image#2
Final Response in both CLI (Command Line Interface) and GUI (Graphical User Interface) Formats.
FinalResponse

About

This Python script is designed to provide detailed information on interactions between drugs and genes using the Sydney module for natural language processing and the Drug Gene Interaction Database (DGIdb) API. Users can input the names of three drugs separated by commas and receive information on the interactions with the corresponding genes.

Topics

Resources

License

Stars

Watchers

Forks

Languages