A Flask web application for searching and analyzing compound relationships in the HBDB database.
- Python 3.10
- Docker and Docker Compose
- MySQL 8.0
-
Clone the repository
-
Create a
.env
file in the root directory with the following variables:
MYSQL_HOST=mysql
MYSQL_PORT=3306
MYSQL_USER=root
MYSQL_ROOT_PASSWORD=your_password
MYSQL_DATABASE=hbdb2
-
Place your
hbdb2.sql
file in the root directory -
Build and run the containers:
docker-compose up --build
The application will be available at http://localhost:5020
- Create a Python virtual environment:
python -m venv venv
source venv/bin/activate # Linux/Mac
venv\Scripts\activate # Windows
- Install dependencies:
pip install -r requirements.txt
- Configure MySQL:
- Install MySQL 8.0
- Create a database named
hbdb2
- Import the
hbdb2.sql
file
- Set up environment variables:
- Create a
.env
file with the same variables as shown in the Docker setup - Adjust MYSQL_HOST to
localhost
for local development
- Run the application:
python app.py
- Access the web interface at
http://localhost:5020
- Enter a compound ID in the search form
- View the results showing:
- Compound name
- Related terms
- Context information
- Category classifications
The application generates JSON files for each compound-concept relationship. These files are stored in the following structure:
{compound_name}/
├── concept_abnormality_metadata/
├── concept_chemical_metadata/
├── concept_molecular function_metadata/
├── concept_gene_metadata/
├── concept_location_metadata/
└── concept_animal model_metadata/
Each JSON file follows the naming format:
{compound_name}_{term_B}_{paragraph}.json
To download the JSON files:
- After searching for a compound, the files will be generated in the appropriate directories
- Access the files directly from the project directory
- Each JSON file contains:
{ "term_A": "compound name", "term_B": "related concept", "context": "surrounding text including the target sentence", "category": "concept category" }
app.py
: Main Flask applicationtemplates/
: HTML templatesdocker-compose.yml
: Docker services configurationDockerfile
: Web application container configurationrequirements.txt
: Python dependencies.env
: Environment variables (create this)hbdb2.sql
: Database schema and data (provide this)
MYSQL_HOST
: MySQL server hostnameMYSQL_PORT
: MySQL server portMYSQL_USER
: MySQL usernameMYSQL_ROOT_PASSWORD
: MySQL root passwordMYSQL_DATABASE
: Database name (hbdb2)